TypeError at /admin/ - django

Please help, my admin interface was working fine before but now when I check it,it gives me the :
TypeError at /admin/
Unhashable type: 'dict'
I don't know what I did to mess it up.
I have admin.autodiscover() in my urls, I have ran syncdb, and I have the contrib.admin in my INSTALLED APPS.
my url : url(r'^admin/', include(admin.site.urls)),
EDIT :
> Environment:
>
>
> Request Method: GET Request URL: http://127.0.0.1:8000/admin/
>
> Django Version: 1.4.5 Python Version: 2.7.3 Installed Applications:
> ('django.contrib.auth', 'django.contrib.contenttypes',
> 'django.contrib.sessions', 'django.contrib.sites',
> 'django.contrib.admin', 'django.contrib.comments',
> 'django.contrib.messages', 'django.contrib.staticfiles', 'haystack',
> 'bookmarks') Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware')
>
>
> Traceback: File
> "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
> in get_response
> 111. response = callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py"
> in wrapper
> 213. return self.admin_view(view, cacheable)(*args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
> _wrapped_view
> 91. response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py"
> in _wrapped_view_func
> 89. response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py"
> in inner
> 192. current_app=self.name): File
> "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
> in reverse
> 447. app_list = resolver.app_dict[ns] File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
> in app_dict
> 290. self._populate() File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
> in _populate
> 265. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args)) File
> "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
> in callback
> 216. self._callback = get_callable(self._callback_str) File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in
> wrapper
> 25. if mem_args in cache:
>
> Exception Type: TypeError at /admin/ Exception Value: unhashable type:
> 'dict'
EDIT:
urls.py:
import os.path
from django.conf.urls import patterns, url, include
from bookmarks.views import *
from bookmarks.feeds import LatestEntriesFeed
from django.views.static import *
from django.conf import settings
from django.views.generic.simple import direct_to_template
from django.contrib.comments.models import Comment
site_media = os.path.join(
os.path.dirname(__file__), 'site_media'
)
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Uncomment the admin/doc line below to enable admin documentation:
#url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Feeds
(r'^latest/feed/$', LatestEntriesFeed()),
#Admin interface
url(r'^admin/', include(admin.site.urls)),
# Comments
(r'^comments/', direct_to_template,
{'template':'comments/posted.html'}),
#social_auth
url(r'',include('social_auth.urls')),
#email invite friend
(r'^friend/invite/$',friend_invite),
(r'^friend/accept/(\w+)/$', friend_accept),
#Browsing
(r'^$', main_page),
(r'^popular/$', popular_page),
(r'^user/(\w+)/$', user_page),
(r'^tag/([^\s]+)/$', tag_page),
(r'^bookmark/(\d+)/$', bookmark_page),
#Session management
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^logout/$', logout_page),
(r'^media/ (?P<path>.*)', #'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
(r'^register/$', register_page),
(r'^register/success/$', direct_to_template,
{ 'template': 'registration/register_success.html' }),
#Account management
(r'^save/$', bookmark_save_page),
(r'^tag/$', tag_cloud_page),
(r'^search/$', search_page),
(r'^vote/$', bookmark_vote_page),
#insights
(r'^insights/$', insights_page),
#media for static files
#(r'^media/(/P<path>.*)$','django.views.static.serve',{'document_root':settings.MEDIA_ROOT}),
# Ajax
(r'^ajax/tag/autocomplete/$', ajax_tag_autocomplete),
#static url
(r'^static/(?P<path>.*)$','django.views.static.serve', {'document_root': 'Home/django_bookmarks/static'})
#(r'^django_bookmarks/', include('django_bookmarks.foo.urls')),
)

I'm on Django 1.11, but I got a similar error unhashable type: 'list' by trying to give models.CharField() a choices argument like this:
[(['FIT_FOR_USE', 'NOT_CHECKED', 'TO_BE_CHECKED', 'BLACKLISTED'],
"['Fit For Use', 'Not Checked', 'To Be Checked', 'Blacklisted']")]
So my guess is you've done something like this:
models.CharField(...., choices=[({}, 'aaa')])

Related

