Hi guys,

So, I'm learning Django for the first time and having fun, I really
like it. Generally I'm finding it very practical and blessedly well-
documented, especially compared to other Python frameworks I have
explored. I'm using it for a personal project of mine that I wanted to
do in python (always my language of choice).

So anyway, one of the selling points of Django is supposed to be its
regex-mapped URLs. See:

http://docs.djangoproject.com/en/dev/topics/http/urls/

and especially the linked article:

http://www.w3.org/Provider/Style/URI

The argument referenced in the first part of this page (as I
understand it) is that a URL should be an unchanging locator for a
resource - if the underlying means by which the resource is supplied,
e.g., the app/view invoked, were to change, the URL should still point
to the same resource so that external bookmarks and links you have no
control over don't break when you change things behind the scenes. The
magic of regex mapping gives you a powerful tool to help make that
possible.

So OK, I used to be keen on the idea of URLs mapping to object
hierarchies or hierarchies of classes and methods cherrypy style, but
now I'm over that and I totally buy the above argument. A site's URL
scheme should be planned out and above all stable and dispatch should
be designed to facilitate that. I'm on the same page.

The thing is, though, everywhere else in the documentation it seems to
say that the preferred way to link to a view within your site is to
use reverse URL mapping with things like reverse(), or get_absolute_url
() defined on your models. It seems like the whole point of doing it
that way is to make it arbitrarily easy to change your site's URL
scheme while straightjacketing you into a particular structure of apps
and views behind the scenes (unless you want to be potentially
changing references to view functions in many places where they are
being reverse mapped to URLs). It seems like encouraging people to use
these reverse mappings is going exactly at cross-purposes to one of
the main purported advantages of Django's style of dispatch.

I think it's cool that you can reverse map URLs, but just to my newbie
eye it doesn't seem like a very good idea. If you plan out your URLs
carefully and keep them as stable as possibe, it seems to me it would
be easier to hard code URLs everywhere according to your scheme and
rely on clever regex mapping and view writing to keep those URLs
pointing to the right content. It helps to guarantee clarity and
stability of the public interface.

I'm hoping someone more experienced with Django will explain the
rationale for the preferred paradigm and show me where I have gone
astray above, because I'm at a critical juncture in my own project...
right now based on the above I'm planning to eschew all or almost all
reverse mapping and instead plan out my URLs and directly generate
URLs in all cases instead of mapping them from views and parameters à
la reverse(). If I didn't understand the logic correctly and I'm
making a mistake, I'd like to know.

Thanks,

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

Reply via email to