Cannot assign None, does not allow null values

211 views
Skip to first unread message

onoxo

unread,
Nov 27, 2009, 4:57:13 PM11/27/09
to Django users
i get this error when i try to create new item in admin site.

here is my models.py
import datetime
from django.db import models
from tinymce import models as tinymce_models
from filebrowser.fields import FileBrowseField

class ItemWithMedia(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)

class Actual(ItemWithMedia):
published = models.DateField('Published')
title_hr = models.CharField('(hr)', max_length=200)
title_en = models.CharField('(en)', max_length=200)
body_text_hr = models.TextField('(hr)')
body_text_en = models.TextField('(en)')

def __unicode__(self):
return self.title_hr

class Meta:
verbose_name = "Aktualno"
verbose_name_plural = "Aktualni"
ordering = ['-published']

what could be the problem?

onoxo

unread,
Nov 27, 2009, 5:27:24 PM11/27/09
to Django users
btw. here is a full code:

models.py
http://snipt.net/vedran/django-models-cannot-assign-none?key=ba151d53cbe8e7c6fd8cfd7993c72897

admin.py
http://snipt.net/vedran/django-admin-cannot-assign-none?key=53222b89cf415d0a0a7750f1510ab8a1

so... when i go to create new Actual item i get this error:
Cannot assign None: "Actual.published" does not allow null values.

Tim Valenta

unread,
Nov 27, 2009, 9:32:28 PM11/27/09
to Django users
You've got a lot of models in that file. Which one are you trying to
save when it throws the error?

By the way, I notice that your "ItemWithMedia" class is probably
creating a database table.. if you never need to manipulate it direct
(ie, you only make subclasses of it), I might suggest putting this in
the definition:

class ItemWithMedia(models.Model):
# ... all of your old stuff goes here
class Meta:
abstract = True

That way Django knows it's just a base class.

Not sure what the problem is, yet...

On Nov 27, 3:27 pm, onoxo <vedran.ko...@gmail.com> wrote:
> btw. here is a full code:
>
> models.pyhttp://snipt.net/vedran/django-models-cannot-assign-none?key=ba151d53...
>
> admin.pyhttp://snipt.net/vedran/django-admin-cannot-assign-none?key=53222b89c...

onoxo

unread,
Nov 28, 2009, 3:07:43 AM11/28/09
to Django users
Hi!

when i go to create Actual class. i get this error:
Cannot assign None: "Actual.published" does not allow null values.

and it makes this error with each class that has published propertie.

Martin Lundberg

unread,
Nov 28, 2009, 5:20:29 AM11/28/09
to django...@googlegroups.com
Is it not that you forget to give the published property a value?

--

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



Reply all
Reply to author
Forward
0 new messages