'At least one of these fields must be filled' - Can I enforce this requirement in Django models? -



'At least one of these fields must be filled' - Can I enforce this requirement in Django models? -

here's utilize case:

class tweet(models.model): url_1 = models.charfield(max_length=140) url_2 = models.charfield(max_length=140) url_3 = models.charfield(max_length=140)

i'd user specify @ to the lowest degree 1 url each tweet instance.

i know how enforce status in views.py, i'm wondering if there's way configure django model such user required fill in @ to the lowest degree 1 out of given set of model fields before instance can saved. think solution cleaner.

thanks!

it can't done @ model level, may possible add together constraint @ database level can enforce this.

django django-models

Comments

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -