class Invoices(models.Model):
invoice_date = models.DateField('created date', auto_now=True)
class Line_Items(models.Model):
descr = models.CharField(max_length=100)
cost = models.DecimalField(max_digits=5, decimal_places=2)
class Invoice_Line_Items_Xref(models.Model):
created_dt = models.DateField(auto_now=True)
invoice_id = models.IntegerField(default=0)
line_item_id = models.IntegerField(default=0)
invoice_id = models.ManyToManyField(Invoices)
line_item_id = models.ManyToManyField(Line_Items)
I don't think the syntax for the cross reference table above is correct, but it is one of the permutations that I've tried. The layout above resulted in this migration after running makemigrations
operations = [
migrations.AddField(
model_name='invoice_line_items_xref',
name='invoice_id',
field=models.ManyToManyField(to='gpga.Invoices'),
),
migrations.AddField(
model_name='invoice_line_items_xref',
name='line_item_id',
field=models.ManyToManyField(to='gpga.Line_Items'),
),
]
However, when I push the code to Openshift, even though the migration runs against the database, the invoice_id and line_item_id columns do not appear on the database table.I have no idea what I'm doing wrong. Thank you for any help.--Michael
--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9953458c-908d-4376-89f9-eb68e37d527a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
class Invoice_Line_Items(models.Model):
created_dt = models.DateField('created date', auto_now=True)
invoice = models.ManyToManyField(Invoices)
line_item = models.ManyToManyField(Line_Items)
I was incorrectly looking for a single table named Invoice_Line_Items because I didn't understand how Django creates multiple tables to deal with ManyToMany relationships like this. The table I was expecting was there, but it didn't have columns for invoice IDs or line_item IDs. Django actually created these three tables to handle this:
gpga_invoice_line_items
gpga_invoice_line_items_invoice
gpga_invoice_line_items_line_item
Thanks again.
--M
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/848c0bba-993a-4599-9829-3c8081af32ec%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/848c0bba-993a-4599-9829-3c8081af32ec%40googlegroups.com.