#NoReverseMatch at /profile/drake Reverse for 'edit_profile' with arguments '('drake')' not found.

1 messages · Page 1 of 1 (latest)

hard pulsar
#

This is my ProfileEditView code:

class ProfileEditView(LoginRequiredMixin, mixins.OnlyAuthorMixin, UpdateView):
    model = User
    form_class = UserForm
    template_name = 'blog/user.html'

    def get_object(self, queryset=None):
        return self.request.user

    def get_success_url(self):
        return reverse('profile', kwargs={'username': self.request.user.username})

    def form_valid(self, form):
        return super().form_valid(form)
cobalt lily
#

Keeping inline with rule 8 of the server. I would have a look at your urls.py.

hard pulsar
#

ok, this is my urls.py

from django.urls import path

from . import views

app_name = 'blog'

urlpatterns = [
    path('', views.PostListView.as_view(), name='index'),
    path('profile/edit/',
         views.ProfileEditView.as_view(),
         name='edit_profile',
         ),    
    path('profile/<str:username>/',
         views.ProfileView.as_view(),
         name='profile'
         ),
    path('posts/<int:id>/edit/',
         views.PostEditView.as_view(),
         name='edit_post',
         ),
    path('posts/<int:id>/',
         views.PostDetailView.as_view(),
         name='post_detail'
         ),
    path('posts/create/',
         views.PostCreateView.as_view(),
         name='create_post'
         ),
    path('posts/<int:id>/delete/',
         views.PostDeleteView.as_view(),
         name='delete_post',
         ),
    path('category/<slug:category_slug>/',
         views.CategoryPostsView.as_view(),
         name='category_posts'
         ),
    path('posts/<int:post_id>/comment/',
         views.CommentCreateView.as_view(),
         name='add_comment',
         ),
    path('posts/<int:post_id>/edit_comment/<int:comment_id>/',
         views.CommentEditView.as_view(),
         name='edit_comment',
         ),
    path('posts/<int:post_id>/delete_comment/<int:comment_id>/',
         views.CommentDeleteView.as_view(),
         name='delete_comment',
         ),
]
scarlet plaza
#

Yeah. That is the whole file. The point was, while keeping it inside rule 8, you should look there to find your problem.

hard pulsar
scarlet plaza
#

Maybe have a look at the error message again.

hard pulsar
#

i cannot change profile/edit/ to something else, thats the point

scarlet plaza
#

Everything you said above is that you can not change profile.html.

hard pulsar
#

yeah, i forgot about that, sorry 😦

#

edited the first post to be more clear

scarlet plaza
#

yeah that makes little sense.

#

I would make sure you have what your teacher said word for word.