Question

I am using django-tagging to manage tags on my entities. How do I ensure that the user has entered at least one tag when filling out a form, other than using javascript validation on the front end?

Was it helpful?

Solution

Are you using the TagField()? If so, it extends the default Django CharField which accepts a required=True argument.

The above applies to a FormField, not ModelField. You can do this instead to make sure the Model field is always required in any subsequent form:

class MyModel(models.Model):
    tags = TagField(blank=False)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top