Hi,
I'm trying to implement a recursive relationship with a foreignkey, but I
failed to make it work.
My goal is to have a table containing different categories and sub categories
of equipment. the relationship with 'self' is for the subcategories.
But I can't create the Master categories. here's my error:
Traceback (most recent call last):
File
"/usr/lib/python2.5/site-packages/django/core/handlers/base.py",
line 77, in get_response
response = callback(request, *callback_args,
**callback_kwargs)
File
"/usr/lib/python2.5/site-packages/django/contrib/admin/views/decorators.py",
line 55, in _checklogin
return view_func(request, *args, **kwargs)
File
"/usr/lib/python2.5/site-packages/django/views/decorators/cache.py",
line 39, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File
"/usr/lib/python2.5/site-packages/django/contrib/admin/views/main.py",
line 261, in add_stage
new_object = manipulator.save(new_data)
File
"/usr/lib/python2.5/site-packages/django/db/models/manipulators.py",
line 110, in save
new_object.save()
File
"/usr/lib/python2.5/site-packages/django/db/models/base.py",
line 247, in save
','.join(placeholders)), db_values)
File "/usr/lib/python2.5/site-packages/MySQLdb/cursors.py",
line 164, in execute
self.errorhandler(self, exc, value)
File
"/usr/lib/python2.5/site-packages/MySQLdb/connections.py", line
35, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1048, "Column 'parent_id' cannot be null")
here's my object :
class Category(models.Model):
name = models.CharField(max_length=36)
description = models.CharField(max_length=200)
parent = models.ForeignKey('self',blank=True)
class Admin:
# Admin options go here
pass
If I dont use blank=True, the admin interface doesn't let me add the category,
otherwise I received the error.
Any help would be appreciated.
Thank you
Francis
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---