Skip to content
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

Make it working in multiple admin sites context #59

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maisim
Copy link

@maisim maisim commented Oct 25, 2024

TODO:

  •  Add tests
  •  Update docs

@maisim
Copy link
Author

maisim commented Oct 25, 2024

Hi guys!
I won't have time to continue this next week but feel free to comment

Copy link
Contributor

@NikAzanov NikAzanov left a 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")
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cutom_admin_site.register(ExportJob, ExportJobAdmin)
custom_admin_site.register(ExportJob, ExportJobAdmin)

@@ -121,6 +121,24 @@ Prepare view sets to import/export via API
resource_class = resources.BookResource


If you use multiple or custom admin site, register required models to them
Copy link
Contributor

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)

Comment on lines +45 to +50
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
Copy link
Contributor

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

self.admin_site.admin_view(self.import_job_progress_view),
name="import_job_progress",
name= "import_job_progress",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
name= "import_job_progress",
name="import_job_progress",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants