Django Admin, Show Aggregate Values From Related Model -


Is it possible, within a single Django adapter model, to collect fields from related objects < P> For example, I have a student object that has a test object for a fiction. The test object has the "score" field

Can I score points in all the students' exams and put it in the admin display_list attribute?

For example: class fixturesman (admin.modeladmin) : List_desp = ["id", "title", "date", "number_fine_matmount"] def queries (self, request): qs = super (fixtureAdmin, self) .queryset (request) return qs.annotate (num_fixture_metas = count ( 'Fixturemeta')) DEF num_fixture_metas_count (auto, obj): return obj.num_fixture_metas num_fixture_metas_count.short_description = 'stability calculation' num_fixture_metas_count.admin_order_field = 'num_fixture_metas'

However, AFAIK, You type this method, Can not click on these areas through the administrator in the form of num_fixture_metas from to .notate () to missing the list_display result The region is in error.



Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -