пишу социальную сеть. и если делать редактирование профиля по айди, то можно будет изменять чужие профили, решил сделать, чтобы редактирование профиля осуществлялось не по айди и выдаёт ошибку, как её исправить?
urls.py
path('profile/edit/', ProfileEditView.as_view(), name='profile_edit'),
views.py
class ProfileEditView(UpdateView):
model = Profile
template_name = 'users/profile_edit.html'
fields = ['avatar', 'name']
success_url = reverse_lazy('main:index')
profile_edit.html
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Registration</button>
</form>
сама ошибка:
Internal Server Error: /profile/edit/
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\views\generic\base.py", line 103, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\views\generic\base.py", line 142, in dispatch
return handler(request, *args, **kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\views\generic\edit.py", line 203, in get
self.object = self.get_object()
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\django\views\generic\detail.py", line 46, in get_object
raise AttributeError(
AttributeError: Generic detail view ProfileEditView must be called with either an object pk or a slug in the URLconf.
[30/Dec/2022 21:28:09] "GET /profile/edit/ HTTP/1.1" 500 78892