HI,

One more question

How do  i update a manytomany field which is  a self referential field ie
it points to the same table.
Consider for example facebooksession contains a field called friends

 friends =
models.ManyToManyField("self",db_column='uid',blank=True,null=True)

On Sun, Mar 18, 2012 at 4:08 PM, dummyman dummyman <tempo...@gmail.com>wrote:

> thnk u very much i got it :)
>
>
> On Sun, Mar 18, 2012 at 3:57 PM, Ian Lewis <ianmle...@gmail.com> wrote:
>
>> 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.
>>
>>
>

-- 
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