Did Ubuntu 14.04 or Linux Mint 17 break your Django project files?

77 views
Skip to first unread message

Pepsodent Cola

unread,
Jul 16, 2014, 4:53:42 PM7/16/14
to django...@googlegroups.com
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)

To this.

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    likes_cheese = models.NullBooleanField()
    favourite_hamster_name = models.CharField(max_length=50)

But then all kinds of different stuff in the project breaks.  Which makes me suspect that nothing was wrong with my code to begin with, that perhaps the change of operating system has caused this error.

Did Ubuntu 14.04 or Linux Mint 17 break your Django project files also?



admin.TabularInline
Also I think Linux Mint 17 broke admin.py's TabularInline function because now the fields looks stacked instead.  I'm not sure if this has anything to do with my operating system switch.  Or if it's because of my recent experimentations with overriding certain parts of the admin template.

class UserProfileInline(admin.TabularInline):
    model = UserProfile
    extra = 1

Did Ubuntu 14.04 or Linux Mint 17 break your Django admin?



Bill Freeman

unread,
Jul 16, 2014, 5:01:48 PM7/16/14
to django-users
I make it a point to never use a python build that comes from a .deb for any real development.

The OS vender may require certain python features for its management scripts, but I don't like my development tools changing out from under me.

Build yourself a python from source, putting it some where in, say, /opt then modify your PATH in .bashrc to find yours first (or only).

Then always develop in in virtualenv (based on your python) and no dist-packages directories about it.

If you need to install something in python, use pip, never apt-get (though you may need apt to install C library dependencies.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f0b3c781-e088-4ba1-a251-8e78795fd0f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Stein

unread,
Jul 16, 2014, 5:06:11 PM7/16/14
to django...@googlegroups.com
IntegrityError is at the database level (not the OS).  Shouldn't have anything to do with the OS specifically.  Has the database you are using changed?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f0b3c781-e088-4ba1-a251-8e78795fd0f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Adam (ad...@csh.rit.edu)

Alasdair Nicol

unread,
Jul 16, 2014, 5:34:15 PM7/16/14
to django...@googlegroups.com
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

Pepsodent Cola

unread,
Jul 16, 2014, 7:11:20 PM7/16/14
to django...@googlegroups.com
Thanks, it was a Django 1.6 issue.  Problem solved now.
Reply all
Reply to author
Forward
0 new messages