Monday, November 21, 2016

help for creating relationship between User model an another model !!

Hi django users,
I am new to django and i am using django 1.10, i follow up all the tutorial in the documentation and now i have build an blog application with models like :
Article , Commentaire(comment in english) and Tag. It's working but now i want to add an relation between User (the one who is connected and creating the article)
and the Article but i dont know how to do this . I find on google and try what i see but nothing ran ,
this is my code
Saisissez le code ici.
from django.contrib.auth.models import User


class
Article(models.Model):
    titre
= models.CharField(max_length=254)
    description
= models.TextField()
    contenu
= models.TextField()
    date_publication
= models.DateField()
    image
= models.ImageField(upload_to='blog/static/blog/images/')
    publie
= models.BooleanField(default=False) # par defaut un article n'est pas publier
    tag = models.ManyToManyField(Tag)
    auteur
= models.ForeignKey('auth.User', verbose_name='auteur', default=1)# here is the relationshp creation


..
And when i run
python manager.py migrate

it give me a long error message with at the end of it :
TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime'
Saisissez le code ici...
Please help i dont know how to do !!!



--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f724cc4b-def2-403e-a366-16eb5d7dc85d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment