Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics Model Administration First App View

Leor Benari
Leor Benari
628 Points

Django: No such column: courses_course.description

So, I was following along, and actually got past this step. Unfortunately, I somehow lost my workspace. I maybe went to a workspace where I didn't figure everything out.

Here is my snapshot:

https://w.trhou.se/2pp2cnwhai

Thanks.

Leor Benari
Leor Benari
628 Points

Thanks for the response. I tried that, and this is what I got:

treehouse:~/workspace/learning_site$ python manage.py makemigrations courses
You are trying to add a non-nullable field 'description' to course 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)
2) Quit, and let me add a default in models.py
Select an option:

Leor Benari
Leor Benari
628 Points

Ok, so I think I got it. It didn't want the field to be null (I'm not sure why). I just selected '1', and then I assigned it to the empty string, ''.

Another quick question: What is the difference between makemigrations and migrate, and makemigrations courses and migrate courses. How is it different, and what would happen if you did it the first way, instead.

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

Did you run makemigrations and migrate after adding description to the Courses model?

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

To answer your comments

What is the difference between makemigrations and migrate,

makemigrations is a Django management command that compares the database and your models to create "recipe" code to change the database to match changes in the models.

migrate is a Django management command that runs the recipes to affect the changes in the database.

Running either of these commands on their own covers all apps.

makemigrations courses and migrate courses. How is it different, and what would happen if you did it the first way, instead.

these run the commands on only the courses models.

Leor Benari
Leor Benari
628 Points

Very helpful. Thanks!!