#15294: Use named urls instead of hard coded ones in admin views
---------------------------------------+-------------------------------
               Reporter:  julien       |          Owner:  ramiro
                   Type:  New feature  |         Status:  new
              Milestone:               |      Component:  contrib.admin
                Version:  1.2          |       Severity:  Normal
             Resolution:               |       Keywords:
           Triage Stage:  Accepted     |      Has patch:  0
    Needs documentation:  0            |    Needs tests:  0
Patch needs improvement:  0            |  Easy pickings:  0
---------------------------------------+-------------------------------

Comment (by julien):

 To clarify my comment above about #5925: it was specifically about the
 `post_url_continue` parameter in the `response_add` method's signature:

 {{{
 #!python
 def response_add(self, request, obj, post_url_continue='../%s/'):
     ...
 }}}

 Ideally `post_url_continue` should take the reversed URL for the change
 view instead of the hardcoded `'../%s/'`. Initially I thought that the
 `reverse_lazy()` introduced by #5925 may help, but the problem is that
 there's no way of finding out the new object's pk or even it's app label
 or model name from the method's signature. Maybe an approach would be to
 allow passing a callable as `post_url_continue`, for example:

 {{{
 #!python

 def post_url_continue(request, modeladmin, obj):
     opts = obj._meta
     return reverse('admin:%s_%s_changelist' %
                                    (opts.app_label, opts.module_name),
                                    current_app=modeladmin.admin_site.name)

 class ModelAdmin(BaseModelAdmin):

     ...

     def response_add(self, request, obj,
 post_url_continue=post_url_continue):
         ...
         if callable(post_url_continue):
             post_url_continue = post_url_continue(request, self, obj)
         ...
 }}}

 Such an approach could be generalised for the other redirection urls
 suggested in #8001.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15294#comment:6>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to