-
Notifications
You must be signed in to change notification settings - Fork 4
Make it working in multiple admin sites context #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hi guys! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long wait and thank you for your contribution for the project! 🔥
We look forward for closing this PR!
| from django.apps import AppConfig | ||
| custom_admin_site = BaseAdminSite(name="custom_admin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like BaseAdminSite is not defined here
Please, add definition or import of BaseAdminSite to make the example more realistic (should be obvious it BaseAdminSite is existing class or defined by user)
| custom_admin_site = BaseAdminSite(name="custom_admin") | ||
| # ... | ||
| cutom_admin_site.register(ExportJob, ExportJobAdmin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| cutom_admin_site.register(ExportJob, ExportJobAdmin) | |
| custom_admin_site.register(ExportJob, ExportJobAdmin) |
| resource_class = resources.BookResource | ||
| If you use multiple or custom admin site, register required models to them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's provide a link to the Django Documentation about multiple/custom admin site (https://docs.djangoproject.com/en/stable/ref/contrib/admin/#customizing-the-adminsite-class)
| def get_form(self, request: WSGIRequest, obj=None, **kwargs): | ||
| """Push admin site to form.""" | ||
| form = super().get_form(request, obj, **kwargs) | ||
|
|
||
| form.admin_site = self.admin_site | ||
| return form |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really required? Why?
Please try to answer questions why? rather than what does it do? in docstring
We also made some changes to the admin mixins, so this logic can probably be put into BaseCeleryImportExportAdminMixin. Please check the latest changes when you get back to work
| r"^celery-import/(?P<job_id>\d+)/progress/$", | ||
| self.admin_site.admin_view(self.import_job_progress_view), | ||
| name="import_job_progress", | ||
| name= "import_job_progress", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| name= "import_job_progress", | |
| name="import_job_progress", |
TODO: