Hi,

facebook_session.books_name is a RelatedManager on the Books model class.

You need to add books to the list with the add() method.

book = Books(book_name="name", book_category="category")
book.save()
facebook_session.books_name.add(book)

See:
https://docs.djangoproject.com/en/1.3/ref/models/relations/#django.db.models.fields.related.RelatedManager.add

On Sun, Mar 18, 2012 at 4:41 PM, dummyman dummyman <tempo...@gmail.com> wrote:
> Hi
>
> I ve to models
>
> class FacebookSession(models.Model):
>
>     access_token = models.CharField(max_length = 250,unique=True)
>     expires = models.IntegerField(null=True)
>
>     user = models.ForeignKey(User, null=True)
>     uid = models.BigIntegerField(unique=True, null=True)
>
>     birthday = models.DateField(blank=True,null=True)
>     name = models.CharField(max_length=100,blank=True,null=True)
>
>     books_name = models.ManyToManyField(Books,blank=True,null=True)
>
>
> lass Books(models.Model):
>
>      book_name = models.CharField(max_length=100)
>      book_category = models.CharField(max_length=100,blank=True,null=True)
>
>      def __unicode__(self):
>          return self.book_name
>
>
>
> now i want to have a list of books in a list called books_list
>
> How to store those in the database
>
> I understood how to store basic_fields
>
>
> database_obj = FacebookSession.objects.get(uid=123444)
> database_obj.name="ss"
>
> database_obj.save()
>
> How do i do the same thing for books_name which is a many to many field in
> FacebookSession class
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



-- 
Ian

http://www.ianlewis.org/

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to