https://www.djangoproject.com/

URL configure get 404

First, the URL file will be loaded by setting in project_dir/project/settings.py

1
ROOT_URLCONF = 'project.urls'

Assumed that you already have an app named myapp

Include the URL config file from your app

Edit project_dir/project/urls.py

1
2
3
4
5
6
7
8
9
10
...
urlpatterns = patterns('',
...
# This is to include the urls.py from myapp
# if you add a trailing slash, will get 404 error
# i.e. (r'^$/', include('myapp.urls')),
(r'^$', include('myapp.urls')),
...
)
...
Reference:

1
request.COOKIES.get('key', 'default')
Reference:

Model date comparison

1
2
3
4
5
6
7
from datetime import date

user = User.objects.get(id=1)
if user.accessed_date == date.today():
# do something
else:
# do other thing