Need Help wtih Importing Data into a Model

4 views
Skip to first unread message

Mark Phillips

unread,
Apr 4, 2012, 11:58:39 AM4/4/12
to django users
I build a model in django (my first, after the tutorial!), and it seems to be working. I can see the tables in the admin interface and interact with them. My problem revolves around adding data to the tables. Here is an example of three tables that I am working on:

class Person(models.Model):
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=200)
phone_celll = models.CharField(max_length=12)
email = models.CharField(max_length=200)
home_address_id = models.ForeignKey(Location)

class Coach(models.Model):
person_id = models.ForeignKey(Person)

I copied some data from existing mysql tables into the Person table in this model from the mysql command line using

INSERT INTO table1 SELECT * from table2;

When I look at the tables in the admin web page, all the data is there.

I then tried to add some data to the Coach table using the admin web page, but none of the data from the Person table appears when I click the green + sign. Instead, I get the add data form for the Person table. 

I have tried restarting the server, syncing the db, logging out and into the web interface. The data is in the Person table when I look using the mysql command line interface, and it is also there when I use the admin web page for these tables. However, I am not able to access the data from this table when I try to create a Coachrecord.

What am I doing wrong?

I am running
Linux version 3.1.0-1-amd64 (Debian 3.1.8-2) 
mysql  Ver 14.14 Distrib 5.1.61, for debian-linux-gnu (x86_64) using readline 6.2
django 1.3.1 final

Thanks,

Mark
Reply all
Reply to author
Forward
0 new messages