Hi,

I'm having problems validating a form for the below models. Multiple
null values in the below "Thing" model's "other" column seem to
prevent the basic ModelForm from validating. This also happens for
OneToOneFields of the same nature. Normal django db api functions and
the database do not seem to have any problem. I also tried this in an
older revision of django (using form_for_model) and had no problems
there.

Is this a known issue? It seems really basic.

---
class OtherThing(models.Model):
    pass

class Thing(models.Model):
    other = models.ForeignKey('OtherThing', null=True, blank=True, unique=True)

>>> import django
>>> django.get_version()
>>> from django.forms import ModelForm
>>> from test.models import *
>>>
>>> class ThingForm(ModelForm):
...   class Meta:
...     model = Thing
...
>>> Thing.objects.all()
[]
>>> ThingForm({}).save()
<Thing: Thing object>
>>> ThingForm({}).save()
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "/home/griswold/lib/python/django/forms/models.py", line 302, in save
    return save_instance(self, self.instance, self._meta.fields,
fail_message, commit)
  File "/home/griswold/lib/python/django/forms/models.py", line 36, in
save_instance
    raise ValueError("The %s could not be %s because the data didn't"
ValueError: The Thing could not be created because the data didn't validate.
>>>
>>> Thing.objects.create()
<Thing: Thing object>
>>> Thing.objects.create()
<Thing: Thing object>
>>> Thing.objects.all()
[<Thing: Thing object>, <Thing: Thing object>, <Thing: Thing object>]

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to