1👍
✅
The problem is that in SQLite dates are simply stored as strings, hence you can store any invalid date as long as it is a string in your column. But the cursor that is used will try to convert this date into a string, and at this level you will get an error. Hence you cannot resolve to using the ORM to solve this problem and must use SQL queries to solve this.
You can use a raw query from Django’s shell (python manage.py shell
) if you don’t know how to open the database shell, the below snippet assumes that your app is named test_app
, you will need to replace that with your own apps name:
from django.db import connection
with connection.cursor() as cursor:
cursor.execute("UPDATE test_app_post SET flight_date='2021-05-27' WHERE flight_date='27th June'")
0👍
please go into Django shell via this command
python manage.py shell
then import model from models file and fire update query
- [Answered ]-Opening Local Desktop Applications from website button
- [Answered ]-Logging in using django-social-auth in a django unittest
- [Answered ]-Is there a way to automatically update a webpage using Django?
- [Answered ]-Access to the date details in a Django database
- [Answered ]-Django REST framework TokenAuthentication returns anonymous user
Source:stackexchange.com