from django.conf.urls.defaults import patterns, url
from nomadblog.views import PostList


urlpatterns = patterns('nomadblog.views',
    # List blog posts
    url('^$', PostList.as_view(), name='list_posts'),
    # Show single post, category + slug based URL
    url(
        regex=r'^(?P<category_slug>[-\w]+)/(?P<post_slug>[-\w]+)/$',
        view='show_post',
        name='show_post',
    ),
    # List categories
    url(
        regex=r'^categories/list/all/$',
        view='list_categories',
        name='list_categories',
    ),
    # List posts by category
    url(
        regex=r'^(?P<category>[-\w]+)/$',
        view='list_posts_by_category',
        name='list_posts_by_category',
    ),
)

from django.conf.urls import patterns, include, url
from nomadblog.views import PostList


urlpatterns = patterns(
    'nomadblog.views',
    url('^$', PostList.as_view(), name='list_posts'),
    url(regex=r'^(?P<category_slug>[-\w]+)/(?P<post_slug>[-\w]+)/$', view='show_post', name='show_post'),
    url(regex=r'^categories/list/all/$', view='list_categories', name='list_categories'),
    url(regex=r'^(?P<category>[-\w]+)/$', view='list_posts_by_category', name='list_posts_by_category'),
)

Fix ImportError: No module named defaults (dj 1.6)
Fix ImportError: No module named defaults (dj 1.6)

- from django.conf.urls.defaults import patterns, url
+ from django.conf.urls import patterns, include, url
  from nomadblog.views import PostList
  
  
- urlpatterns = patterns('nomadblog.views',
-     # List blog posts
+ urlpatterns = patterns(
+     'nomadblog.views',
      url('^$', PostList.as_view(), name='list_posts'),
+     url(regex=r'^(?P<category_slug>[-\w]+)/(?P<post_slug>[-\w]+)/$', view='show_post', name='show_post'),
+     url(regex=r'^categories/list/all/$', view='list_categories', name='list_categories'),
+     url(regex=r'^(?P<category>[-\w]+)/$', view='list_posts_by_category', name='list_posts_by_category'),
-     # Show single post, category + slug based URL
-     url(
-         regex=r'^(?P<category_slug>[-\w]+)/(?P<post_slug>[-\w]+)/$',
-         view='show_post',
-         name='show_post',
-     ),
-     # List categories
-     url(
-         regex=r'^categories/list/all/$',
-         view='list_categories',
-         name='list_categories',
-     ),
-     # List posts by category
-     url(
-         regex=r'^(?P<category>[-\w]+)/$',
-         view='list_posts_by_category',
-         name='list_posts_by_category',
-     ),
  )
  
Fix ImportError: No module named defaults (dj 1.6)
## Code Before:
from django.conf.urls.defaults import patterns, url
from nomadblog.views import PostList


urlpatterns = patterns('nomadblog.views',
    # List blog posts
    url('^$', PostList.as_view(), name='list_posts'),
    # Show single post, category + slug based URL
    url(
        regex=r'^(?P<category_slug>[-\w]+)/(?P<post_slug>[-\w]+)/$',
        view='show_post',
        name='show_post',
    ),
    # List categories
    url(
        regex=r'^categories/list/all/$',
        view='list_categories',
        name='list_categories',
    ),
    # List posts by category
    url(
        regex=r'^(?P<category>[-\w]+)/$',
        view='list_posts_by_category',
        name='list_posts_by_category',
    ),
)

## Instruction:
Fix ImportError: No module named defaults (dj 1.6)
## Code After:
from django.conf.urls import patterns, include, url
from nomadblog.views import PostList


urlpatterns = patterns(
    'nomadblog.views',
    url('^$', PostList.as_view(), name='list_posts'),
    url(regex=r'^(?P<category_slug>[-\w]+)/(?P<post_slug>[-\w]+)/$', view='show_post', name='show_post'),
    url(regex=r'^categories/list/all/$', view='list_categories', name='list_categories'),
    url(regex=r'^(?P<category>[-\w]+)/$', view='list_posts_by_category', name='list_posts_by_category'),
)
