Monday, August 31, 2020

UpdateView Redirect

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

 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5f43d577-a26f-456e-a7b2-7fddabc166ccn%40googlegroups.com.

No comments:

Post a Comment