Please Help. I am working on Django Series Tutorial by Corey Schafer. @KenWhitesell … Yes I know you say I should work on more recent tutorials.
The truth is aside from the LearnDjango tutorials which helped me to really grasp and understand Django, the tutorial series by CoreyMS and Real Python have helped boost my understanding of Django.
I wish I had the book Django for Beginners by William Vincent. That is my wish list and like a kid I continue to wish and ask the tooth fairy that I get the book for my 74th birthday coming up February 13, 2025.
Anyway this tutorial by Corey Schafer uses Django 2.1. So using what I learned from following the tutorials on LearnDjango I created a virtual environment and installed Django as I was taught like so
python -m pip install django~=2.1
With pip freeze I saw that I had django 2.2.28 installed. Right now on the Python Django tutorial series by Corey M Schafer
I am at Part 5 of the tutorials(Database and Migrations). I am coding with the Python Interpreter Console. Everything goes fine until I run the following command.
>>> user = User.objects.get(id=1)
>>> user
<User: zackamata>
>>> Post.objects.all()
Traceback (most recent call last):
File "C:\Users\ZACKAMATA\Documents\Learn Python\Django\Corey Schafer\djangoProject\venv\Lib\site-pack
ages\django\db\backends\utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ZACKAMATA\Documents\Learn Python\Django\Corey Schafer\djangoProject\venv\Lib\site-pack
ages\django\db\backends\sqlite3\base.py", line 383, in execute
return Database.Cursor.execute(self, query, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such column: blog_post.author_id
I then tried to makemigrations and I get the following in my command prompt
(venv) C:\Users\ZACKAMATA\Documents\Learn Python\Django\Corey Schafer\djangoProject\djangoProject2>pyth
ject\djangoProject2>python manage.py makemigrations You are trying to add a non-nullable field 'author' to post without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix: 1) Provide a one-off default now (will be set on
all existing rows with a null value for this column) 2) Quit, and let me add a default in models.py
Select an option:
This is new to me so I would like to ask how do I add the default. Thanks for your patience and your understanding