UpdateView Redirect

30 views
Skip to first unread message

dtdave

unread,
Aug 31, 2020, 11:43:21 AM8/31/20
to Django users
I have got myself into somewhat of a pickle.

Currently I have the following url structure:
path('<uuid:pk>/', views.PublisherDetailView.as_view(), name='publisher_detail'),
path('<uuid:pk>/update/', views.PublisherUpdateView.as_view(), name='publisher_update'),

In my views the following:
class PublisherUpdateView(UpdateView):
    model = Publisher
    template_name = "catalog/publisher_update.html"
    fields = (
        "name",
        "address",
        "city",
        "state_province",
        "country",
        "website",
    )

    def get_success_url(self):
        return reverse_lazy("catalog:publisher_detail", kwargs={'pk': self.object.id})
And the link in my template is:
<a href="{% url 'catalog:publisher_update' publisher.id %}" class="btn btn-sm btn-info">Update</a>
Everything works fine at this point.
However my url structure now need to become:
path('<slug:slug>/<uuid:pk>/', views.PublisherDetailView.as_view(), name='publisher_detail'),
path(<slug:slug>/'<uuid:pk>/update/', views.PublisherUpdateView.as_view(), name='publisher_update'),

My question is how do I account for this in my views?
Any help would be appreciated

 
Reply all
Reply to author
Forward
0 new messages