Форум сайта python.su
Привет.
Есть модели:
models.py
class PAttribute(models.Model):
cname = models.CharField(max_length=100)
surl = models.CharField(max_length=50)
class Profile(models.Model):
user = models.ForeignKey(User, unique=True)
pattribute = models.ManyToManyField(PAttribute)
# Добавляю запись в модель PAttribute
petite = PAttribute(cname='cname',surl='surl').save()
# Добавляю запись в модель профиля
profile = Profile(user=user,pattribute=petite)
profile.pattribute.add(petite)
profile.save()
Офлайн
Полагаю так
petite = PAttribute(cname='cname',surl='surl').save()
profile = Profile(user=user)
profile.pattribute.add(petite)
profile.save()
Офлайн