Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
1.2 ModelForm.is_valid() backward incompatible change
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ydjango  
View profile  
 More options Jun 9 2012, 4:54 pm
From: ydjango <neerash...@gmail.com>
Date: Sat, 9 Jun 2012 13:54:48 -0700 (PDT)
Local: Sat, Jun 9 2012 4:54 pm
Subject: 1.2 ModelForm.is_valid() backward incompatible change
From 1.2 release notes (backward incompatible change):
"Much of the validation work for ModelForms has been moved down to the
model level. As a result, the first time you call
ModelForm.is_valid(), access ModelForm.errors or otherwise trigger
form validation, your model will be cleaned in-place. This conversion
used to happen when the model was saved. If you need an unmodified
instance of your model, you should pass a copy to the ModelForm
constructor.

I am migrating from 1.1 to 1.3. Some of my code rely on model not
being cleaned in place. As  some fields become read only and should
not be changed. This 1.2 functionality makes those field empty. Also I
save the model and not the form in these cases.

So as per documentation, to get around it, I need to pass a copy of
model to form. What is the best way to get a copy of model:
1) use deepcopy?
2)  get the object twice from db? (slow as more db access)

Any downsides to using deepcopy? Anything I need to be careful about?

Anyone else also had this issue and any suggestions.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kurtis Mullins  
View profile  
 More options Jun 12 2012, 10:29 am
From: Kurtis Mullins <kurtis.mull...@gmail.com>
Date: Tue, 12 Jun 2012 10:29:13 -0400
Local: Tues, Jun 12 2012 10:29 am
Subject: Re: 1.2 ModelForm.is_valid() backward incompatible change

I'm not sure if I understand the problem correctly, but I think this might
be what you're looking to do.

In your ModelForm, simply exclude the fields you don't want or explicitly
include only the fields you do want to use. Those are both under the
ModelForm's Meta class.

e.g.

# Include only these fields
class Meta:
    fields = ('fieldA', 'fieldB', 'fieldD')

# Or Exclude a field
class Meta:
    exclude = ('fieldC',)

https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »