I’m hosting two websites on ubuntu server and both having postgresql, the first one is working prefect but the second give me this error no such table: wagtailcore_site Request Method: GET Django Version: 2.2.10 Exception Type: OperationalError Exception Value: no such table: wagtailcore_site Exception Location: /home/project2/.venv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 383 Python Executable: /home/project2/.venv/bin/python3.7m Python Version: 3.7.3 database settings for first
Tag: django
Invalid password format or unknown hashing algorithm in Django class based view
I want to create user by API view. But I get this problem: serializers.py views.py How can I solve this problem? Answer You should override serializer’s create() method to hash password before saving new user object. You can use set_password for this: Otherwise User.password will be stared in DB without hashing which is not secure. Also you can use create_user
Prettier vscode extension not support Django template tags {% tag %}
Prettier visual studio code extension not support Django template tags {% tag %} now How can I fix this? Do I have to disable Prettier extension for html files or is there another solution؟؟ issues 5581 in github = No Django template tags support Answer February 2022 Based on @Al Mahdi’s comment: Prettier does not support prettier.disableLanguages option anymore. Therefore,
Django Error – unsupported operand type(s) for -: ‘str’ and ‘int’
I have a Django code that must do some math, but I continuously get the following error: unsupported operand type(s) for -: ‘str’ and ‘int’ Here is the code: Here is also the URL where I want to get “nor” from: http://localhost:8000/mechanical/?nor=4&mc=yes&repaired=no&submit=Submit Answer Query string params are always string, you need to convert them to desired type. Here you need
putting a pandas dataframe inside a django template
I want to put a pandas dataframe inside a django template. For instance I want something like this: What I have tried are these codes. First in my django views.py, this was my function: The template is: And, the style.css is: Apparently, when I check it in my browser the template is loaded with the CSS code correctly but it
psycopg2.IntegrityError: duplicate key value violates unique constraint DETAIL: Key (id)=(19) already exists
I am not setting the primary key manually. How could this be happening? In my 5 years of programming in Django I’ve never gotten this error. I can’t tell what is going wrong by just looking at my code and the traceback. What could be wrong? Let me know if I need to post more code. Thanks in advance. Any
About converting custom functions in models into annotations in custom managers/querysets
Being new to Django, I’m starting to care a bit about performance of my web application. I’m trying to transform many of my custom functions / properties which were originally in my models to querysets within custom managers. in my model I have: But I’m not clear on a few points: 1/ is there any pros or cons declaring with
ModuleNotFoundError: No module named ‘bootstrap4’
I installed bootstrap4 with $ pip install django-bootstrap4 It is being installed in this directory C:Userstradetechpit-match-envLibsite-packages Django seems to be looking at this directory C:UserstradeAnaconda3libsite-packagesdjango When I put ‘bootstrap4’ in the INSTALLED_APPS = (‘bootstrap4’) variable and then run $ python manage.py runserver I get this error How can I resolve this error? I installed bootstrap4 in the django folder by
Proper usage of “callable default function” in Django REST Framework (DRF)
Question: How can I access the serializer instance or any relevant arguments in the default callable function of DRF field? Scenario: I have a serializer configuration as below, and when I try to serialize the data as, I am gettting error as, Answer Update For DRF>=3.12, use this king of default class pass a class instance instead of function to
Django model filter targeting JSONField where the keys contain hyphen / dash
I am trying to apply a model filter on a JSONField BUT the keys in the JSON are UUIDs. So when is do something like… … I get a compile error. The hyphens in the UUID are the issue. Any clues if there is an escape char or another behaviour to use? My database is PostgreSQL. Update 1 – now