Y
Y
Yarik Khinkin2020-10-18 23:01:31
Django
Yarik Khinkin, 2020-10-18 23:01:31

Why is the save() command not executing in Django?

I'm learning the Django framework at https://webformyself.com/djang ... ign=django, everything was going great until I got to part 1, lesson 9.

When trying to save records to the database via the variable news1.save() , an error occurs:

Mistake
>>> news1.save()
Traceback (most recent call last):
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 413, in exec
ute
return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: table news_news has no column named updated_at

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "", line 1, in
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\models\base.py", line 753, in save
self.save_base(using=using, force_insert=force_insert,
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\models\base.py", line 790, in save_base
updated = self._save_table(
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\models\base.py", line 895, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\models\base.py", line 933, in _do_insert
return manager._insert(
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\models\manager.py", line 85, in manager_meth
od
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\models\query.py", line 1254, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields )
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1397, in execu
te_sql
cursor.execute(sql, params)
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\backends\utils.py", line 98, in execute
return super().execute(sql, params)
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\backends\utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\backends\utils.py", line 75, in _execute_wit
h_wrappers
return executor(sql, params, many, context)
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "D:\django-sites\testsite\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 413, in exec
ute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: table news_news has no column named updated_at
5f8c9f05ac67e427929945.png5f8c9f174c1e4722561199.png

I already started the whole course 3 times from the beginning, rummaged through the entire Internet, but could not find a solution.

Help me please!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
shurshur, 2020-10-19
@yarik310501

The model has been modified but not migrated:
python manage.py makemigrations
python manage.py migrate

M
Misha Tarasov, 2021-06-15
@Miha_Tarasov

Make migrations

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question