Re: Problem with populate script

2014-10-01 Thread Daniel Grace
I got this working, I had to do two things.
1. add the following line at the top of the script:
import django
2. add the following line after "os.environ.setdefault...":
django.setup()

-- 
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+unsubscr...@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/758faacb-94c9-41cb-953e-6ed4a7e8f9c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with populate script

2014-09-29 Thread Collin Anderson
Is the path to the django source code is on your PYTHONPATH?

If it's in the same directory, try: PYTHONPATH=. populate.py

-- 
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+unsubscr...@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/1fc0a056-e6c4-4653-b0bc-6fb8e8df8e42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with populate script

2014-09-29 Thread robert brook
This was really not a core function of the application, so I wold not worry 
about it.

Just add the data to a csv page and import it into sql lite to get you 
going.


But I believe that you need to tell Python where the data base is located 
using the settings file

 import os
 os.environ['DJANGO_SETTINGS_MODULE']='settings'



On Monday, September 29, 2014 1:51:13 PM UTC-4, Daniel Grace wrote:
>
> 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 
> from rango.models import Category, Page
>   File "C:\landy\tango\rango\models.py", line 1, in 
> 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+unsubscr...@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/e1dfa25b-8c7c-4489-88d4-eaa637ca94b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with populate script

2014-09-29 Thread Daniel Grace
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 
from rango.models import Category, Page
  File "C:\landy\tango\rango\models.py", line 1, in 
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+unsubscr...@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.