Использование python3.4 django 2.0.2
models.py
class Userinfo(models.Model):
useruid = models.BigAutoField(db_column='UserUID', primary_key=True)
useremail = models.CharField(
db_column='UserEmail', unique=True, max_length=100)
userpassword = models.CharField(db_column='UserPassword', max_length=128)
passwordsalt = models.CharField(db_column='PasswordSalt', max_length=128)
userstatus = models.IntegerField(db_column='UserStatus', default=0)
username = models.CharField(
db_column='UserName', max_length=100, default=0)
class Meta:
managed = False
db_table = 'userinfo'
class Postinfo(models.model):
postuid = models.BigAutoField(db_column='PostUID', primary_key=True)
content = content = models.TextField(db_column='Content')
useruid = models.ForeignKey(
Userinfo, db_column='UserUID', on_delete=models.CASCADE)
class Meta:
managed = False
db_table = 'postinfo'
QuerySet
postquery = models.Postinfo.objects.all().select_related("useruid").order_by(
'-postuid')
пост-запрос
<QuerySet [{'content': 'test','postuid': 1, 'useruid_id': 1},OtherPosts...>
и
userinfoquery = postquery.values("useruid_id__username","useruid_id__userstatus","useruid_id")
userinfoquery -
<QuerySet [{'useruid_id__username': 'firstuser','useruid_id__userstatus': 0, 'useruid_id': 1},OtherUsers...>
я хочу useruid_id__username -> username
useruid_id__userstatus -> userstatus
useruid_id -> useruid
я попробовал это
userinfoquery = postquery.values(
useruid="useruid_id", username="useruid_id__username", userstatus="useruid_id__userstatus")
этот код вызывает исключение
QuerySet.annotate() received non-expression(s): useruid_id, useruid_id__uesrname, useruid_id__userstatus.
как можно удалить useruid_id__