Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do I need to import to gain access to my models?

Tags:

python

django

I'd like to run a script to populate my database. I'd like to access it through the Django database API.

The only problem is that I don't know what I would need to import to gain access to this.

How can this be achieved?

like image 568
spence91 Avatar asked Oct 08 '08 11:10

spence91


1 Answers

Import your settings module too

import os
os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings"

from mysite.polls.models import Poll, Choice

should do the trick.

like image 117
kender Avatar answered Sep 20 '22 18:09

kender