Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#88 closed defect (fixed)

Configuration should be more forgiving to users who forget the trailing comma.

Reported by: mmarshall Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: trivial Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


It is really easy for users to forget the trailing comma in configuration settings that should be a tuple, resulting in weird errors. In order to help keep (new) users from getting frustrated, a string should be converted into a tuple for these settings.

Here is a patch to implement this:

Index: django/conf/
--- django/conf/     (revision 211)
+++ django/conf/     (working copy)
@@ -29,9 +29,16 @@
 except ImportError, e:
     raise EnvironmentError, "Could not import DJANGO_SETTINGS_MODULE '%s' (is it on sys.path?): %s" % (me.SETTINGS_MODULE, e)

+# a list of settings that should be converted into tuples if they are strings:
+tuple_settings = ["INSTALLED_APPS","TEMPLATE_DIRS"]
 for setting in dir(mod):
     if setting == setting.upper():
-        setattr(me, setting, getattr(mod, setting))
+        setting_value = getattr(mod, setting)
+        if setting in tuple_settings and type(setting_value) == str:
+            setting_value = (setting_value,) #In case the user forgot the comma.
+        setattr(me, setting, setting_value)

 # save DJANGO_SETTINGS_MODULE in case anyone in the future cares

Note that I only put two entries in the tuple_settings list, as they are the only ones I know of. If there are more, they should be added.

Change History (2)

comment:1 Changed 15 years ago by anonymous

Summary: jjjjConfiguration should be more forgiving to users who forget the trailing comma.Configuration should be more forgiving to users who forget the trailing comma.

comment:2 Changed 15 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

Fixed in [213].

Note: See TracTickets for help on using tickets.
Back to Top