문제

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?

도움이 되었습니까?

해결책

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top