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 Django's Admin

Creating New Instance Through Admin Panel & Shell - Where do they get saved?

Let's say I wanted to create a back-up of available courses offered through the website; I would have to save the instances somewhere, but where are they located?

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Creating new instances in admin or using the Model .create() method in the manage.py shell will save to the database. If you instantiate using inst = Model(), then you'll need to call inst.save()

Also look into manage.py dumpdata and loaddata for ways to snapshot data in a JSON format.

If you do it in the shell they aren't saved once you close the shell and if you do it in the script it will be saved there, so you will have them when you download the script.