I've already tried the select_related in my queryset. No change at all.
>>Also keep in mind that Django (or any other framework) has no idea
whether or not fields have "changed" in a form submission without pulling
the original set of values to compare against, so expect the object to be
On Jul 24, 2017 4:09 AM, "johan de taeye" wrote:
I have a model that has a foreign key relation to a number of other objects.
When saving an instance of this model from the admin (or a ModelForm), I
see plenty of extra and redundant database calls.
For a single record
On Tue, Apr 17, 2012 at 8:07 PM, coded kid wrote:
> I want to make sure users fill all the fields before they are
> redirected to the next page. And if they don’t fill the fields it
> should raise an error telling them to fill the fields before they
> proceed. So to do
Indent that redirect one more time so that it's wothin the if loop and
you're redirected to good only when the form is valid
On 18/04/2012 5:07 AM, "coded kid" wrote:
> I want to make sure users fill all the fields before they are
> redirected to the next page. And if
The question is how do I get the modelform to only check for form
validity, and not model validity (like it did before). I don't see
what your link has to do with that.
On Dec 30, 7:32 pm, Ferran wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> On 30/12/10 17:25,
Ah :) . I should have thought of that ... pretty stupid of me :)
Thanks for the clarification, I'll try that, makes perfect sense!
/Axel.
2010/12/30 derek
> Alex
>
> And I seem to have been equally unclear :}
>
> I agree that cleaned_data is only available after
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256
On 30/12/10 17:25, Burhan wrote:
> In 1.2.3, this logic always fails because "is_clean()" fails if an
> existing customer enter's their email address. How can I do the same
> using django 1.2.3?
http://docs.python.org/tutorial/errors.html
Alex
And I seem to have been equally unclear :}
I agree that cleaned_data is only available after is_valid() - the
point being that your form *will* be valid if you have set the value
for that field in a hidden input. I do not see that this can be a
"security risk" - the default that you are
Easiest solution I can see is to create two form classes: StudentForm
and NonStudentForm. On student form you can then edit form.instance
or form.cleaned_data depending on what your needs are to add the
additional fields before the object is created/updated.
Another approach would be to try
hi derek,
thanks for your hints - was I really that unclear? hm.
anyway, could you please give an example about how to "override/check the
value for that field after the form POST"? I don't seem to be able to do
that, and believe me, I have read the docs.
I think cleaned_data is only available
Axel
Not sure I have followed all your requirements, but perhaps you can
try:
* set a default value for the required field
* mask the required field on the form being shown to the user (make it
hidden)
* override/check the value for that field after the form POST and data
"clean" (see:
Test if self.instance.user is not None, if so, change the queryset to
exclude the self.instance.user:
http://gist.github.com/350440
__
Vinícius Mendes
Solucione Sistemas
http://solucione.info/
On Wed, Mar 31, 2010 at 11:24 AM, Emanuel wrote:
> Hi
Hi there,
When calling def clean_name(self):, you can see if your instance has
an id or not:
def clean_name(self):
if not self.id:
#this would be a new record
else:
#this would be an existing record
HTH,
Brandon
On Mar 31, 9:24 am, Emanuel
On Mon, Aug 10, 2009 at 6:09 AM, nostradamnit wrote:
>
> I have a form that inherits from ModelForm, and in my view,
> form.is_valid returns true, then save() bombs out with validation
> errors?!?
>
is_valid is a method. If you are checking it "if form.is_valid:" that is
Digging in documentation surely helps :)
I had to replace
{% if pform.non_field_errors %}
{{ pform.non_field_errors.as_ul }}
{% endif %}
with {{ pform.errors }} to see that about field was causing it. I
overrid about field with tinymce
Thanks
This might have solved another issue i had not encountered yet, but it
did not solve my current issue :)
Form is still not valid and i have no idea why. If someone would tell
me how modelform error messages are supposed to be used, then they
might help me.
{% if
The method create_profile returns profile after saving. But this
object will not contain primary keys etc generated in the db. To work
around this common issue with django
profile.save()
# Get the data again from db.
profile = Profile.objects.get(user=username)
return profile
Let me know if
I figured ill add the code i have so far:
The models:
class ProfileManager(models.Manager):
def create_profile(self, username):
"Creates and saves a User with the given username, e-mail and
password."
now = datetime.datetime.now()
profile =
18 matches
Mail list logo