Merge pull request #59 from wackerservices/feature/model-specific-attributes

New feature: many to many to content type on attribute
This commit is contained in:
Daniel Indictor 2020-11-13 00:41:31 -05:00 committed by GitHub
commit 715dea0626
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -27,6 +27,7 @@ class Migration(migrations.Migration):
('modified', models.DateTimeField(auto_now=True, verbose_name='Modified')),
('required', models.BooleanField(default=False, verbose_name='Required')),
('display_order', models.PositiveIntegerField(default=1, verbose_name='Display order')),
('entity_ct', models.ManyToManyField(to='contenttypes.ContentType', blank=True)),
],
options={
'ordering': ['name'],

View file

@ -184,6 +184,14 @@ class Attribute(models.Model):
"""
required = models.BooleanField(verbose_name = _('Required'), default = False)
entity_ct = models.ManyToManyField(ContentType, blank=True)
"""
This field allows you to specify a relationship with any number of content types.
This would be useful, for example, if you wanted an attribute to apply only to
a subset of entities. In that case, you could filter by content type in the
:meth:`~eav.registry.EavConfig.get_attributes` method of that entity's config.
"""
enum_group = models.ForeignKey(
EnumGroup,
verbose_name = _('Choice Group'),