I written this logic in my views.py, and I used class based views, Detail view:
@login_required
class profileView(DetailView):
model = profile
template_name = "users/profile.html"
and in urls.py file I've written this:
from django.urls import path,include
from . import views
from .views import profileView
urlpatterns = [
path('register/',views.register,name="register"),
path('login/',views.login_user,name="login_user"),
path('profile/',profileView.as_view(),name="profile_view"),
]
the django version that I'm using is 3.1 and python version is 3.8.
I hope that someone has an answer to my question.