Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'function' object has no attribute 'MY_SETTING'

Tags:

python

django

In my views.py I have

from django.conf import settings

  def site_view(request):
    ...
    if some_var == settings.MY_SETTING:
  ...

The value MY_SETTING is defined in settings.py. However I get the following error when I try and load the view:

Exception Type:    AttributeError
Exception Value:   'function' object has no attribute 'MY_SETTING'

What's going on?

like image 856
fredley Avatar asked Dec 13 '12 11:12

fredley


1 Answers

How about importing settings like:

from django.conf import settings as conf_settings

then:

if some_var == conf_settings.MY_SETTING:
like image 141
CJ4 Avatar answered Nov 13 '22 03:11

CJ4