Skip to content

Conversation

@ClanEver
Copy link
Contributor

Closes #394

I have tested using field.name for field in self.model._meta.fields on both the original model and the proxy model, and it works as expected.

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for handling it. is there any way to verify the change? tests, screenshots etc?

@ClanEver
Copy link
Contributor Author

I have added tests. The results before and after the modification are as follows:

Before the modification:

pytest t/unit/test_admin.py
============================= test session starts ==============================
platform linux -- Python 3.13.2, pytest-7.4.4, pluggy-1.6.0
django: version: 5.2.5, settings: t.proj.settings (from ini)
benchmark: 5.0.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/clanever/dev/python/django-celery-results
configfile: setup.cfg
plugins: django-4.11.1, benchmark-5.0.1
collected 4 items

t/unit/test_admin.py ..FF                                                [100%]

# Omitting lengthy FAILURES here

=========================== short test summary info ============================
FAILED t/unit/test_admin.py::TaskResultProxyAdminTests::test_add_view - django.core.exceptions.FieldError: 'result' cannot be specified for TaskResultProxy model form as it ...
FAILED t/unit/test_admin.py::TaskResultProxyAdminTests::test_change_view - django.core.exceptions.FieldError: 'result' cannot be specified for TaskResultProxy model form as it ...
========================= 2 failed, 2 passed in 2.51s ==========================

After the modification:

pytest t/unit/test_admin.py
========================================== test session starts ===========================================
platform linux -- Python 3.13.2, pytest-7.4.4, pluggy-1.6.0
django: version: 5.2.5, settings: t.proj.settings (from ini)
benchmark: 5.0.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/clanever/dev/python/django-celery-results
configfile: setup.cfg
plugins: django-4.11.1, benchmark-5.0.1
collected 4 items                                                                                        

t/unit/test_admin.py ....                                                                          [100%]

=========================================== 4 passed in 2.65s ============================================

tox has also passed.

@auvipy
Copy link
Member

auvipy commented Aug 16, 2025

please check the failing test

@ClanEver ClanEver force-pushed the main branch 3 times, most recently from 098afd2 to 6628e76 Compare August 16, 2025 19:32
@ClanEver
Copy link
Contributor Author

I've tried to fix it. Please let me know if any improvements are needed.

@auvipy auvipy requested a review from Copilot October 2, 2025 11:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an error that occurs when registering TaskResultAdmin on a Django proxy model by changing the field reference from self.opts.local_fields to self.model._meta.fields.

  • Updates the get_readonly_fields method in TaskResultAdmin to use the correct field reference for proxy models
  • Adds comprehensive test coverage for both regular and proxy model scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
django_celery_results/admin.py Fixed field reference in get_readonly_fields method to work with proxy models
t/unit/test_admin.py Added test cases for TaskResultAdmin functionality with both regular and proxy models

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@auvipy auvipy merged commit 9b067cc into celery:main Oct 2, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants