Monday, September 29, 2014

Problem with populate script

I am trying to follow the tutorial at http://www.tangowithdjango.com/
I am stuck in section 5.8 where it shows how to create a script to populate the database.
I created a script called "populate.py" as shown (except I added brackets for the Python 3 print statements),
and saved it in the root directory for my project.
But when I run the script I get an error:

(landy) C:\landy\tango>populate.py
Starting Rango population script...
Traceback (most recent call last):
  File "C:\landy\tango\populate.py", line 59, in <module>
    from rango.models import Category, Page
  File "C:\landy\tango\rango\models.py", line 1, in <module>
    from django.db import models
ImportError: No module named 'django.db'

I tried placing the script in C:\landy\tango\tango and C:\landy\tango\rango directories but I get similar errors.

Is it a better approach to make the populate script into a manage command?
Or should I be using fixtures?

Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a05392f4-bf88-403d-98da-8478595be570%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment