Friday, December 6, 2013

Re: ManyToMany field creation problem

I cant get the field

unit_price = models.ManyToManyField(UnitType,through=UnitPrice, blank=True, null=True)

in Property table.

After adding the field, I tried doing a schemamigration, but output says  "No change has been done"





On Fri, Dec 6, 2013 at 3:04 PM, Daniel Roseman <daniel@roseman.org.uk> wrote:
On Friday, 6 December 2013 07:44:27 UTC, Mrinmoy Das wrote:
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??



What else are you expecting? If the through table is created, that's all you need.
--
DR.

--
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/0b766e73-adf4-42a9-9085-524687de9f50%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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-MNzc%2B4N1aqLEOwp81w-aNftuRivag_strKjMonRHSAj8Q%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