class ProductGroup(models.Model): group_sku = models.CharField(unique=True, max_length=255) brand = models.CharField(max_length=255) ...
class Product(models.Model): product_sku = models.CharField(unique=True, max_length=255) color = models.CharField(max_length=255) size = models.CharField(max_length=255) product = models.ForeignKey(Product, limit_choices_to=Q(group_sku__in=product_sku)) ... I'm importing my data to Django from an XML file via a python script. group_sku comes in the format "GROUP123" product_sku comes in the format "GROUP123-BLUE-M" (or similar) and there are multiple products in each group How do I define the foreign key relationship so that each Product is linked to its respective ProductGroup? Or feel free to tell me if I'm going about this the complete wrong way. Using Django 1.6.5, Python 2.7, and MySQL -- 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+unsubscr...@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/7b972d02-f9cf-4bd2-a453-43474bf920ae%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.