I usually don't find myself writing too many redundant views, since the built-in admin site does so much of that automatically. Then I just build views specific to the site's public UI. I still find it curious that you would find yourself recreating said urls. I run a company database through the admin and three urls and three views. There should only have to be one url pattern defined per model, plus any extra views for looking at that one model. I don't mean to belittle what it is you're doing, but I can't say that I can identify very well. How many of your models have exactly the same set of views? My tendency is to think that those should be caught through some keyword captures.
There are, however, generic views (http://docs.djangoproject.com/en/ dev/ref/generic-views/) which might help. You might look at it and not think that it is as easy to use as you might like, but they are quite good for automatically handling dates in URLs, etc. I can't explain too much about generic views, as I haven't had to use them much. I'm totally not an authority on that end. If they don't really work out, you could always write a url which captures each of those three things as keyword arguments: urlpatterns = patterns('', (r'^(?P<app>[^/]+)/(?P<view>[^/]+)/(?P<id>\d+)/', 'magic_view_handler'), ) "magic_view_handler" would then be a view that gets called, whose signature looks something like: magic_view_handler(request, app, view, id): view_function = None try: view_function = import('%s.%s' % (app, view)) except ImportError: raise Http404 view_function(request, id) It'd then be up to your *real* view to check to ensure that the id is legit. I forget precise syntax on that import() function. I don't use it often. The idea is to import a dynamic module based on some string you've got handy. I think that the reason why this latter suggestion doesn't have a reason to exist is because you've always got to validate all sorts of stuff very specific to the model. By making one generic view, you're bound to never really allowing yourself any custom processing. You'd always be passing your variably-defined model to the same template. How could the same template render entirely different models to the page? Anyway, "sticky" the word for it, at best. I'm totally curious, so could I ask that you give an example of your url conf? If feels like there might be something missing that could simplify your task. Tim On Nov 25, 12:07 pm, Todd Blanchard <tblanch...@mac.com> wrote: > It is mostly a waste of time and busy work. > > I like the rails strategy of /controller/action/id > > I'd like to define a similar one time couple rules in urls.py > > Something like /application/view/id where view is the name of the function in > the views.py in that application. > > Anybody got a little snippet or recipe to do this generically once and for > all? > > -Todd Blanchard -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.