missing a 'blank=True'
--
For far too long, power has been concentrated in the hands of "root"
and his "wheel" oligarchy. We have instituted a dictatorship of the
users. All system administration functions will be handled by the
People's Committee for Democratically Organizing the System (PC-DOS).
> now, this is driving me crazy. this problem persists even after
> switching from 0.96.1 to the newforms-admin branch.
>
> after declaring a model class with an attribute that may be null (pn)
> the admin site still tells me to fill in that field, because "This field
> is required.", but it isn't.
>
> i have registered the model class to the admin site without any custom
> options.
>
> recreated the database file (sqlite) after switching to the na branch.
>
> checked in SQLite Manager that the pn field may indeed be null.
>
> new Dossier instances can be created and saved in the shell without the
> pn attribute, but when viewing the instance on the admin page and
> pressing Save, the error appears.
>
> what is the matter?????
http://www.b-list.org/weblog/2006/jun/28/django-tips-difference-between-blank-and-null/
--
Jarek Zgoda
Skype: jzgoda | GTalk: zg...@jabber.aster.pl | voice: +48228430101
"We read Knuth so you don't have to." (Tim Peters)
> after declaring a model class with an attribute that may be null
> (pn) the admin site still tells me to fill in that field, because
> "This field is required.", but it isn't.
have you set blank=True?
--
regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/
You also need blank=True here:
pn = models.CharField('Publication number', max_length=20, null=True)
That will fix you :-)
Ben
Andre Meyer wrote:
> hi all
>
> now, this is driving me crazy. this problem persists even after
> switching from 0.96.1 to the newforms-admin branch.
>
> after declaring a model class with an attribute that may be null (pn)
> the admin site still tells me to fill in that field, because "This
> field is required.", but it isn't.
>
> i have registered the model class to the admin site without any custom
> options.
>
> recreated the database file (sqlite) after switching to the na branch.
>
> checked in SQLite Manager that the pn field may indeed be null.
>
> new Dossier instances can be created and saved in the shell without
> the pn attribute, but when viewing the instance on the admin page and
> pressing Save, the error appears.
>
> what is the matter?????
>
> thanks for your suggestions
> cheers
> André
>
>
> code:
>
> /model.py
> /
> class Dossier(models.Model):
> an = models.CharField('Dossier number', max_length=10,
> primary_key=True)
> pn = models.CharField('Publication number', max_length=20, null=True)
>
> def __unicode__(self):
> return self.an <http://self.an>
>
> admin.site.register(Dossier)
>
>
> >
> still need to figure out why ;-)
by default, django treats all fields as not null and not blank.
Usually, the 'null' part is enforced at the database level and the
'blank' part at django level. So for fields like CharFields, saying
null is allowed is not the same as saying blank is allowed.