Hey there. I'm starting a term as web development editor at my student newspaper in the fall, and we recently (February) launched a new site created in Django. My background's definitely more in design than in development per se, so I'm trying to get up to speed with Django by putting together a blogging application for the site. Shouldn't be too hard--yay for generic views--but I'm having trouble with the URLconf at the moment.
The problem is that I need to be able to support multiple blogs (for example, one on student government, one on the local music scene, etc.), hence the Blog.slug field, which I'm hoping to be able to grab from the URL so I can figure out which entries I need to pass to the template. With that in mind, then, I've got the following URLconf (included in the root URLconf at /blog/): --- from django.conf.urls.defaults import * from maneater.blogging.models import Entry, Blog urlpatterns = patterns('django.views.generic.list_detail', (r'^$', 'object_list', {'queryset': Blog.objects.all(),}), ) urlpatterns += patterns('django.views.generic.date_based', (r'^(?P<blog_slug>[-\w]+)/$', 'archive_index', {'queryset': Entry.objects.filter(blog__slug__exact=blog_slug), 'date_field': 'date',}), (r'^(?P<blog_slug>[-\w]+)/(?P<year>\d{4})/$', 'archive_year', {'queryset': Entry.objects.filter(blog__slug__exact=blog_slug), 'date_field': 'date',}), (r'^(?P<blog_slug>[-\w]+)/(?P<year>\d{4})/(?P<month>\w{1,2})/$', 'archive_month', {'queryset': Entry.objects.filter(blog__slug__exact=blog_slug), 'date_field': 'date', 'month_format': '%m',}), (r'^(?P<blog_slug>[-\w]+)/(?P<year>\d{4})/(?P<month>\w{1,2})/(? P<day>\w{1,2})/$', 'archive_day', {'queryset': Entry.objects.filter(blog__slug__exact=blog_slug), 'date_field': 'date', 'month_format': '%m',}), (r'^(?P<blog_slug>[-\w]+)/(?P<year>\d{4})/(?P<month>\w{1,2})/(? P<day>\w{1,2})/(?P<slug>[-\w]+)/$', 'object_detail', {'queryset': Entry.objects.filter(blog__slug__exact=blog_slug), 'date_field': 'date', 'month_format': '%m',}), ) --- The object_list view works great, as long as it's the only pattern in the URLconf. As soon as I add all the date-based stuff, though, I get a fun little 500: --- Environment: Request Method: GET Request URL: http://127.0.0.1:8000/blog/ Django Version: 0.97-pre-SVN-unknown Python Version: 2.5.2 Installed Applications: ['django.contrib.admin', 'maneater.newspaper_content', 'maneater.newspaper_publishing', 'maneater.podcasting', 'maneater.newspaper_staff', 'maneater.website_management', 'maneater.blogging', 'django.contrib.flatpages', 'django.contrib.contenttypes', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.sitemaps'] Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.gzip.GZipMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.doc.XViewMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware') Traceback: File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response 76. callback, callback_args, callback_kwargs = resolver.resolve(request.path) File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py" in resolve 233. sub_match = pattern.resolve(new_path) File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py" in resolve 231. for pattern in self.urlconf_module.urlpatterns: File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py" in _get_urlconf_module 255. raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e) Exception Type: ImproperlyConfigured at /blog/ Exception Value: Error while importing URLconf 'maneater.blogging.urls': name 'blog_slug' is not defined --- So I know it doesn't like how I'm trying to filter by the blog slug in the URL (capturing the named group <blog_slug> and trying to pass {'queryset': Entry.objects.filter(blog__slug__exact=blog_slug)} to the view). I'm not really sure how I _should_ go about it, though. Any ideas? Thanks! -Justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---