Django stuck on validating models

6854933580_2c8b688306_z

Arrgh, i've search for a day why was it not works!!! One To One Field(Account, null=True) first_name = models. Model Serializer): account = Account Contact Serializer() class Meta: model = Contact read_only_fields = ('created', 'modified',) def create(self, validated_data): account_data = validated_data.pop('account') account = Account.objects.create_user(**account_data) contact = Contact.objects.create(account=account, **validated_data) return contact class Account Contact Serializer(serializers. Char Field(write_only=True, required=False) class Meta: model = Account fields = ('id', 'email', 'password',) def create(self, validated_data): return Account.objects.create(**validated_data) The workaround this is to remove the unique constraint from the serializer and move it to the business logic validation part since the nested serializer can not say - as of today - whether he's updating or creating a new object. Just wanted to say that (unfortunately) without a generic Writable Nested Model Serializer out-of-the-box, Django REST framework is hardly useful.

I wasn't able to run the development server because of a non-critical model validation failure. I've had this problem with many versions of Django, but somehow managed to find where the error was.This time, I can't, and all I get is this cryptic error, absolutely not related to the position of the error, even with the execute_from_command_line(sys.argv) File "/home/username/virtualenv/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/home/username/virtualenv/project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/username/virtualenv/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv self.execute(*args, **options.__dict__) File "/home/username/virtualenv/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute output = self.handle(*args, **options) File "/home/username/virtualenv/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle return self.handle_noargs(**options) File "/home/username/virtualenv/project/local/lib/python2.7/site-packages/django/core/management/commands/validate.py", line 10, in handle_noargs self.validate(display_num_errors=True) File "/home/username/virtualenv/project/local/lib/python2.7/site-packages/django/core/management/base.py", line 314, in validate raise Command Error("One or more models did not validate:\n%s" % error_text) Category fields = ('id', 'name', 'tasks') We don't support (automatic) writable nested serialization, so it's not totally unreasonable to also say 'validators' are not appropraite for this case, here's what you'd need to do.However if there's an alternative that'd def be worth considering. Date Time Field(auto_now_add=True) updated_at = models. Date Time Field(auto_now=True) objects = Account Manager() USERNAME_FIELD = 'email' class Contact Serializer(serializers.It also provides context and hints applicable to the message, and a unique identifier that is used for filtering purposes.

You must have an account to comment. Please register or login here!