Django, models. How to make a link to model field to the field value of another model?

0 like 0 dislike
3 views
The structure of the models:

class Profile (models.Model): user = models.ForeignKey(MyUser) university = models.CharField(max_length=512) #... class Stream (models.Model): #... class Enty (models.Model): stream = models.ForeignKey(Stream) entry = (max_length=512) ...


The structure fully meets its mandated tasks, namely adding, editing and deleting records. It's all on the user interaction with the database.

But there's still the backside of the analysis of the administrator records the Entry in connection with field university. That is, the administrator via a special interface makes a request to the records Enty for some stream and it does not matter the identity of the user and the relationship between the entries. The subject of consideration is only the connection of stream - entry - university.
that is
class Enty (models.Model): stream = models.ForeignKey(Stream) entry = (max_length=512) university = #link to Profile.university ...

is it possible to implement this link?

Yes, you can make university Entry field in the text each time you create a record Enty to write down the value of university of Profile, but it is not cool.
by | 3 views

1 Answer

0 like 0 dislike
Not very clear, a link to what you want in your circuit, if you have the relation user - profile one-to-many. But even if a user field in the Profile would be a OneToOneField, I do not sure that Jankowski ORM it is possible for one request to catch up with university of Profile. In pure SQL it would be possible to write a query that sjajnu Entry for user_id and Profile.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 20, 2019 by i_egor
110,608 questions
257,186 answers
0 comments
28,697 users