Hi guys,

I want to make some simple relationship models about relations between
users. I have this model:

class Relation(models.Model):
        user = models.ForeignKey(User)
        relation = models.ManyToManyField(User, related_name="relations")
        type = models.ForeignKey(RelationshipType, blank=False)

        def __unicode__(self):
                return self.name

The User is user model from django.auth app.

I've try simple add a new user and make a relation between the logged-
in user and the new:

u = User.objects.create_user('proba9', 'pr...@abv.bg', 'probapass')
u.save()
u = User.objects.using("default").get(pk=u.pk)
usr = request.user
ru = RelationshipType.objects.get(pk='1')
r = Relation(usr,ru)
r.relation.add(u)
r.save()

After r.relation.add(u) django rise me this error:

Cannot add "<User: proba9>": instance is on database "None", value is
on database "default"

I have only one DB in settings.py and it's a mysql and it's with label
default. After the execution of the code the new user is created, but
the relation couldn't.

I have contact with some friends with more experience than me and they
think that this can be bug in Django. My currently version of Django
is 1.2.1.

If someone can help me I'll be very thankful.

Best, Tihomil Kulev!

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