DjangoDjango

How to get edit url for model instance

Sep 28, 2013 · Updated: Jul 05, 2021 · by Tim Kamanin

Use this:

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:

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 ↓ ↓ ↓