دنبال کننده ها

۱۳۹۶ اسفند ۱۳, یکشنبه

python - Filter the objects shown in django admin inline

[ad_1]



I am trying to filter the objects shown in the django inline admin.



Let's say I have a model class Article:



#models.py
class Article(models.Model):
#some fields


If the class Article is used as an Inline somewhere, I do not want the Users(Editors) to be able to see all of the Articles, but to filter them out according to a certain criteria (a pseudo example would be if the Articles have a type field and certain editors are allowed to see only certain types, e.g sport articles, news articles etc.)



Reading the documentation of django, I found get_formsets_with_inlines and get_inline_instances, which I do not find any difference in and after trying to edit them, I did not succeed.



Can I filter out the objects shown in the inlines by overriding a certain function or should I consider something else?




[ad_2]

لینک منبع