DjangoDjango

How to get edit url for model instance

Sep 28, 2013 · Updated: Nov 04, 2017 · by Tim Kamanin

Use this:

python
urlresolvers.reverse("admin:%s_%s_change" % (self.model._meta.app_label, self.model._meta.module_name), args=(object_id,))

to redirect to object edit page after performing some action, use this
snippet:

python
return redirect(urlresolvers.reverse("admin:%s_%s_change" % (self.model._meta.app_label, self.model._meta.module_name), args=(object_id,)))

Hey, if you've found this useful, please share the post to help other folks find it:

There's even more:

Subscribe for updates

  • via Twitter: @timonweb
  • old school RSS:
  • or evergreen email ↓ ↓ ↓