"Posts matching query does not exist." error while navigating to "admin page" in django?

I am learning Django and working on making a simple blog website. Now the whole project is working fine but whenever I navigate to the admin panel it shows the error "Posts matching query does not exist.".
Let me know which part of the code you want to see(i'm confused which file has the error)
error :
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/admin
Django Version: 2.0.5
Python Version: 3.6.5
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'posts']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "C:\Users\Fruity_Dude\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\core\handlers\exception.py" in inner
35. response = get_response(request)
File "C:\Users\Fruity_Dude\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\core\handlers\base.py" in _get_response
128. response = self.process_exception_by_middleware(e,
request)
File "C:\Users\Fruity_Dude\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\core\handlers\base.py" in _get_response
126. response = wrapped_callback(request, *callback_args,
**callback_kwargs)
File "C:\Users\Fruity_Dude\Projects\Django\devflow\posts\views.py" in
post_details
10. posts = Posts.objects.get(slug=slug)
File "C:\Users\Fruity_Dude\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\db\models\manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args,
**kwargs)
File "C:\Users\Fruity_Dude\AppData\Local\Programs\Python\Python36\lib\site-
packages\django\db\models\query.py" in get
403. self.model._meta.object_name
Exception Type: DoesNotExist at /admin
Exception Value: Posts matching query does not exist.
urls.py:
from django.urls import path
from . import views
app_name = 'posts'
urlpatterns = [
path('', views.posts, name='home'),
path('<slug:slug>', views.post_details, name='detail'),
]
views.py:
from django.shortcuts import render
from .models import Posts
from django.http import HttpResponse
def posts(request):
posts = Posts.objects.all().order_by('date')
return render(request, 'posts/posts.html', {'posts': posts})
def post_details(request, slug):
posts = Posts.objects.get(slug=slug)
return render(request, 'posts/post_details.html', {'posts': posts})
main urls.py:
from django.contrib import admin
from django.urls import path,include
from . import views
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = [
path('admin/', admin.site.urls), #for admin
path('', include('posts.urls')),
path('about/', views.about, name='about'), #for about
path('contact/', views.contact, name='contact'), #for contact
path('support/', views.support, name='support'), #for support
path('donate/', views.donate, name='donate') #for donate
]
urlpatterns += staticfiles_urlpatterns()
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
The problem seem to be that you are running
posts = Posts.objects.get(slug=slug)
and your url catches
path('<slug:slug>', views.post_details, name='detail')
For instance when you do http://domain:port/a-post/ what will be matched in argument slug is 'a-post/' (notice the trailing /)
You wrote in a comment that
url(r'^(?P<slug>[\w-]+)/$', views.post_details, name='detail')
fixed the issue. That is probably because the trailing / is now not included in the resulting slug variable.
The error is raised by Posts.objects.get(slug=slug) since the .get-method requires one and only one row to be matched. (see django docs)
To avoid that problem, I see two solutions you should implement.
Change the match to path('<slug:slug>/', views.post_details, name='detail'), i.e. added a /.
Use the filter-method.
For example:
posts = Posts.objects.filter(slug=slug).all() # all() to make django perform the sql select command and return list
if not posts:
# handle error case, either return 404 or redirect somewhere.
elif len(posts) > 1:
# handle the weird case when there was more than one matching post
post = posts[0]
# render using post instead of posts, since it is only one post

How to properly include + register viewset routers with Django 2.0 DRF 3.8

