Hi,
Yes, it connects to the same database. I only have one accessible database in the production environment and the administration interface works fine for the other models I have, it crashes only when I try to access that specific model or when trying to access the website.
Red.
hi,
You may need to check that the database django connect to is the same as you checked that the column is exists?
--On Tue, Oct 22, 2019 at 8:32 PM red <googlecrap@riseup.net> wrote:
--Hi everyone,
I have a website in production. I have an app, with a model. It contained a markdown_file attribute:
markdown_file=models.FileField(upload_to='/media/')But since the number of file is limited, I decided to make it a markdown_filename attribute with a choices selection box:
markdown_filename=models.CharField(max_length=30,null=True,blank=True,choices=MENU_MARKDOWN_FILE_CHOICES)Therefore, I modified this model and made migrations locally. I pushed the code in production and run:
python manage.py migrateAfter I checked with showmigrations and sqlmigrate, that the modification I made were there. Then, I checked in the database, that the fields were correctly modified. But, I still get this error, when trying to access the website:
ERROR:django.request:Internal Server Error: / Traceback (most recent call last): File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedColumn: column showcase_subpage.markdown_file does not exist LINE 1: ...bpage"."slug", "showcase_subpage"."html_content", "showcase_... ^ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "./showcase/views.py", line 10, in home return render(request, 'showcase/home.html', context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/shortcuts.py", line 36, in render content = loader.render_to_string(template_name, context, request, using=using) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/loader.py", line 62, in render_to_string return template.render(context, request) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render return self.template.render(context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/base.py", line 171, in render return self._render(context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/base.py", line 163, in _render return self.nodelist.render(context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/base.py", line 937, in render bit = node.render_annotated(context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated return self.render(context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render return compiled_parent._render(context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/base.py", line 163, in _render return self.nodelist.render(context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/base.py", line 937, in render bit = node.render_annotated(context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated return self.render(context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/template/defaulttags.py", line 166, in render len_values = len(values) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/models/query.py", line 256, in __len__ self._fetch_all() File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/models/query.py", line 1242, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/models/query.py", line 55, in __iter__ results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1100, in execute_sql cursor.execute(sql, params) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 67, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers return executor(sql, params, many, context) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/srv/data/web/vhosts/default/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: column showcase_subpage.markdown_file does not exist LINE 1: ...bpage"."slug", "showcase_subpage"."html_content", "showcase_... ^The markdown_file field has been modified and renamed as markdown_filename. It has been correctly specified in the migrations. The modification is effective in the database. I tested locally (it works fine locally), to make sure, I don't have anymore code calling markdown_file attribute. I also tried clearing the migrations history and the database, to rebuilt it as new, but, the problem is still there. I can't see why, this former attributes is still queried, though the migrations went OK, without any error.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4ff82558-df2a-85a7-e10c-fd567c768862%40riseup.net.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABexzmg2T%2B7QQynYsykOAY1NKr6gSEcNv%3DBW9Uc-NUqreZFs8Q%40mail.gmail.com.
No comments:
Post a Comment