You're absolutely right.
I don't know what I was thinking.
Thanks!
On Dec 7, 8:42 pm, Shawn Milochik wrote:
> On Dec 7, 2009, at 7:16 PM, Continuation wrote:
>
>
>
> > I thought if form.is_valid() returns False, Django would send a list
> > of the errors to browser. But
On Dec 7, 2009, at 7:16 PM, Continuation wrote:
>
> I thought if form.is_valid() returns False, Django would send a list
> of the errors to browser. But that's not what happened here.
Do you have anything like these in your template?
{{ my_form.errors }}
{{ my_form.field_name.errors }}
Shawn
Hi,
Thank you very much for your help.
I used your form validation method.
The results is weird.
I tested it with a value lower than the previous value. But didn't see
any error message in my browser.
I stepped through the code using pdb. I could see that
forms.ValidationError("The amount in
On Dec 6, 2009, at 11:01 PM, Continuation wrote:
> What do you mean by the __init__ of the model?
>
Every models.Model object has an __init__ function, like any Python class. You
need to override it.
Add this into your model (in your models.py):
def __init__(self, *args, **kwargs):
What do you mean by the __init__ of the model?
My directory structure is:
myapp/models
MyModel lives inside myapp/models.
There's an __init__.py file within myapp, but it's empty and I've
never touched it.
Can you be more specific about what to do? Thanks.
On Dec 6, 10:52 pm, Shawn Milochik
The easiest way I know of is this:
In the __init__ of the model, create a variable: self.old_value =
self.fieldname.
In the save() function, you can check self.fieldname against self.old_value.
Shawn
--
You received this message because you are subscribed to the Google Groups
"Django
I created a form class based on a model:
class MyModel(models.Model):
increasing_field = models.PositiveIntegerField()
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
I created a form to change an existing MyClass instance using POST
data to populate the
7 matches
Mail list logo