Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError for "module_name" #2

Open
zudljk opened this issue Oct 16, 2016 · 0 comments
Open

AttributeError for "module_name" #2

zudljk opened this issue Oct 16, 2016 · 0 comments

Comments

@zudljk
Copy link

zudljk commented Oct 16, 2016

As of Django 1.8.x, "module_name" in django.db.models.Model has been renamed to "model_name".
Applying model_blocks to a template in Django >= 1.8 results in this error:

Environment:

Request Method: GET
Request URL: https://django-tutorial-zudljk.c9users.io/polls/3/

Django Version: 1.10.2
Python Version: 2.7.6
Installed Applications:
['polls.apps.PollsConfig',
 'model_blocks',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']


Template error:
In template /home/ubuntu/workspace/polls/templates/polls/detail.html, error at line 2
   'Options' object has no attribute 'module_name'   1 : {% load model_blocks %}
   2 :  {{ question | as_detail_block }} 

Traceback:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/ubuntu/workspace/polls/views.py" in detail
  10.     return render(request, 'polls/detail.html', {'question': get_object_or_404(Question, pk=question_id)})

File "/usr/local/lib/python2.7/dist-packages/django/shortcuts.py" in render
  30.     content = loader.render_to_string(template_name, context, request, using=using)

File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string
  68.     return template.render(context, request)

File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  208.                     return self._render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in render
  1044.             output = self.filter_expression.resolve(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py" in resolve
  739.                 new_obj = func(obj, *arg_vals)

File "/usr/local/lib/python2.7/dist-packages/model_blocks/templatetags/model_filters.py" in as_detail_block
  18.     return node.render(Context({'title':title}))

File "/usr/local/lib/python2.7/dist-packages/model_blocks/templatetags/model_nodes.py" in render
  56.         template_variable = self.get_template_variable(thing, self.thing_type)

File "/usr/local/lib/python2.7/dist-packages/model_blocks/templatetags/model_nodes.py" in get_template_variable
  31.                 (thing._meta.app_label, thing._meta.module_name, type_of_thing)

Exception Type: AttributeError at /polls/3/
Exception Value: 'Options' object has no attribute 'module_name'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant