On 4/4/06, Max Battcher <[EMAIL PROTECTED]> wrote: > > limodou wrote: > > No, urlconf just one place, we also have view and template need to > > deal with. > > Last I checked, none of my views have URLs, other than redirects to > relative paths like '../' or 'thanks/' or redirects to major pages like > '/' and '/member/login/'. As for my templates, certainly my > site-specific templates have URLs for navigation, but all of my > app-specific templates get along just fine with relative paths and > model_object.get_absolute_url. > > Maybe if you just focused on clean code you wouldn't have to worry about > baroque complexes of settings? >
My solution is not a new idea. You can see: http://groups.google.com/group/django-users/browse_thread/thread/a13202328b3925a8/8351c3996f76f458#8351c3996f76f458 And there are many people except me consider that: django need a good urls system: Jacob Kaplan-Moss ----------------------------------- As far as I'm concerned, the problem has always been one of syntax and simplicity. Obviously the model is the wrong place to put a URL for all the reasons discussed, but you can't beat it for simplicity. I've tried a few times to come up with a solution that's both "correct" and just as simple, and each time I've failed. As far as I'm concerned, if someone can come up with a way to do this that's stupidly simple then I'm all for a change, but at the same time get_absolute_url() is a wart I'm willing to live with. Adrian Holovaty ------------------------------ Yeah, precisely. Elegant solutions are quite welcome! Adrian And in my project woodlog, I have many apps just like blog, rss, comment, tags, profile, etc. And each of them has a app prefix to distinguish each other, so the top level urls.py is just like: urlpatterns = patterns('', (r'^$', 'apps.digest.views.index'), (r'^blog/$', 'apps.frontpage.views.index'), (r'^help/$', 'django.views.generic.simple.direct_to_template',{'template':'home/help'}), ('^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'}), ('^login/$', 'public.apps.account.views.main.login'), ('^register/$', 'public.apps.account.views.main.register'), (r'^setting/', include('apps.profile.urls')), (r'^RPC/?$', 'apps.woodlog.rpc.call'), (r'^medias/(?P<path>.*)$', 'django.views.static.serve', media_dict), (r'^admin/', include('django.contrib.admin.urls')), (r'^test/', include('public.apps.test.urls')), (r'^comment/', include('public.apps.comment.urls')), (r'^blog/(?P<user_name>.*?)/', include('apps.woodlog.urls')), (r'^rss/', include('apps.rss.urls')), (r'^search/', 'apps.search.views.search'), (r'^blogers/$', 'apps.frontpage.views.bloglist'), (r'^tags/$', 'apps.frontpage.views.tags'), (r'^tags/(?P<name>.*?)/$', 'apps.frontpage.views.taglist'), (r'^digest/', include('apps.digest.urls')), ) And I can use rss, tags, profile, comment in blog app, and also I can use profile, rss in digest app. So apps can reference each other. And how to use them in url? For example, in blog app, if I want to use rss, I need: /rss/something so if the rss url prefix is changed, so we need change all files which use '/rss' string. And if the /rss/something is defined /$rss/something, so even though the rss app urlprefix is changed, we still don't need to change the files which use '/$rss' string. Why the app prefix would change, I think there are many reasons, for example: 1. reuse some app, and these apps maybe conflict with existed ones. 2. want to redefine the url, and make them more clean 3. also can used for media prefix Some static media files need to store in a folder, and configure the url prefix in someplace, so when we define a url of a css or image, we can define it as: <a href="/medias/a.gif">aaaa</a> So if the template use fixed '/medias' prefix, and if the medias must be changed, we should do many replacement work. And if we define above code as: <a href='/$medias/a.gif'>aaaa</a> we just need to change the remap rule, and no need to change the template file at all. And if we copy template or other things just like view, etc, the modification will be the least, and I think it's flexible enough. -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---
