url(r'^/(?P<username>[0-9a-zA-Z_-]+)/posts/$', UserPostList.as_view(), name='userpost-list'),
In Django tutorial https://docs.djangoproject.com/en/1.9/intro/tutorial03/#writing-more-views when we write more views, there is a %s simbol. What does it mean?
def detail(request, question_id):
return HttpResponse("You're looking at question %s." % question_id)
...
Obviously, this is a variable, that takes its respective question_id and puts to %s in a return. But wtf why %s exactly?
manage.py check
or manage.py runserver
IIRC. Maybe that's the problem? -- Otherwise please state what's the exact URL your trying to access (that produces 404). You could also set DEBUG=True
in your settings and inspect the debug output; it will tell you which patterns Django tried; maybe your urls.py
are not included.
%
sign is replaced by it. -- See here for documentation: https://docs.python.org/2/library/stdtypes.html#string-formatting
DEBUG=True
doesn't help you ("Is my urls.py
parsed?"), without full source code disclosed there's no-one that can help you with your issue. The regex seems right, and what you're trying to achieve is usually straight-forward with Django.
runserver
won't. Try adding a trailing slash to the URL.