2

I'm new to django. What I'm trying to achieve is when the ProductType combobox is changed, the fields changes to its specific fields then the users inputs using those field and entered to the database. My problem is how to create a flexible model that would accept extra fields

from django.db import models


class Product(models.Model):
    """SKU"""
    stock = models.IntegerField(default=None)    

class ProductType(models.Model):
    product_field = models.ForeignKey(ProductFields, on_delete=models.CASCADE)
    name = models.CharField(max_length=255)

class ProductFields(models.Model):
    """Fields of ProductType"""

Here's an DB example I'm trying to achieve See Image

JamesL
  • 41
  • 2

1 Answers1

1

SQL database is not suitable for that purpose. Look for non-SQL databases for ex. Firebase

Mike Olszak
  • 373
  • 6
  • 12