You need to also state that null=True. Also, you want to have ensure that
the field defined in your db
allows null values.

On Mon, Jun 28, 2010 at 3:19 PM, Jonathan Hayward <
[email protected]> wrote:

> I have a model with two foreign keys to itself:
>
>     department = models.ForeignKey(u'self', blank = True, related_name =
> u'member')
>     reports_to = models.ForeignKey(u'self', blank = True, related_name =
> u'subordinate')
>
> When I tried to save test data from the admin interface, leaving those
> items blank, I got a ValueError, pasted below. What do I need to be able to
> save test data? I'm willing to assign non-blank values to those fields for
> now, but there's a chicken-and-egg problem if the admin interface won't let
> me save any instances until I already have an instance saved.
>
>  ValueError at /admin/directory/entity/add/
>
> Cannot assign None: "Entity.department" does not allow null values.
>
>   Request Method: POST Request URL:
> http://linux:8000/admin/directory/entity/add/ Exception Type: ValueError 
> Exception
> Value:
>
> Cannot assign None: "Entity.department" does not allow null values.
>
>  Exception Location: 
> /usr/lib/pymodules/python2.6/django/db/models/fields/related.py
> in __set__, line 269 Python Executable: /usr/bin/python Python Version:
> 2.6.5 Python Path: ['/home/jonathan/directory',
> '/usr/local/lib/python2.6/dist-packages/pip-0.6.3-py2.6.egg',
> '/home/jonathan/store/src/satchmo/satchmo/apps',
> '/usr/local/lib/python2.6/dist-packages/django_threaded_multihost-1.3_3-py2.6.egg',
> '/usr/local/lib/python2.6/dist-packages/django_signals_ahoy-0.1_1-py2.6.egg',
> '/usr/local/lib/python2.6/dist-packages/django_tagging-0.3.1-py2.6.egg',
> '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2',
> '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old',
> '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages',
> '/usr/lib/python2.6/dist-packages/PIL',
> '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6',
> '/usr/lib/python2.6/dist-packages/gtk-2.0',
> '/usr/lib/pymodules/python2.6/gtk-2.0',
> '/usr/local/lib/python2.6/dist-packages'] Server time: Mon, 28 Jun 2010
> 15:13:53 -050
>
> --
> → Jonathan Hayward, [email protected]
> → An Orthodox Christian author: theology, literature, et cetera.
> → My award-winning collection is available for free reading online:
> ☩ I invite you to visit my main site at 
> http://JonathansCorner.com/<http://jonathanscorner.com/>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<django-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
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.

Reply via email to