1

I have Django project and I need to create model with fields, which every of them must have 17 fields of string, something like nested dict.

Code below doesnt work, just example. I need something like that:

class LimitValues(models.Model):
    stateDescription = models.TextField() # x17


class VSRGraduation(models.Model):
    some_field_1= models.ForeignKey(LimitValues)
    some_field_2= models.ForeignKey(LimitValues)
    some_field_3= models.ForeignKey(LimitValues)
    # etc... total 15 some_fields

Maybe you are faced with same problem.

1 Answer 1

2

You just need to represent it using 1 to Many relationships.

1 VSRGraduation instance can be pointed by Many LimitValues instances

1 LimitValues instance can be pointed by Many LimitValuesState instances

class LimitValuesState(models.Model):
   stateDescription = models.TextField()
   limitvalue = models.ForeignKey(LimitValues)

class LimitValues(models.Model):
    vsr_graduation = models.ForeignKey(VSRGraduation)


class VSRGraduation(models.Model):
     #extra model fields
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.