| | 291 | Multiple view prefixes |
|---|
| | 292 | ---------------------- |
|---|
| | 293 | |
|---|
| | 294 | In practice, you'll probably end up mixing and matching views to the point |
|---|
| | 295 | where the views in your ``urlpatterns`` won't have a common prefix. However, |
|---|
| | 296 | you can still take advantage of the view prefix shortcut to remove duplication. |
|---|
| | 297 | Just add multiple ``patterns()`` objects together, like this: |
|---|
| | 298 | |
|---|
| | 299 | Old:: |
|---|
| | 300 | |
|---|
| | 301 | from django.conf.urls.defaults import * |
|---|
| | 302 | |
|---|
| | 303 | urlpatterns = patterns( '' |
|---|
| | 304 | (r'^/?$', 'django.views.generic.date_based.archive_index'), |
|---|
| | 305 | (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'django.views.generic.date_based.archive_month'), |
|---|
| | 306 | (r'^tag/(?P<tag>\w+)/$', 'weblog.views.tag'), |
|---|
| | 307 | ) |
|---|
| | 308 | |
|---|
| | 309 | New:: |
|---|
| | 310 | |
|---|
| | 311 | from django.conf.urls.defaults import * |
|---|
| | 312 | |
|---|
| | 313 | urlpatterns = patterns('django.views.generic.date_based' |
|---|
| | 314 | (r'^/?$', 'archive_index'), |
|---|
| | 315 | (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$','archive_month'), |
|---|
| | 316 | ) |
|---|
| | 317 | |
|---|
| | 318 | urlpatterns += patterns('weblog.views', |
|---|
| | 319 | (r'^tag/(?P<tag>\w+)/$', 'tag'), |
|---|
| | 320 | ) |
|---|
| | 321 | |
|---|