Thursday, December 5, 2013

ManyToMany field creation problem

Hi,

I have these tables


on apps/common/models.py


class UnitType(models.Model):
    title = models.CharField(max_length=50)

    def __unicode__(self):
        return u'%s' % self.title

class UnitPrice(models.Model):
    project = models.ForeignKey('property.Property')
    unit_type = models.ForeignKey(UnitType)

    five_year_target_price = models.CharField(max_length=50, blank=True, null=True)
    per_sqft_price = models.CharField(max_length=50, blank=True, null=True)
    total_price = models.CharField(max_length=50, blank=True, null=True)
   
    total_area = models.CharField(max_length=140, blank=True, null=True)
    carpet_area = models.CharField(max_length=140, blank=True, null=True)

     def __unicode__(self):
        return u'%s' % self.title



and on apps/property/models.py


class Property(Base):
.....
.....
    unit_price = models.ManyToManyField(UnitType,through=UnitPrice, blank=True, null=True)

.....
.....



after adding the unit price field I did  a migration

      python manage.py schemamigration property --auto

I am getting this output

       Nothing seems to have changed.

the through table is created,  i have checked that.


                                         Table "public.common_unitprice"
         Column         |          Type          |                           Modifiers                          
------------------------+------------------------+---------------------------------------------------------------
 id                     | integer                | not null default nextval('common_unitprice_id_seq'::regclass)
 project_id             | integer                | not null
 unit_type_id           | integer                | not null
 five_year_target_price | character varying(50)  |
 per_sqft_price         | character varying(50)  |
 total_price            | character varying(50)  |
 total_area             | character varying(140) |
 carpet_area            | character varying(140) |
Indexes:
    "common_unitprice_pkey" PRIMARY KEY, btree (id)
    "common_unitprice_project_id" btree (project_id)
    "common_unitprice_unit_type_id" btree (unit_type_id)
Foreign-key constraints:
    "project_id_refs_id_7c43d44c" FOREIGN KEY (project_id) REFERENCES property_property(id) DEFERRABLE INITIALLY DEFERRED
    "unit_type_id_refs_id_1a1f3765" FOREIGN KEY (unit_type_id) REFERENCES common_unittype(id) DEFERRABLE INITIALLY DEFERRED






Any help??

--
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/CAFWA-MOdDbRDc5m-pj07J1cUaKo4MvFc8nfbx1Fz6rbC%2B7m_3A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate