Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
django get lazy reference by Model

To get model from lazy reference, we can do

from django.apps import apps
Article = apps.get_model('articles.Article') 
# app.Model

But what about the reverse for it? I mean to get the lazy reference app.Model by Model class.

from articles.models import Article
# something like
print(Article.lazy_reference)
# <str> articles.Article

you probably wonder why I do this, I need to tract user initiative and passive actions, there's no modelfield in django, hence I store the model reference and pk as indication.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use the meta options,

model_meta = Article._meta

lazy_ref = f"{model_meta.object_name}.{model_meta.app_label}"
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!