0

I want Foo.objects.all() order by Bar.order

Two tables connect by ryid fields without foreign key.

The database I got like this, I cannot set ryid it to foreign key.


class Foo(models.Model):
    lsid = models.AutoField(db_column='Lsid', primary_key=True)
    ryid = models.IntegerField(db_column='Ryid', blank=True, null=True)

class Bar(models.Model):
    lsid = models.AutoField(db_column='Lsid', primary_key=True)
    ryid = models.IntegerField(db_column='Ryid', blank=True, null=True)
    order = models.IntegerField(db_column='Wzpx', blank=True, null=True)
wgf4242
  • 575
  • 2
  • 9
  • 16
  • 1
    check this question: https://stackoverflow.com/questions/19590483/django-queryset-join-without-foreignkey – mrash Oct 12 '21 at 02:14

0 Answers0