2👍
I don’t know why you say you don’t have a relationship between those two models. You do: it just uses an char field rather than an ID. That’s still a perfectly valid foreign key. You should declare your UserDomain like this:
class UsersDomains(models.Model):
domain_email = models.ForeignKey(Users, to_field='email', null=True)
and also add unique=True
to the Users.domain field, and now Django will automatically do the right thing.
0👍
maybe this could help –
http://www.caktusgroup.com/blog/2009/09/28/custom-joins-with-djangos-queryjoin/
basically it’s just using the queryset.query.join
to add whatever join you want..
- [Answered ]-After change class function doesn't work
- [Answered ]-Q object (creating it with OR connection type at once)
Source:stackexchange.com