agateblue / django-dynamic-preferences

Dynamic global and instance settings for your django project
https://django-dynamic-preferences.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
350 stars 87 forks source link

URL access via Swagger #256

Closed g-normand closed 2 years ago

g-normand commented 2 years ago

Hello,

I try to use dynamic-preferences but I can't access to UserPreferences easily via Swagger.

In urls.py, I added:

router = routers.SimpleRouter()
router.register(r'user-preferences', UserPreferencesViewSet, 'user')
...
URLS_VM3.append(url(r'^', include(router.urls)))

So, I got it in Swagger: Capture d’écran du 2021-12-16 10-54-15

I can access to the list : Capture d’écran du 2021-12-16 10-56-59

=> First of all, I have access to the UserPreference, but without the ID necessary for modification/access

In the admin area, I got the ID : 2 (http://127.0.0.1:8004/admin/dynamic_preferences_users/userpreferencemodel/2/change/ is the URL to change it)

But I can't access or add an UserPreference: Capture d’écran du 2021-12-16 10-58-06

Is there something that I'm doing wrong? Or is it a bug? Thanks Guillaume

agateblue commented 2 years ago

As far as I can remember, you need to use the identifier field (e.g user__notifications_enabled) in the URL. We don't rely on numeric IDs there, so that you can update/set any preference knowing only its string identifier.