On Sep 16, 4:14 pm, matehat <mathieu.damo...@gmail.com> wrote: > Oh, and trying to make the url resolving mechanism look in the > database is really a bad idea because it would trigger a bunch of > database queries every time a request is processed by your > application, which would really slow things down.
What do you mean? With get_absolute_url I get to magically resolve the url without looking into db? Regex just don't give me enough flexibility -- I need to make url changes in admin (indirectly through renaming and moving categories) and later have to look it up in db. No way around this. Or is it? Well, maybe I can see one: automatically generate urls.py in admin category post-save. But I don't like this at all. > > mathieu > > On 16 sep, 10:11, matehat <mathieu.damo...@gmail.com> wrote: > > > Hi, > > > If the url only depends on the object's id (which I suppose don't > > change with time), you should not have it put in the database at > > first, because the object's id alone takes care of its persistence. > > Then, plugging it into Django's url resolving mechanism becomes really > > easy with the well-documented "get_absolute_url()" model method and > > the "permalink" decorator, for instance. > > > Also, if you want better advices on how to fit your database model > > into django's url resolving mechanism, you should post a question > > (together with more details) onto the django-users group. > > > Mathieu > > > On 16 sep, 07:07, twold <marek.ber...@gmail.com> wrote: > > > > Hello, > > > I am having little difficulties with django url system and I hope > > > someone can clear it up. Here's what I want to achieve: we're going to > > > have a tree-based catalog in our app and we'd like to index it like > > > this: name1/name2/name3/... I've created a database lookup table url <-> > > > id with urls being automatically generated at catalog save time. Now > > > > I would like to plug this in django url resolving process (first I put > > > in view to which I passed whole path, but that is simply wrong for a > > > couple of reasons). Also, I don't want to completely replace > > > RegexURLResolver, because other parts of our site will be using it. So > > > what I'd like would probably be some refactoring of the resolvers. For > > > the time being I subclassed RegexURLPattern and implemented custom > > > resolve method -- it is hacky, but works straight away when I put my > > > subclass in url_patterns. The problem is, there seems to be no easy > > > way, to make reverse work. I was thinking about all of it a lot, also > > > googling a lot and I found no answers. So I wonder: what's the best > > > way to make database URL resolving play nicely with the default regex > > > resolving? Is there any way at all? > > > > With regards, > > > Marek Bernat --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---