Danny is spot on on all accounts. To elaborate, Mezzanine needs a default value so that it can infer the type of the variable for the setting (a string, integer, etc), which it then uses to work out what type of form field to provide in the editable settings interface in the admin.
On Fri, Jul 11, 2014 at 7:27 AM, Danny <[email protected]> wrote: > > On 10/07/2014 10:07 PM, Fredrik Blomqvist wrote: > >> I'm trying to register a couple of settings, but as soon as I try to set >> one of them (in the admin interface) I get a "NoneType takes no >> arguments" error, until I restart the server (the settings are all empty >> after that, aka nothing gets saved). >> > > I'm assuming these are in your defaults.py? > > Add default="" to the new settings, that might be the only trick required. > > BTW, your TEMPLATE_ACCESSIBLE_SETTINGS call probably doesn't need > description or editable, as you've got the append=True so it'll > take those properties from the one defined before. > > I've pasted some of my code below yours quoted below. > > HTH. HAND. > > Seeya. Danny. > > > >> Here's the code: >> >> from django.utils.translation import ugettext_lazy as _ >> from mezzanine.conf import register_setting >> >> >> register_setting( >> name="TEMPLATE_ACCESSIBLE_SETTINGS", >> description=_("Sequence of setting names available within >> templates."), >> editable=False, >> default=("SOCIAL_LINK_FACEBOOK", "SOCIAL_LINK_INSTAGRAM"), >> append=True, >> ) >> register_setting( >> name="SOCIAL_LINK_FACEBOOK", >> label=_("Facebook link"), >> description=_("If present a Facebook icon linking here will be >> in the header."), >> editable=True, >> ) >> register_setting( >> name="SOCIAL_LINK_INSTAGRAM", >> label=_("Instagram link"), >> description=_("If present a Instagram icon linking here will be >> in the header."), >> editable=True, >> ) >> >> >> >> And here is the traceback: >> >> Environment: >> >> Request Method: GET >> Request URL: http://127.0.0.1:8000/ >> Django Version: 1.6.5 >> Python Version: 3.4.0 >> Installed Applications: >> ('mezzanine.boot', >> 'django.contrib.auth', >> 'django.contrib.contenttypes', >> 'django.contrib.redirects', >> 'django.contrib.sessions', >> 'django.contrib.sites', >> 'django.contrib.sitemaps', >> 'django.contrib.staticfiles', >> 'theme', >> 'mezzanine.conf', >> 'mezzanine.core', >> 'mezzanine.generic', >> 'mezzanine.blog', >> 'mezzanine.forms', >> 'mezzanine.pages', >> 'mezzanine.galleries', >> 'mezzanine.twitter', >> 'filebrowser_safe', >> 'south', >> 'grappelli_safe', >> 'django.contrib.admin', >> 'django.contrib.comments') >> Installed Middleware: >> ('django.contrib.sessions.middleware.SessionMiddleware', >> 'django.middleware.locale.LocaleMiddleware', >> 'django.contrib.auth.middleware.AuthenticationMiddleware', >> 'django.middleware.common.CommonMiddleware', >> 'django.middleware.csrf.CsrfViewMiddleware', >> 'django.contrib.messages.middleware.MessageMiddleware', >> 'mezzanine.core.request.CurrentRequestMiddleware', >> 'mezzanine.core.middleware.RedirectFallbackMiddleware', >> 'mezzanine.core.middleware.TemplateForDeviceMiddleware', >> 'mezzanine.core.middleware.TemplateForHostMiddleware', >> 'mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware', >> 'mezzanine.core.middleware.SitePermissionMiddleware', >> 'mezzanine.pages.middleware.PageMiddleware') >> >> Traceback: >> File >> "/home/fgblomqvist/.virtualenvs/mezzanine-test- >> env3/lib/python3.4/site-packages/django/core/handlers/base.py" >> in get_response >> 105. response = middleware_method(request, >> callback, callback_args, callback_kwargs) >> File >> "/home/fgblomqvist/.virtualenvs/mezzanine-test- >> env3/lib/python3.4/site-packages/mezzanine/pages/middleware.py" >> in process_view >> 103. response = view_func(request, *view_args, >> **view_kwargs) >> File >> "/home/fgblomqvist/.virtualenvs/mezzanine-test- >> env3/lib/python3.4/site-packages/mezzanine/pages/views.py" >> in page >> 100. return render(request, templates, extra_context or {}) >> File >> "/home/fgblomqvist/.virtualenvs/mezzanine-test- >> env3/lib/python3.4/site-packages/mezzanine/utils/views.py" >> in render >> 163. context_instance = RequestContext(request, dictionary) >> File >> "/home/fgblomqvist/.virtualenvs/mezzanine-test- >> env3/lib/python3.4/site-packages/django/template/context.py" >> in __init__ >> 169. self.update(processor(request)) >> File >> "/home/fgblomqvist/.virtualenvs/mezzanine-test- >> env3/lib/python3.4/site-packages/mezzanine/conf/context_processors.py" >> in settings >> 45. settings_dict[k] = getattr(settings, k, "") >> File >> "/home/fgblomqvist/.virtualenvs/mezzanine-test- >> env3/lib/python3.4/site-packages/mezzanine/conf/__init__.py" >> in __getattr__ >> 184. self._load() >> File >> "/home/fgblomqvist/.virtualenvs/mezzanine-test- >> env3/lib/python3.4/site-packages/mezzanine/conf/__init__.py" >> in _load >> 148. setting_value = type_fn(setting_obj.value) >> Exception Type: TypeError at / >> Exception Value: NoneType takes no arguments >> >> >> Regards, Fredrik >> >> > My code is basically this: > > ~~~~~~~~~~~~ > from django.conf import settings > > from django.utils.translation import ugettext_lazy as _ > > from mezzanine.conf import register_setting > > register_setting( > name="SOCIAL_FACEBOOK", > description="Link to Facebook Page. Include http prefix.", > editable=True, > default="", > ) > > register_setting( > name="SOCIAL_TWITTER", > description="Link to Twitter Feed. Include http prefix.", > editable=True, > default="", > ) > > # ... and a few more ... > > register_setting( > name="TEMPLATE_ACCESSIBLE_SETTINGS", > append=True, > default=("SOCIAL_FACEBOOK", "SOCIAL_TWITTER", > "SOCIAL_GOOGLEPLUS", "SOCIAL_YOUTUBE", > "SOCIAL_EMAIL", > ), > ) > ~~~~~~~~~~~ > > -- > Email: [email protected] > > > -- > You received this message because you are subscribed to the Google Groups > "Mezzanine Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Stephen McDonald http://jupo.org -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
