Code below is from Django
's settings.py
. Since everything in Python
is an object, why don't just pass installed apps as tuple of objects:
INSTALLED_APPS = (
django.contrib.auth,
django.contrib.contenttypes,
.....
Is there some strong reason why they 开发者_如何学Godo this:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
.....
instead?
I'm new to Python
and Django
, so don't judge me too much, please.
Passing module or class name as a string is typical solution to avoiding circular import error.
For example, if settings file contains import myapp.models
and myapp.models contains from django.conf import settings
this would lead to circular import.
You'd have to import django
and so first to make it work, otherwise you'll have an error.
精彩评论