Help! I’m on page 60 of the fantastic book.
I’ve got an error.
I can’t figure out where to fix the error.
It tells me the error is a syntax error in my views.py code at:
return redirect(‘thing_detail’, slug=thing.slug)
- I don’t know where to go to fix the error…
- can I just delete it and try again?
- Is there a good place for me to understand the “commit” function? - if I can figure out how to fix my error, I want to use that function.
Thanks!
SyntaxError at /admin/collection/thing/
‘return’ outside function (views.py, line 25)
Request Method: GET
Request URL: http://localhost:8000/admin/collection/thing/
Django Version: 1.8.4
Exception Type: SyntaxError
Exception Value:
‘return’ outside function (views.py, line 25)
Exception Location: /home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/importlib/init.py in import_module, line 109
Python Executable: /home/juicebox/my_project_folder/hellowebapp/venv/bin/python
Python Version: 3.4.3
Python Path:
[’/home/juicebox/my_project_folder/hellowebapp’,
’/home/juicebox/my_project_folder/hellowebapp/venv/lib/python34.zip’,
’/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4’,
’/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/plat-linux’,
’/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/lib-dynload’,
’/home/juicebox/.pyenv/versions/3.4.3/lib/python3.4’,
’/home/juicebox/.pyenv/versions/3.4.3/lib/python3.4/plat-linux’,
’/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages’]
Server time: Mon, 28 Sep 2015 04:04:53 +0000
Error during template rendering
In template /home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/contrib/admin/templates/admin/change_list.html, error at line 11
’return’ outside function
1 {% extends “admin/base_site.html” %}
2 {% load i18n admin_urls admin_static admin_list %}
3
4 {% block extrastyle %}
5 {{ block.super }}
6 <link rel=“stylesheet” type=“text/css” href="{% static “admin/css/changelists.css” %}" />
7 {% if cl.formset %}
8 <link rel=“stylesheet” type=“text/css” href="{% static “admin/css/forms.css” %}" />
9 {% endif %}
10 {% if cl.formset or action_form %}
11
12 {% endif %}
13 {{ media.css }}
14 {% if not actions_on_top and not actions_on_bottom %}
15
16 #changelist table thead th:first-child {width: inherit}
17
18 {% endif %}
19 {% endblock %}
20
21 {% block extrahead %}
Traceback Switch to copy-and-paste view
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/core/handlers/base.py in get_response
response = response.render()
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/response.py in render
self.content = self.rendered_content
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/response.py in rendered_content
content = template.render(context, self._request)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/backends/django.py in render
return self.template.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/base.py in render
return self._render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/base.py in _render
return self.nodelist.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/base.py in render
bit = self.render_node(node, context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/debug.py in render_node
return node.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/base.py in _render
return self.nodelist.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/base.py in render
bit = self.render_node(node, context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/debug.py in render_node
return node.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/loader_tags.py in render
return compiled_parent._render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/base.py in _render
return self.nodelist.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/base.py in render
bit = self.render_node(node, context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/debug.py in render_node
return node.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/loader_tags.py in render
result = block.nodelist.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/base.py in render
bit = self.render_node(node, context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/debug.py in render_node
return node.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/defaulttags.py in render
return nodelist.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/base.py in render
bit = self.render_node(node, context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/debug.py in render_node
return node.render(context)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/template/defaulttags.py in render
url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/core/urlresolvers.py in reverse
app_list = resolver.app_dict[ns]
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/core/urlresolvers.py in app_dict
self._populate()
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/core/urlresolvers.py in _populate
lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/core/urlresolvers.py in callback
self._callback = get_callable(self._callback_str)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/functools.py in wrapper
result = user_function(*args, **kwds)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/site-packages/django/core/urlresolvers.py in get_callable
mod = import_module(mod_name)
...
▶ Local vars
/home/juicebox/my_project_folder/hellowebapp/venv/lib/python3.4/importlib/__init__.py in import_module
return _bootstrap._gcd_import(name[level:], package, level)
...
▶ Local vars
Request information
GET
No GET data
POST
No POST data
FILES
No FILES data
COOKIES
Variable Value
csrftoken
‘9USN1IsUOkGk8QkCZMer7INL01mElHTi’
sessionid
‘ekgvrs0avx54lqhgelsv4y0dvala4b0x’
META
Variable Value
GDMSESSION
‘xubuntu’
UPSTART_SESSION
‘unix:abstract=/com/ubuntu/upstart-session/1000/1468’
NVM_DIR
‘/home/juicebox/.nvm’
PYENV_SHELL
‘bash’
wsgi.url_scheme
‘http’
SESSIONTYPE
‘’
UPSTART_EVENTS
‘started xsession’
HTTP_USER_AGENT
‘Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0’
RUN_MAIN
‘true’
XDG_SESSION_ID
‘c1’
MANPATH
‘/home/juicebox/.nvm/versions/io.js/v2.0.1/share/man:/home/juicebox/.rvm/rubies/ruby-2.1.5/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man:/home/juicebox/.rvm/man’
NVM_BIN
‘/home/juicebox/.nvm/versions/io.js/v2.0.1/bin’
PWD
‘/home/juicebox/my_project_folder/hellowebapp’
REMOTE_ADDR
‘127.0.0.1’
XDG_GREETER_DATA_DIR
‘/var/lib/lightdm-data/juicebox’
VIRTUAL_ENV
‘/home/juicebox/my_project_folder/hellowebapp/venv’
XDG_SESSION_PATH
‘/org/freedesktop/DisplayManager/Session0’
NVM_IOJS_ORG_VERSION_LISTING
‘https://iojs.org/dist/index.tab’
UPSTART_INSTANCE
‘’
wsgi.input
<_io.BufferedReader name=6>
rvm_prefix
‘/home/juicebox’
QUERY_STRING
‘’
XAUTHORITY
‘/home/juicebox/.Xauthority’
wsgi.multiprocess
False
GLADE_MODULE_PATH
‘:’
HTTP_ACCEPT_LANGUAGE
‘en-US,en;q=0.5’
PATH_INFO
‘/admin/collection/thing/’
COLORTERM
‘xfce4-terminal’
HTTP_COOKIE
('csrftoken=9USN1IsUOkGk8QkCZMer7INL01mElHTi; '
‘sessionid=ekgvrs0avx54lqhgelsv4y0dvala4b0x’)
wsgi.version
(1, 0)
SERVER_PROTOCOL
‘HTTP/1.1’
XDG_CURRENT_DESKTOP
‘XFCE’
_system_name
‘Ubuntu’
XDG_SEAT_PATH
‘/org/freedesktop/DisplayManager/Seat0’