Hi,
On 16/07/14 21:53, Pepsodent Cola wrote:
> Hi,
> I have been learning and developing my first Django project in Linux
> Mint 14 for about 2 years. This month I moved my Django project files
> to Linux Mint 17.
> When I run my unit tests then I get this error, which I don't remember
> having when I was testing code in Linux Mint 14.
>
> *IntegrityError: NOT NULL constraint failed:*
> userprofile_userprofile.likes_cheese
>
>
> NOT NULL constraint failed
> I try to change the old code from this.
>
> class UserProfile(models.Model):
> user = models.OneToOneField(User)
> likes_cheese = models.*BooleanField()*
> favourite_hamster_name = models.CharField(max_length=50)
>
It sounds looks like your operating system upgrade has upgraded Django
to 1.6. In Django 1.6 you need to explicitly set default=False on your
boolean fields, otherwise they default to None
> likes_cheese = models.BooleanField(default=False)
For more info see the release notes [1]. It would be worth going through
them to see if there are any other changes you should or need to make.
[1]:
https://docs.djangoproject.com/en/dev/releases/1.6/#booleanfield-no-longer-defaults-to-false
Cheers,
Alasdair
--
Alasdair Nicol
Developer, MEMSET
mail:
alas...@memset.com
web:
http://www.memset.com/
Memset Ltd., registration number 4504980.
Building 87, Dunsfold Park, Stovolds Hill, Cranleigh, Surrey, GU6 8TB, UK