0

Given a simple model:

class Blog(models.Model):
    blogname = = models.CharField(max_length=200,primary_key=True)

class BlogEntry(models.Model):
    blogname = models.ForeignKey('Blog')
    # more blog related fields 
    ...

and say the following blogs linux, python and other how would you handle the URLs to the respective blog pages pages. Currently I have set up a view to list all the blogs for the model Blog as the root page:

url(r'^$', 'blog.views.index')

The question is how to map the blog linux to /linux the way I am handling this currently is:

url(r'(?P<blog_name>.*)/','blog.views.blog_page')

but of course that means /.* is a valid URL and I only want /linux,/python and /other.

4

1 回答 1

4

blog_name用 a拒绝其他值Http404

于 2013-06-10T19:50:45.653 回答