Thursday, March 24, 2011

Repetition in urls.py

Hi,

I am using django 1.3 and have the following in my urls.py for a
blogging application:

urlpatterns = patterns('',
url(r'$',
ArchiveIndexView.as_view(model=Entry,date_field='created',paginate_by=10),
name='blog_archive_index'),
url(r'today/$',
TodayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),
name='blog_archive_today'),
url(r'(?P<year>\d{4})/$',
YearArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_year'),
url(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/$',
MonthArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_month'),
url(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{2})/$',
DayArchiveView.as_view(model=Entry,date_field='created',paginate_by=10),name='blog_archive_day'),
url(r'(?P<year>\d{4})/(?P<month>[a-z]{3})/(?P<day>\d{2})/(?
P<slug>[\w\-]+)/$',
DateDetailView.as_view(model=Entry,date_field='created'),name='blog_entry_detail'),
)

I was just wondering if there was a simple way to condense this as
with django 1.2 I could add all this in to a dictionary like:

info_dict = {'model': Entry, 'date_field': 'created', 'paginate_by':
10}

Ryan

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate