Advise on orm modelling in django
I am building a webapp in which users place orders with nested information. I am after some advice on best practice so I can do some more research.
The idea is that a user either loads an existing order, or creates a new order. They then fill in the subsequent order fields, which can be on a one to many basis. My initial thought was to use a variable for order_id and use a foreign key to link the instances of the other classes. However, this seems overcomplicated. order_id would have to be unique and sequential. Is this the best approach to this issue?
class Order(models.Model):
order_id= xxxx
created_by = xxxx
class A(models.Model):
order_id = models.ForeignKey(xxxxx)
someclassafield = xxxx
class B(models.Model):
order_id = models.ForeignKey(xxxxx)
someclassbfield = xxxx
This would give the user the ability to create orders such as below:
Order 1
(Class_A, order_id, someclassafield)
(Class_A, order_id, someclassafield)
(Class_A, order_id, someclassafield)
(Class_B, order_id, someclassbfield)
Order 2
(Class_A, order_id, someclassafield)
(Class_A, order_id, someclassafield)
(Class_B, order_id, someclassbfield)
(Class_B, order_id, someclassbfield)
How many English words
do you know?
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
how many words do you know
Powered by Examplum