Skip to content

Instantly share code, notes, and snippets.

@tricoder42
Last active March 28, 2019 11:55
Show Gist options
  • Save tricoder42/17129e07bc7d018d7c79 to your computer and use it in GitHub Desktop.
Save tricoder42/17129e07bc7d018d7c79 to your computer and use it in GitHub Desktop.
# BAD:
from production import *
# Good (my personal preference):
from myproject.settings.production import *
# Good (probably your choice):
from .production import *
# use immutable types for INSTALLED_APPS
PREREQ_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'debug_toolbar',
'imagekit',
'haystack',
)
PROJECT_APPS = (
'homepage',
'users',
'blog',
)
# sum of two tuples is allowed, resulting in *new* tuple
INSTALLED_APPS = PREREQ_APPS + PROJECT_APPS
# old method, when all views were functions. Still usable even with CBV (I use it)
urlpatterns = patterns('accounts.views',
url('^login/$', 'login') # view name is accounts.views.login
)
# calling patterns() isn't necessary in this case
from accounts.views import login
urlpatterns = patterns('',
url('^login/$', login)
)
# Simpler:
# Yes, urlpatterns *must* be a list
urlpatterns = [
url('^login/$', login)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment