Last active
March 28, 2019 11:55
-
-
Save tricoder42/17129e07bc7d018d7c79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BAD: | |
from production import * | |
# Good (my personal preference): | |
from myproject.settings.production import * | |
# Good (probably your choice): | |
from .production import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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