Thanks for getting back to me. You're correct -- that article is not a one-for-one match when compared to my problem, so let me tweak my question.
When I attempt to save (my_form.save()) and I leave the zip code field blank, I receive the following exception: DataError at /person/new/add/ invalid input syntax for integer: "" When I look at the insert statement, sure enough, an empty string is attempting to make its way into my zip code field. With that being said, do you expect that behavior? If not, how can I correct the issue? If you do expect that behavior, how can I go about creating a NullIntegerField? This is new territory for me. On Jun 25, 4:28 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote: > Huuuze wrote: > > I have defined a zip code field as follows in my Address model: > > > zip = models.IntegerField(blank=True, null=True) > > > Being a good Djangonaut, I'm using a ModelForm to convert my address > > model into HTML. Now this where things get dicey. As you can see in > > the model, zip code can except empty values. Unfortunately, when I > > attempt to save data entered by a user who has left the zip code field > > blank, I receive a database exception. Apparently, Django is > > attempting to insert an empty string into my integer-only field. > > > From what I can tell, this particular topic has been discussed > > previously: > > >http://www.hoboes.com/Mimsy/?ART=595 > > > Is the solution outlined in the blog post above the long-term solution > > for Django developers or are there plans to have a ModelForm > > understand that I would not want to insert an empty string into an > > integer field? > > Are you sure it happens in IntegerFields, that's surprising. That blog > is talking about CharFields for which saving "" for None is less surprising. > > Instead of mucking with model's save method I'd create my own field, > NullCharField or NullIntegerField that replaces "" or None with NULL > according to the null=true parameter. > > -- > Norman J. Harman Jr. > Senior Web Specialist, Austin American-Statesman > ___________________________________________________________________________ > You've got fun! Check out Austin360.com for all the entertainment > info you need to live it up in the big city! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---