ambient-innovation / django-dynamic-admin Goto Github PK
View Code? Open in Web Editor NEWEnable interactive selects in django-admin
Home Page: https://pypi.org/project/django-dynamic-admin-forms/
License: MIT License
Enable interactive selects in django-admin
Home Page: https://pypi.org/project/django-dynamic-admin-forms/
License: MIT License
It would be nice to have ability to make ChoiceField dynamic (to handle choices)
The installation guide mentions adding dynamic_admin_forms.urls
to urls.py
.
However, doing this will mean that the URL can be accessed by anyone, even those who are not admin users. This will render the widget in the browser and potentially expose sensitive information.
I have modified the package to define the URLs within a custom admin site:
class CustomAdminSite(AdminSite):
def get_urls(self):
urls = super().get_urls()
my_urls = [
path("dynamic-admin-form/<app_label>/<model_name>/<field_name>/",
self.admin_view(CustomDynamicModelAdminMixin.render_field))
]
return my_urls + urls
Wrapping the view in self.admin_view
adds Django's security checks, meaning only users with access to the admin dashboard can call the URL.
I needed to modify the mixin to target the custom admin site, rather than the default, and the JS file to reflect the new admin URL.
The url currently used is hard coded. We should be able to let the user set the whole url or at least a prefix.
It makes sense to have GET requests sent to this url /admin/dynamic-admin-form/?${params}
Currently, select2 widgets will be replaced by normal select elements when the field rerenders. It would however be nice to update the widgets option instead of replacing it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.