I don't know why you're calling a ManyToManyField to Products a country 
name, but you shouldn't get a country_name field - the Imports table will 
contain all the data needed to associate countries with products.

What exactly do you want to be stored in the country_name field on the 
Countries model? If you want it to be the name of the country, it should be 
a separate field from the ManyToManyField altogether.

On Tuesday, April 1, 2014 10:21:18 AM UTC, willyhakim wrote:
>
> Below is my models.py
> My problem is when I syncdb (I have dropped the db couple times to start 
> over)
> the *country_name* field with m2m never shows in the db. what am I doing 
> wrong? I am using postgres
>
> class Products(models.Model):
>
>     hs_number = models.CharField(primary_key=True, blank=True, 
> max_length=4)
>     product_descript = models.CharField(max_length=250)
>
>     class Meta:
>         db_table = "Products"
>
>     def __unicode__(self):
>         return self.hs_number
>
>
> class Countries(models.Model):
>     country_id = models.CharField(primary_key=True, max_length=2, 
> blank=True)
>    * country_name = models.ManyToManyField(Products, through="Imports", 
> blank=True)*
>     region = models.CharField(max_length=200)
>
> class Imports(models.Model):
>     hs_number = models.ForeignKey(Products)
>     country_id = models.ForeignKey(Countries)
>     imported_value2008 = models.DecimalField(max_digits=12, 
> decimal_places=2, default=0.00)
>     imported_value2009 = models.DecimalField(max_digits=12, 
> decimal_places=2, default=0.00)
>
>

-- 
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/0cb18bdf-fbbb-46e6-9fdf-43cf6331a79d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to