Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I correctly understand, you don't need dynamic model fields, instead you can add model, which contains specific attributes for image in project, something like:</p> <pre><code>class Image(models.Model): name = models.CharField() img = models.ImageField() class ProjectImage(models.Model): image = models.ForeignKey('Image') project = models.ForeignKey('Project') flag = models.CharField(choices=PASS_FAIL_UNKNOWN) class ProjectImageTag(models.Model): project_image = models.ForeignKey(ProjectImage) value = models.CharField() class Project(models.Model): images = models.ManyToManyField('Image', through=ProjectImage) </code></pre> <p>Also, you can store such tags in <a href="https://github.com/derek-schaefer/django-json-field" rel="nofollow">json field</a> or postgres <a href="https://django-orm.readthedocs.org/en/latest/orm-pg-hstore.html" rel="nofollow">hstore field</a> instead of separate table.</p> <p><strong>EDIT</strong></p> <p>Variation with predefined keys:</p> <pre><code>class ProjectImage(models.Model): image = models.ForeignKey('Image') project = models.ForeignKey('Project') flag = models.CharField(choices=PASS_FAIL_UNKNOWN) class Image(models.Model): name = models.CharField() img = models.ImageField() class Project(models.Model): images = models.ManyToManyField('Image', through=ProjectImage) class ProjectImageParams(models.Model): project_image = models.ForeignKey(ProjectImage, related_name='params') key = models.CharField() value = models.BooleanField() </code></pre> <p>Params of image may be obtained with ProjectImage().params.all(). And yes, django-eav may be a good option.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload