You have models:
class Order(Model):
date = DateField(editable = False, auto_now_add=True)
status = CharField(max_length = 1, choices = STATUS, default = 'N')
profile = ForeignKey(Profile, related_name = 'orders', blank = True, null = True)
shipping = ForeignKey(Shipping, related_name = 'orders', blank = True, null = True)
address = ForeignKey(Address, related_name = 'address_orders', blank = True, null = True)
company = ForeignKey(Company, related_name = 'company_orders', blank = True, null = True)
class Address(Model):
address_profile = ForeignKey(Profile, related_name = 'addresses')
city = CharField(max_length = 256, blank = True, null = True)
street = CharField(max_length = 256, blank = True, null = True)
zipcode = CharField(max_length = 10, blank = True, null = True)
phone = CharField(max_length = 23, blank = True, null = True)
class Company(Address):
company_profile = ForeignKey(Profile, related_name = 'companies')
name = CharField(max_length = 256, blank = True, null = True)
company_id = CharField(max_length = 256, blank = True, null = True)
How do you create OrderForm for specified profile? With this one
class OrderCheckoutForm(forms.ModelForm):
class Meta:
model = Order
I get a form with all addresses and companies in option. I'd like to limit them to related with it's profile. Is there any simple solution?
Thanks in advance, Etam.