Related
I have been using the app platform for almost 2 months. Yesterday, I made some changes in database tables (models) in my Django projects. I pushed those changes to Github and my app successfully redeployed. But When I open the site, I got “ProgrammingError” that some field that I created new in the existing table does not exist. So, I opened the console in App Platform and applied migrations but nothing is changed. I am still facing the error.
Here is the full traceback:
Traceback (most recent call last):
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
The above exception (column products_subcategory.description does not exist
LINE 1: ...subcategory"."id", "products_subcategory"."name", "products_...
^
) was the direct cause of the following exception:
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/workspace/lavisco/views.py", line 40, in get
return render(request, 'lavisco/index.html', context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/shortcuts.py", line 19, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/loader.py", line 62, in render_to_string
return template.render(context, request)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 170, in render
return self._render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
return self.nodelist.render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render
bit = node.render_annotated(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
return self.render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
return self.nodelist.render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render
bit = node.render_annotated(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
return self.render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/loader_tags.py", line 192, in render
return template.render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 172, in render
return self._render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
return self.nodelist.render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 938, in render
bit = node.render_annotated(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
return self.render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/defaulttags.py", line 311, in render
if match:
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/models/query.py", line 291, in bool
self._fetch_all()
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/models/query.py", line 1308, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/models/query.py", line 53, in iter
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1156, in execute_sql
cursor.execute(sql, params)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 98, in execute
return super().execute(sql, params)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /
Exception Value: column products_subcategory.description does not exist
LINE 1: ...subcategory"."id", "products_subcategory"."name", "products_...
I need to dynamically create a choice field in Django Form (not ModelForm) using the logged user as a parameter.
The view:
def cadastro(request):
medico = request.user.medico
usuario=request.user
clinicas = medicos.clinicas.all()
escolhas = tuple([(c.id, c.nome.clinica) for c in clinicas])
if request.method == 'POST':
formulario = NovoProcesso(escolhas, request.POST)
if formulario.is_valid():
formulario.save(usuario)
else:
formulario = NovoProcesso(escolhas)
contexto = {'formulario': formulario, 'clinicas': clinicas}
return render(request, 'processos/cadastro.html', contexto)
Form class:
class NovoProcesso(forms.Form):
def __init__(self, escolhas, *args, **kwargs):
super(NovoProcesso, self).__init__(escolhas, *args, **kwargs) -------> the source of the problem is here.
self.fields['clinicas'].choices = escolhas
clinicas = forms.ChoiceField(widget=forms.Select, choices=[])
# there are other fields here, but I ommited for the sake of clarity
def(save):
#custom save method....
I incorrectly passed arguments to the init method as described here:
object has no attribute 'get'
I'm having trouble to understand the line:
self.fields['clinicas'].choices = escolhas
Not sure if I should write self.fields['clinicas].choices or . widget.... not sure how to write de form field inside the class. Tried several variations.
I'm getting the following error:
Internal Server Error: /processos/cadastro/ Traceback (most recent
call last): File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 158, in getitem
field = self.fields[name] KeyError: 'errors'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 828, in _resolve_lookup
current = current[bit] File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 160, in getitem
raise KeyError( KeyError: "Key 'errors' not found in 'NovoProcesso'. Choices are: altura, anamnese, cid, clinicas,
cpf_paciente, data_1, diagnostico, incapaz, med1, med1_posologia_mes1,
nome_mae, nome_paciente, nome_responsavel, peso, qtd_med1_mes1,
qtd_med1_mes2, qtd_med1_mes3, tratamentos_previos, tratou."
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/core/handlers/exception.py",
line 34, in inner
response = get_response(request) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/core/handlers/base.py",
line 115, in _get_response
response = self.process_exception_by_middleware(e, request) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/core/handlers/base.py",
line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/contrib/auth/decorators.py",
line 21, in _wrapped_view
return view_func(request, *args, **kwargs) File "/home/lucas/dev/autocusto/processos/views.py", line 101, in cadastro
return render(request, 'processos/cadastro.html', contexto) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/shortcuts.py",
line 19, in render
content = loader.render_to_string(template_name, context, request, using=using) File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/loader.py",
line 62, in render_to_string
return template.render(context, request) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/backends/django.py",
line 61, in render
return self.template.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 171, in render
return self._render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 163, in _render
return self.nodelist.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 936, in render
bit = node.render_annotated(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 903, in render_annotated
return self.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/loader_tags.py",
line 150, in render
return compiled_parent._render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 163, in _render
return self.nodelist.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 936, in render
bit = node.render_annotated(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 903, in render_annotated
return self.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/loader_tags.py",
line 62, in render
result = block.nodelist.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 936, in render
bit = node.render_annotated(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 903, in render_annotated
return self.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 986, in render
output = self.filter_expression.resolve(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 670, in resolve
obj = self.var.resolve(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 795, in resolve
value = self._resolve_lookup(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 836, in _resolve_lookup
current = getattr(current, bit) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 175, in errors
self.full_clean() File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 376, in full_clean
self._clean_fields() File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 388, in _clean_fields
value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name)) File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/widgets.py",
line 258, in value_from_datadict
return data.get(name) AttributeError: 'tuple' object has no attribute 'get' [20/Dec/2019 13:09:03] "GET /processos/cadastro/
HTTP/1.1" 500 215106 /home/lucas/dev/autocusto/processos/views.py
changed, reloading. Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced). December 20, 2019 -
13:11:10 Django version 3.0, using settings 'autocusto.settings'
Starting development server at http://127.0.0.1:8000/ Quit the server
with CONTROL-C. /home/lucas/dev/autocusto/processos/forms.py changed,
reloading. Watching for file changes with StatReloader Performing
system checks...
System check identified no issues (0 silenced). December 20, 2019 -
13:11:24 Django version 3.0, using settings 'autocusto.settings'
Starting development server at http://127.0.0.1:8000/ Quit the server
with CONTROL-C. [(1, 'SHAM'), (2, '65'), (3, '65asdfasdf'), (4,
'Clínica 1'), (5, 'Clínica 2'), (6, 'Clínica 3')] Internal Server
Error: /processos/cadastro/ Traceback (most recent call last): File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 158, in getitem
field = self.fields[name] KeyError: 'errors'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 828, in _resolve_lookup
current = current[bit] File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 160, in getitem
raise KeyError( KeyError: "Key 'errors' not found in 'NovoProcesso'. Choices are: altura, anamnese, cid, clinicas,
cpf_paciente, data_1, diagnostico, incapaz, med1, med1_posologia_mes1,
nome_mae, nome_paciente, nome_responsavel, peso, qtd_med1_mes1,
qtd_med1_mes2, qtd_med1_mes3, tratamentos_previos, tratou."
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/core/handlers/exception.py",
line 34, in inner
response = get_response(request) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/core/handlers/base.py",
line 115, in _get_response
response = self.process_exception_by_middleware(e, request) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/core/handlers/base.py",
line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/contrib/auth/decorators.py",
line 21, in _wrapped_view
return view_func(request, *args, **kwargs) File "/home/lucas/dev/autocusto/processos/views.py", line 101, in cadastro
return render(request, 'processos/cadastro.html', contexto) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/shortcuts.py",
line 19, in render
content = loader.render_to_string(template_name, context, request, using=using) File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/loader.py",
line 62, in render_to_string
return template.render(context, request) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/backends/django.py",
line 61, in render
return self.template.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 171, in render
return self._render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 163, in _render
return self.nodelist.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 936, in render
bit = node.render_annotated(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 903, in render_annotated
return self.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/loader_tags.py",
line 150, in render
return compiled_parent._render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 163, in _render
return self.nodelist.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 936, in render
bit = node.render_annotated(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 903, in render_annotated
return self.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/loader_tags.py",
line 62, in render
result = block.nodelist.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 936, in render
bit = node.render_annotated(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 903, in render_annotated
return self.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 986, in render
output = self.filter_expression.resolve(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 670, in resolve
obj = self.var.resolve(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 795, in resolve
value = self._resolve_lookup(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 836, in _resolve_lookup
current = getattr(current, bit) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 175, in errors
self.full_clean() File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 376, in full_clean
self._clean_fields() File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 388, in _clean_fields
value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name)) File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/widgets.py",
line 258, in value_from_datadict
return data.get(name) AttributeError: 'list' object has no attribute 'get' [20/Dec/2019 13:11:28] "GET /processos/cadastro/
HTTP/1.1" 500 215100 /home/lucas/dev/autocusto/processos/forms.py
changed, reloading. Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced). December 20, 2019 -
13:13:15 Django version 3.0, using settings 'autocusto.settings'
Starting development server at http://127.0.0.1:8000/ Quit the server
with CONTROL-C. /home/lucas/dev/autocusto/processos/views.py changed,
reloading. Watching for file changes with StatReloader Performing
system checks...
System check identified no issues (0 silenced). December 20, 2019 -
13:25:04 Django version 3.0, using settings 'autocusto.settings'
Starting development server at http://127.0.0.1:8000/ Quit the server
with CONTROL-C. [20/Dec/2019 13:30:03] "GET / HTTP/1.1" 200 3680 Not
Found: /favicon.ico ((1, 'SHAM'), (2, '65'), (3, '65asdfasdf'), (4,
'Clínica 1'), (5, 'Clínica 2'), (6, 'Clínica 3')) Internal Server
Error: /processos/cadastro/ Traceback (most recent call last): File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 158, in getitem
field = self.fields[name] KeyError: 'errors'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 828, in _resolve_lookup
current = current[bit] File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 160, in getitem
raise KeyError( KeyError: "Key 'errors' not found in 'NovoProcesso'. Choices are: altura, anamnese, cid, clinicas,
cpf_paciente, data_1, diagnostico, incapaz, med1, med1_posologia_mes1,
nome_mae, nome_paciente, nome_responsavel, peso, qtd_med1_mes1,
qtd_med1_mes2, qtd_med1_mes3, tratamentos_previos, tratou."
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/core/handlers/exception.py",
line 34, in inner
response = get_response(request) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/core/handlers/base.py",
line 115, in _get_response
response = self.process_exception_by_middleware(e, request) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/core/handlers/base.py",
line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/contrib/auth/decorators.py",
line 21, in _wrapped_view
return view_func(request, *args, **kwargs) File "/home/lucas/dev/autocusto/processos/views.py", line 101, in cadastro
return render(request, 'processos/cadastro.html', contexto) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/shortcuts.py",
line 19, in render
content = loader.render_to_string(template_name, context, request, using=using) File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/loader.py",
line 62, in render_to_string
return template.render(context, request) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/backends/django.py",
line 61, in render
return self.template.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 171, in render
return self._render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 163, in _render
return self.nodelist.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 936, in render
bit = node.render_annotated(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 903, in render_annotated
return self.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/loader_tags.py",
line 150, in render
return compiled_parent._render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 163, in _render
return self.nodelist.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 936, in render
bit = node.render_annotated(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 903, in render_annotated
return self.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/loader_tags.py",
line 62, in render
result = block.nodelist.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 936, in render
bit = node.render_annotated(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 903, in render_annotated
return self.render(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 986, in render
output = self.filter_expression.resolve(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 670, in resolve
obj = self.var.resolve(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 795, in resolve
value = self._resolve_lookup(context) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/template/base.py",
line 836, in _resolve_lookup
current = getattr(current, bit) File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 175, in errors
self.full_clean() File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 376, in full_clean
self._clean_fields() File "/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/forms.py",
line 388, in _clean_fields
value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name)) File
"/home/lucas/dev/.virtualenvs/autocusto/lib/python3.8/site-packages/django/forms/widgets.py",
line 258, in value_from_datadict
return data.get(name) AttributeError: 'tuple' object has no attribute 'get'
I've tried the following solutions with no success:
Django: how to pass parameters to forms,
Django Forms: pass parameter to form
Don't know what I'm missing!
Probably, in NovoProcesso form class or somewhere else you have "," at the end of one of the attribute definition which causes this error. Try to find it out.
You haven't posted whole code but I guess you have something like this:
class NovoProcesso(forms.Form):
clinicas = forms.ChoiceField(widget=forms.Select, choices=[]), <- this comma causes an error
EDIT: Incorrectly passed arguments to the init method as described here object has no attribute 'get'
I'm trying to config the django project in vscode and running via debug.
python==3.6.7
Django==2.1.8
When I try to open http://127.0.0.1:8000/admin/ I am getting the following error, please refer the screen shot below.
I tried many possible workaround from google, by trying to change logging level from debug to info, but nothing seems to be worked.
I request you to please let me know how to fix this issues.
Thanks in advance.
Error Logs:
Exception has occurred: VariableDoesNotExist
Failed lookup for key [is_popup] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x7ff6323e3510>>, 'request': <WSGIRequest: GET '/admin/login/?next=/admin/'>, 'user': <SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7ff632434dd8>>, 'perms': <django.contrib.auth.context_processors.PermWrapper object at 0x7ff6323b2f98>, 'messages': <django.contrib.messages.storage.fallback.FallbackStorage object at 0x7ff63246cc88>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}}, {}, {'form': <AdminAuthenticationForm bound=False, valid=Unknown, fields=(username;password)>, 'view': <django.contrib.auth.views.LoginView object at 0x7ff63246cc50>, 'site_title': 'Django site admin', 'site_header': 'Django administration', 'site_url': '/', 'has_permission': False, 'available_apps': [], 'title': 'Log in', 'app_path': '/admin/login/?next=/admin/', 'username': '', 'next': '/admin/', 'site': <django.contrib.sites.requests.RequestSite object at 0x7ff6323f95f8>, 'site_name': '127.0.0.1:8000', 'LANGUAGE_CODE': 'en-us', 'LANGUAGE_BIDI': False}]
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 850, in _resolve_lookup
(bit, current)) # missing attribute
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 796, in resolve
value = self._resolve_lookup(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 671, in resolve
obj = self.var.resolve(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/defaulttags.py", line 875, in eval
return self.value.resolve(context, ignore_failures=True)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/defaulttags.py", line 302, in render
match = condition.eval(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/base.py", line 171, in render
return self._render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/response.py", line 83, in rendered_content
content = template.render(context, self._request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 154, in _get_response
response = response.render()
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/utils/deprecation.py", line 91, in __call__
response = response or self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 78, in get_response
response = self._middleware_chain(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 142, in __call__
response = self.get_response(request)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 65, in __call__
return self.application(environ, start_response)
File "/usr/lib/python3.6/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 169, in handle
self.handle_one_request()
File "/usr/lib/python3.6/socketserver.py", line 721, in __init__
self.handle()
File "/usr/lib/python3.6/socketserver.py", line 361, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python3.6/socketserver.py", line 348, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python3.6/socketserver.py", line 317, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python3.6/socketserver.py", line 238, in serve_forever
self._handle_request_noblock()
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/servers/basehttp.py", line 213, in run
httpd.serve_forever()
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 139, in inner_run
ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 104, in run
self.inner_run(None, **options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/fs052/Desktop/workspace/tryouts/dj2/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/fs052/Desktop/workspace/tryouts/dj2/dj2/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib/python3.6/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
Seems your django installation is corrupt. Try this
pip install -I django
In my view render I return the following context dictionary:
company = get_object_or_404(Company, slug=slug)
context = {
'company':company,
}
return render(request, 'company-detail.html', context)
I use this in a template tag to check ownership:
#register.filter(name='is_owner')
def is_owner(user, company):
if user.customer.company.id == company.id:
return True
else:
return False
I try to see the output of the tag in my template:
{{user|is_owner:customer.id}}
I get the following error:
Internal Server Error: /companies/my-company/ Traceback (most recent call last): File "/django/template/base.py", line 835, in
_resolve_lookup
current = current[bit] File "/django/template/context.py", line 83, in __getitem__
raise KeyError(key) KeyError: 'customer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/django/template/base.py", line 841, in _resolve_lookup
if isinstance(current, BaseContext) and getattr(type(current), bit): AttributeError: type object 'RequestContext' has no attribute 'customer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/django/template/base.py", line 849, in _resolve_lookup
current = current[int(bit)] ValueError: invalid literal for int() with base 10: 'customer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/django/core/handlers/exception.py", line 35, in inner
response = get_response(request) File "/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request) File "/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/companies/views.py", line 250, in company_detail_view
return render(request, 'companies/company-detail.html', context) File "/django/shortcuts.py", line 36, in render
content = loader.render_to_string(template_name, context, request, using=using) File "/django/template/loader.py", line 62, in render_to_string
return template.render(context, request) File "/django/template/backends/django.py", line 61, in render
return self.template.render(context) File "/django/template/base.py", line 175, in render
return self._render(context) File "/django/template/base.py", line 167, in _render
return self.nodelist.render(context) File "/django/template/base.py", line 943, in render
bit = node.render_annotated(context) File "/django/template/base.py", line 910, in render_annotated
return self.render(context) File "/django/template/loader_tags.py", line 155, in render
return compiled_parent._render(context) File "/django/template/base.py", line 167, in _render
return self.nodelist.render(context) File "/django/template/base.py", line 943, in render
bit = node.render_annotated(context) File "/django/template/base.py", line 910, in render_annotated
return self.render(context) File "/django/template/loader_tags.py", line 67, in render
result = block.nodelist.render(context) File "/django/template/base.py", line 943, in render
bit = node.render_annotated(context) File "/django/template/base.py", line 910, in render_annotated
return self.render(context) File "/django/template/loader_tags.py", line 194, in render
return template.render(context) File "/django/template/base.py", line 177, in render
return self._render(context) File "/django/template/base.py", line 167, in _render
return self.nodelist.render(context) File "/django/template/base.py", line 943, in render
bit = node.render_annotated(context) File "/django/template/base.py", line 910, in render_annotated
return self.render(context) File "/django/template/base.py", line 993, in render
output = self.filter_expression.resolve(context) File "/django/template/base.py", line 697, in resolve
arg_vals.append(arg.resolve(context)) File "/django/template/base.py", line 802, in resolve
value = self._resolve_lookup(context) File "/django/template/base.py", line 856, in _resolve_lookup
(bit, current)) # missing attribute django.template.base.VariableDoesNotExist: Failed lookup for key [customer] in [{'True': True, 'False': False, 'None': None}, {}, {}, {'company': <Company: My Company>}] [08/May/2018 18:55:25] "GET /companies/my-company/ HTTP/1.1" 500 214439
Your view doesn’t set customer in the template context. Perhaps you want:
{{ user|is_owner:company }}
Note that I’ve passed company instead of company_id because the tag uses company.id.
I was develping a site and once installed django-bb, but at some point i've decided not to use anymore, so i "turned-off" django-bb commenting all reference code. So far all good. On my dev machine everting runs ok. But on the server machine, something is calling for djangobb. I tried to delete all files relatives to djangobb, and it's no way i can get rid of this exception error. And I've checked all my html code and cant find anyware this call for djangobb.
Please anybody can help?
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 280, in run
self.result = application(self.environ, self.start_response)
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 674, in __call__
return self.application(environ, start_response)
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 248, in __call__
response = self.get_response(request)
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/core/handlers/base.py", line 130, in get_response
return self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/core/handlers/base.py", line 180, in handle_uncaught_exception
return callback(request, **param_dict)
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/utils/decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/views/defaults.py", line 31, in server_error
return http.HttpResponseServerError(t.render(Context({})))
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/template/__init__.py", line 173, in render
return self._render(context)
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/template/__init__.py", line 167, in _render
return self.nodelist.render(context)
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/template/__init__.py", line 796, in render
bits.append(self.render_node(node, context))
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/template/__init__.py", line 809, in render_node
return node.render(context)
File "/root/Envs/PolyAssocEnv/lib/python2.6/site-packages/django/template/defaulttags.py", line 385, in render
raise e
NoReverseMatch: u'djangobb' is not a registered namespace