Kyle Fox wrote:
> I've been having a hard time figuring out how to solve this problem:
>
> We're building *another* django blogging app, but we want the app to
> support multiple blogs on the same site, ideally by having each Blog
> "mounted" on it's own URL, ie: "/politics/" is a Blog, "/tumbles/" is
> another Blog, etc.
>
> To accomplish this, I have a `Blog` model which looks roughly
> something like this:
>
> class Blog(models.Model):
> site = models.ForeignKey(Site)
> title = models.CharField(max_length=500)
> url = models.SlugField('URL', prepopulate_from=("title",),
> blank=True)
>
> urls.py then contains lines like this:
> (r'^(?P<blog_url>[-\w]+)/categories/',
> include('glyph.apps.categories.urls')),
>
>
url(r'^(?P<level1>[^/]*)/(?P<level2>[^/]*)/$',
'django_framework.views.callview', name='level2' ),
url(r'^(?P<level1>[^/]*)/$', 'django_framework.views.callview',
name='level1' ),
url(r'^$', 'django_framework.http_frontend.views.callview',
name='level0' ),
and from there on you take on in the callview, the arguments level1,
level2 (not names!) will be None
when not matched so you have the whole hierachy in the callview method.
And you don't have to
extend the urls.py when you get new blogs up.
the name='' you will need when you have to reverse translate to URL
(since the standard methods
that Django provides will not be applicable for sure ;-)
--- tony
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---