"NoneType takes no arguments" when registering settings

997 views
Skip to first unread message

Fredrik Blomqvist

unread,
Jul 10, 2014, 8:37:01 AM7/10/14
to mezzani...@googlegroups.com
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).

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

Stephen McDonald

unread,
Jul 10, 2014, 5:25:20 PM7/10/14
to mezzani...@googlegroups.com
I think you'll find editable settings require a "default" argument - try that.


--
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 mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Stephen McDonald
http://jupo.org

Danny

unread,
Jul 10, 2014, 5:27:19 PM7/10/14
to mezzani...@googlegroups.com

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.
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: mol...@gmail.com

Stephen McDonald

unread,
Jul 10, 2014, 5:37:10 PM7/10/14
to mezzani...@googlegroups.com
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.


--
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 mezzanine-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Fredrik Blomqvist

unread,
Jul 10, 2014, 6:25:47 PM7/10/14
to mezzani...@googlegroups.com, st...@jupo.org
Thanks guys, that was the solution (and it now also seems perfectly logical to me why it needs that).

Cheers.
Reply all
Reply to author
Forward
0 new messages