Additional example for reverse_lazy documentation

880 views
Skip to first unread message

Alasdair Nicol

unread,
Jun 29, 2011, 5:49:51 PM6/29/11
to django-d...@googlegroups.com
Hi,

I like the upcoming reverse_lazy in Django 1.4 (commit 16121). I suggest the examples should include using reverse_lazy in urlpatterns.

I just helped a user out in stackoverflow [1] who was struggling with NoReverseMatch errors because their url patterns used reverse for optional arguments. I think adding an example might stop users from struggling with the same problem in future.

My suggested one line addition to the examples in [2] is

 * providing a reversed url in a URL pattern as an extra argument to the view function.

On the other hand, I realise that the documentation is stating "some common cases", it doesn't have to be exhaustive.

I'd like to make a ticket and patch if people think this is a good idea.

Regards,
Alasdair Nicol

[1]: http://stackoverflow.com/questions/6512610/django-url-error-in-template-with-password-change-view/6514169
[2]: https://docs.djangoproject.com/en/dev/topics/http/urls/#passing-extra-options-to-view-functions
-- 
Alasdair Nicol
Developer, MEMSET

mail: alas...@memset.com
 web: http://www.memset.com/

Memset Ltd., registration number 4504980. 25 Frederick Sanger Road, Guildford, Surrey, GU2 7YD, UK.

Julien Phalip

unread,
Jun 29, 2011, 11:49:40 PM6/29/11
to Django developers
Hi Alasdair,

On Jun 30, 7:49 am, Alasdair Nicol <alasd...@memset.com> wrote:
> Hi,
>
> I like the upcoming reverse_lazy in Django 1.4 (commit 16121). I suggest
> the examples should include using reverse_lazy in urlpatterns.
>
> I just helped a user out in stackoverflow [1] who was struggling with
> NoReverseMatch errors because their url patterns used reverse for
> optional arguments. I think adding an example might stop users from
> struggling with the same problem in future.
>
> My suggested one line addition to the examples in [2] is
>
>   * providing a reversed url in a URL pattern as an extra argument to
> the view function.
>
> On the other hand, I realise that the documentation is stating "some
> common cases", it doesn't have to be exhaustive.
>
> I'd like to make a ticket and patch if people think this is a good idea.
>
> Regards,
> Alasdair Nicol
>
> [1]:http://stackoverflow.com/questions/6512610/django-url-error-in-templa...
> [2]:https://docs.djangoproject.com/en/dev/topics/http/urls/#passing-extra...

This is a good suggestion. Feel free to open a ticket. In fact, the
doc about reverse_lazy could be further improved by providing some
concrete code samples -- so if your patch contains some, all the
better ;-)

Julien
Reply all
Reply to author
Forward
0 new messages