Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » full_validation fails upon validating an inherited model [RSS Feed]

#1 June 18, 2012 09:45:56

Carsten R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model


Hallo,I have a problem running Django's full_validation-method upon aninstance of an inherited model. Please consider the following two models:class ParentModel(models.Model):

parent_model_id = models.IntegerField(primary_key=True)
parent_model_attr = models.CharField(max_length=200)


class ChildModel(ParentModel):

child_model_attr = models.CharField(max_length=200)Creating a ChildModel by using the keyword pk instead of the primarykey's real attribute name and running full_validation on it beforesaving (after saving this method does not make much sense, I think)leads to an error as shown below:>>> from mytest.models import ChildModel>>> cm = ChildModel(pk=1,child_model_attr='sometext',parent_model_attr='Some other text')>>> cm.full_clean()
Traceback (most recent call last):
File "<console>", line 1, in <module>File "/usr/lib/python2.7/dist-packages/django/db/models/base.py",line 824, in full_cleanraise ValidationError(errors)
ValidationError: {'parent_model_id': }Using the primary key's real attribute name works of course (but cannotbe done in my scenario).Any ideas how to make using the pk-keyword work without that validationerror?Thanks in advance for any hint.


With best regards

Carsten Reimer


--
Carsten Reimer
Web Developer
carsten.rei...@galileo-press.de
Phone +49.228.42150.73

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Phone +49.228.42150.0 (Zentrale) .77 (Fax)http://www.galileo-press.de/Managing Directors: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 June 18, 2012 10:07:43

Carsten R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model


in my previous post I named the method in question full_validation. Thisis obviously wrong. It must be full_clean. Sorry for that.Carsten Reimer schrieb:Hallo,I have a problem running Django's full_validation-method upon aninstance of an inherited model. Please consider the following two models:class ParentModel(models.Model):

parent_model_id = models.IntegerField(primary_key=True)
parent_model_attr = models.CharField(max_length=200)


class ChildModel(ParentModel):

child_model_attr = models.CharField(max_length=200)Creating a ChildModel by using the keyword pk instead of the primarykey's real attribute name and running full_validation on it beforesaving (after saving this method does not make much sense, I think)leads to an error as shown below:>>> from mytest.models import ChildModel>>> cm = ChildModel(pk=1,child_model_attr='sometext',parent_model_attr='Some other text')>>> cm.full_clean()
Traceback (most recent call last):
File "<console>", line 1, in <module>File "/usr/lib/python2.7/dist-packages/django/db/models/base.py", line824, in full_cleanraise ValidationError(errors)
ValidationError: {'parent_model_id': }Using the primary key's real attribute name works of course (but cannotbe done in my scenario).Any ideas how to make using the pk-keyword work without that validationerror?Thanks in advance for any hint.


With best regards

Carsten Reimer--
Carsten Reimer
Web Developer
carsten.rei...@galileo-press.de
Phone +49.228.42150.73

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Phone +49.228.42150.0 (Zentrale) .77 (Fax)http://www.galileo-press.de/Managing Directors: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 25, 2017 11:25:15

CurtisSole
Registered: 2017-01-23
Posts: 87
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model

This post is being moderated

Offline

#4 Feb. 2, 2017 13:38:37

Richardneer
Registered: 2017-01-26
Posts: 55
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model

This post is being moderated

Offline

#5 Feb. 12, 2017 01:33:24

CurtisSole
Registered: 2017-01-23
Posts: 87
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model

This post is being moderated

Offline

#6 Feb. 12, 2017 10:46:12

CurtisSole
Registered: 2017-01-23
Posts: 87
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model

This post is being moderated

Offline

#7 Feb. 14, 2017 15:29:56

CurtisSole
Registered: 2017-01-23
Posts: 87
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model

This post is being moderated

Offline

#8 Feb. 15, 2017 17:17:14

CurtisSole
Registered: 2017-01-23
Posts: 87
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model

This post is being moderated

Offline

#9 Feb. 17, 2017 05:23:41

CurtisSole
Registered: 2017-01-23
Posts: 87
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model

This post is being moderated

Offline

#10 Feb. 17, 2017 10:17:47

Richardneer
Registered: 2017-01-26
Posts: 55
Reputation: +  0  -
Profile   Send e-mail  

full_validation fails upon validating an inherited model

This post is being moderated

Offline

  • Root
  • » Django
  • » full_validation fails upon validating an inherited model [RSS Feed]

Board footer

Moderator control

Enjoy the 24th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support