How to make a many to many or a foreign key not required in a model for django?
here is my model :
class Page(models.Model):
template = models.CharField(max_length=200,blank=True)
self_url = models.ForeignKey('liens.Lien',null=True,blank=True)
Categorie = models.ForeignKey(Categorie_Page,null=True,blank=True)
Liens = models.ManyToManyField('liens.Lien',related_name="Liens sur la page",null=True,blank=True)
Nom = models.CharField(max_length=200)
ImagesSite = models.ManyToManyField('presentation.ImageSite',null=True,blank=True)
Texte_contenu = models.ManyToManyField('presentation.Texte_contenu',null=True,blank=True)
Note_divers = models.ManyToManyField('notes.Note_diver开发者_运维技巧s',null=True,blank=True)
MiseEnForme = models.ManyToManyField('presentation.MiseEnForme',null=True,blank=True)
Menu = models.ManyToManyField('presentation.Menu',null=True,blank=True)
Avis = models.ManyToManyField('moteur.Avis',null=True,blank=True)
Regle = models.ManyToManyField('regles.Regle',null=True,blank=True)
Pack = models.ManyToManyField('moteur.Pack',null=True,blank=True)
Imageventes = models.ManyToManyField('moteur.ImageVente',null=True,blank=True)
Film = models.ManyToManyField('moteur.Film',null=True,blank=True)
ImageFilm = models.ManyToManyField('moteur.ImageFilm',null=True,blank=True)
ImageActeur = models.ManyToManyField('moteur.ImageActeur',null=True,blank=True)
generated = models.DateTimeField('date published',blank=True)
modified = models.DateTimeField('date modified',blank=True)
protege = models.BooleanField(blank=True)
and i want that all my field could be blank. How can i do that ?
I have :
pages_page.self_url_id may not be NULL
or this field is required so ...
Regards Bussiere
Set on the relevant fields null=True
and update your database.
It looks like you've already set null on self_url
, so the problem is that your database has not been updated with this nullable information. Syncdb will not update your tables!
run python manage.py reset myapp
(this will destroy / recreate your table)
精彩评论