On Sun, 2007-08-19 at 18:41 -0400, Francis Lavoie wrote:
> Hi,
> 
> I still have this error with null=True .
> 
> model.py: 
> class Category(models.Model):
>     name = models.CharField(max_length=36)
>     description = models.CharField(max_length=200)
>     parent = models.ForeignKey('self', null=True, blank=True)
> 
>     class Admin:
>         # Admin options go here
>         pass
> 
> then I did (to reset de database) : python manage.py flush 
> 
> and `python manage.py sql myapp` returns :
> 
> BEGIN;
> CREATE TABLE `myapp_category` (
>     `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
>     `name` varchar(36) NOT NULL,
>     `description` varchar(200) NOT NULL,
>     `parent_id` integer NULL
> )
> ;
> ALTER TABLE `myapp_category` ADD CONSTRAINT
> parent_id_refs_id_5d9ae1d8600b3d85 FOREIGN KEY (`parent_id`)
> REFERENCES `myapp_category` (`id`);

That should work perfectly. It's the standard setup for a tree-like
model structure. The database table also looks correct. Try creating the
models from scratch in a separate project or application and I'll think
you'll find it will work. It sounds like there is something going wrong
from your earlier failed attempts.

Regards,
Malcolm

-- 
I don't have a solution, but I admire your problem. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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