I'm developing a basic Django DRF API. I have been using class-based views with explicit URLs. Now I'm trying to use very vanilla DRF ViewSets + router (for auto URL generation).
Can anybody help point me in the right direction? I'm on DRF 3.8 and Django 2.0
Project urls.py:
from django.conf.urls import url, include
urlpatterns = [
url(r'^userprofile/', include('UserProfile.urls', namespace='UserProfile')),
]
App: UserProfile/urls.py:
from django.conf.urls import include
from django.urls import path
from rest_framework.routers import DefaultRouter
from UserProfile import views
app_name = 'UserProfile'
router = DefaultRouter()
router.register('humans', views.HumanViewSet,)
urlpatterns = [path('', include(router.urls))]
App: UserProfile/views.py
from rest_framework import viewsets
from UserProfile.models import Human
from UserProfile.serializers import HumanSerializer
class HumanViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = HumanSerializer
queryset = Human.objects.all()
I get an error:
__init__() missing 2 required positional arguments: 'app_name' and 'app_module'
Full traceback:
Including full traceback:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/userprofile/humans/
Django Version: 2.0.4
Python Version: 3.6.4
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_simplejwt',
'django_extensions',
'django_pdb',
'django_use_email_as_username.apps.DjangoUseEmailAsUsernameConfig',
'custom_user.apps.CustomUserConfig',
'factory',
'UserProfile']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/rest_framework/viewsets.py" in view
103. return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
466. request = self.initialize_request(request, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/rest_framework/viewsets.py" in initialize_request
125. request = super(ViewSetMixin, self).initialize_request(request, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py" in initialize_request
368. authenticators=self.get_authenticators(),
File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py" in get_authenticators
262. return [auth() for auth in self.authentication_classes]
File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py" in <listcomp>
262. return [auth() for auth in self.authentication_classes]
Exception Type: TypeError at /userprofile/humans/
Exception Value: __init__() missing 2 required positional arguments: 'app_name' and 'app_module'

Django shortcuts.redirect NoReverseMatch

I'm getting NoReverseMatch from the below view:
from django.shortcuts import render, redirect
def new_room(request):
label="test"
return redirect(chat_room, label=label)
# this didn't work either:
# return redirect('chat_room', label=label)
def chat_room(request, label):
...
My urls.py looks like this:
from django.conf.urls import url, include
from messaging import views
app_name="messaging"
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^new/$', views.new_room, name='new_room'),
url(r'^(?P<label>[\w-]{,50})/', views.chat_room, name='chat_room'),
]
Going straight to messaging/test/ will load the page correctly. It's only the redirect that is causing the issue.
Full stacktrace:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/messages/new/
Django Version: 1.10.5
Python Version: 3.5.2
Installed Applications:
['messaging',
'dal',
'dal_select2',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',,
'channels']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "g:\Python\lib\site-packages\django\core\handlers\exception.py" in inner
39. response = get_response(request)
File "g:\Python\lib\site-packages\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "g:\Python\lib\site-packages\channels\handler.py" in process_exception_by_middleware
240. return super(AsgiHandler, self).process_exception_by_middleware(exception, request)
File "g:\Python\lib\site-packages\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "g:\Git\Jam\messaging\views.py" in new_room
26. return redirect('chat_room', label=label)
File "g:\Python\lib\site-packages\django\shortcuts.py" in redirect
56. return redirect_class(resolve_url(to, *args, **kwargs))
File "g:\Python\lib\site-packages\django\shortcuts.py" in resolve_url
147. return reverse(to, args=args, kwargs=kwargs)
File "g:\Python\lib\site-packages\django\urls\base.py" in reverse
91. return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
File "g:\Python\lib\site-packages\django\urls\resolvers.py" in _reverse_with_prefix
392. (lookup_view_s, args, kwargs, len(patterns), patterns)
Exception Type: NoReverseMatch at /messages/new/
Exception Value: Reverse for 'chat_room' with arguments '()' and keyword arguments '{'label': 'test'}' not found. 0 pattern(s) tried: []
That's because you're using namespacing for your chat_room app.
Change to:
return redirect('messaging:chat_room', label=label)
Check here for namespacing and also here too.

Custom password_reset_form returning: unhashable type: 'dict'

I am trying to override the form for password_reset_form but it keep resulting in following error:
unhashable type: 'dict'
I interpret this error as password_reset_form does not exist for some reason?
My urls.py:
from rest_framework.routers import DefaultRouter
from django.conf.urls import patterns, url, include
from web import views
from web.forms import MyLoginForm, MyPasswordResetForm
urlpatterns = patterns('',
#url(r'^', views.IndexView.as_view(), name='index'),
url(r'^accounts/login/$', 'django.contrib.auth.views.login', {'authentication_form': MyLoginForm}),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', name='logout'),
url(r'^accounts/password/reset/$',
'django.contrib.auth.views.password_reset',
{'password_reset_form': MyPasswordResetForm},
{'post_reset_redirect' : '/user/password/reset/done/'}),
(r'^accounts/password/reset/done/$',
'django.contrib.auth.views.password_reset_done'),
(r'^accounts/password/reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
'django.contrib.auth.views.password_reset_confirm',
{'post_reset_redirect' : '/user/password/done/'}),
(r'^accounts/password/done/$',
'django.contrib.auth.views.password_reset_complete'),
)
My forms.py:
from django import forms
from django.forms import ModelForm
from django.contrib.auth.models import User
from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm
class MyLoginForm(AuthenticationForm):
username = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control','placeholder':'Brugernavn'}))
password = forms.CharField(widget=forms.PasswordInput(attrs={'class':'form-control','placeholder':'Password'}))
class MyPasswordResetForm(PasswordResetForm):
username = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control','placeholder':'Brugernavn'}))
Full stacktrace:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/password/reset/
Django Version: 1.6.1
Python Version: 2.7.5
Installed Applications:
('django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'web',
'api',
'django.contrib.admin',
'rest_framework.authtoken',
'corsheaders',
'django.contrib.auth')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware')
Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/contrib/auth/views.py" in password_reset
142. post_reset_redirect = reverse('password_reset_done')
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in reverse
509. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
387. possibilities = self.reverse_dict.getlist(lookup_view)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in reverse_dict
296. self._populate()
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in _populate
273. for name in pattern.reverse_dict:
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in reverse_dict
296. self._populate()
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in _populate
287. lookups.appendlist(pattern.name, (bits, p_pattern, pattern.default_args))
File "/Library/Python/2.7/site-packages/django/utils/datastructures.py" in appendlist
383. self.setlistdefault(key).append(value)
File "/Library/Python/2.7/site-packages/django/utils/datastructures.py" in setlistdefault
373. if key not in self:
Exception Type: TypeError at /accounts/password/reset/
Exception Value: unhashable type: 'dict'
Your arguments for url isn't right. Should be one dictionary
url(r'^accounts/password/reset/$',
'django.contrib.auth.views.password_reset',
{'password_reset_form': MyPasswordResetForm,
'post_reset_redirect': '/user/password/reset/done/'}),

Django: error at / bad character in group name

I was following Apress - Practical Django Project by James Bennet and I got this nasty error out of the blue. Could you help me?
Here it goes:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.2.5
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.flatpages',
'cms.search',
'coltrane',
'tagging']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
91. request.path_info)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
215. for pattern in self.url_patterns:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_url_patterns
244. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_urlconf_module
239. self._urlconf_module = import_module(self.urlconf_name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/utils/importlib.py" in import_module
35. __import__(name)
File "/Users/danielcorreia/Sites/test_Django/cms/../cms/urls.py" in <module>
21. (r'', include('django.contrib.flatpages.urls')),
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/conf/urls/defaults.py" in patterns
24. t = url(prefix=prefix, *t)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/conf/urls/defaults.py" in url
41. return RegexURLPattern(regex, view, kwargs, name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in __init__
89. self.regex = re.compile(regex, re.UNICODE)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py" in compile
188. return _compile(pattern, flags)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py" in _compile
241. raise error, v # invalid expression
Exception Type: error at /
Exception Value: bad character in group name
Oh! I'm a newbie to Django. Please be gentle :)
Here's the urls.py:
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^cms/', include('cms.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
(r'tiny_mce/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': '/Users/danielcorreia/Sites/tinymce/jscripts/tiny_mce' }),
(r'^search/$', 'cms.search.views.search'),
(r'^weblog/$', 'coltrane.views.entries_index'),
(r'^weblog/(?P<year\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$', 'coltrane.views.entry_detail'),
(r'', include('django.contrib.flatpages.urls')),
)
(r'^weblog/(?P<year\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$', 'coltrane.views.entry_detail'),
Change to:
(r'^weblog/(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$', 'coltrane.views.entry_detail'),
Note the closing angle bracket for the year group.