{"id":26902,"library":"django-dynamic-preferences","title":"django-dynamic-preferences","description":"Dynamic global and instance settings for your Django project. Version 1.17.0. Release cadence: infrequent, last updated in 2023.","status":"maintenance","version":"1.17.0","language":"python","source_language":"en","source_url":"https://github.com/agateblue/django-dynamic-preferences","tags":["django","preferences","settings","dynamic"],"install":[{"cmd":"pip install django-dynamic-preferences","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"Core dependency","package":"django","optional":false},{"reason":"Required for storing preference values","package":"django-picklefield","optional":false},{"reason":"Python 2/3 compatibility (may be removed in future)","package":"six","optional":true}],"imports":[{"note":"Common mistake: the mixin is in users.mixins, not directly in dynamic_preferences.","wrong":"from dynamic_preferences.mixins import DynamicPreferencesMixin","symbol":"DynamicPreferencesMixin","correct":"from dynamic_preferences.users.mixins import DynamicPreferencesMixin"},{"note":"Misspelling registry as registry.","wrong":"from dynamic_preferences.registry import global_preferences_registry","symbol":"global_preferences_registry","correct":"from dynamic_preferences.registries import global_preferences_registry"},{"note":"User registry is in users.registries, not the main registries module.","wrong":"from dynamic_preferences.registries import user_preferences_registry","symbol":"user_preferences_registry","correct":"from dynamic_preferences.users.registries import user_preferences_registry"}],"quickstart":{"code":"# settings.py\nINSTALLED_APPS = [\n    'dynamic_preferences',\n    'dynamic_preferences.users',\n]\n\n# urls.py\nfrom django.urls import path, include\nurlpatterns = [\n    path('preferences/', include('dynamic_preferences.urls')),\n]\n\n# models.py\nfrom dynamic_preferences.users.mixins import DynamicPreferencesMixin\nfrom django.contrib.auth.models import AbstractUser\n\nclass User(DynamicPreferencesMixin, AbstractUser):\n    pass\n\n# views.py\nfrom dynamic_preferences.registries import global_preferences_registry\nfrom dynamic_preferences.users.registries import user_preferences_registry\n\ndef my_view(request):\n    global_prefs = global_preferences_registry.manager()\n    user_prefs = user_preferences_registry.manager(request.user)\n    # Access a preference\n    value = global_prefs.get('general__site_name')\n    return render(request, 'template.html', {'site_name': value})","lang":"python","description":"Basic setup with global and per-user preferences. Requires Django User model to inherit from DynamicPreferencesMixin."},"warnings":[{"fix":"Ensure your User model inherits from DynamicPreferencesMixin.\n\nfrom dynamic_preferences.users.mixins import DynamicPreferencesMixin\nclass User(DynamicPreferencesMixin, AbstractUser):\n    pass","message":"In version 1.10+, the user preference registry is no longer automatically attached to the User model via a signal. You must explicitly add DynamicPreferencesMixin to your User model.","severity":"breaking","affected_versions":">=1.10"},{"fix":"Always use double underscore between section and name when accessing preferences (e.g., get('general__site_name')).","message":"The preference name separator is double underscore (e.g., 'general__site_name'). A single underscore may be silently ignored.","severity":"gotcha","affected_versions":"all"},{"fix":"Migrate to class-based preference definitions.\n\nfrom dynamic_preferences.preferences import GlobalPreferenceModel\nfrom dynamic_preferences.registries import global_preferences_registry\n\n@global_preferences_registry.register\nclass SiteName(GlobalPreferenceModel):\n    section = 'general'\n    name = 'site_name'\n    verbose_name = 'Site Name'\n    default = 'My Site'","message":"The old-style registration using preference decorators with explicit section and name is deprecated. Use the registry's register method or the @register_preference decorator with a class.","severity":"deprecated","affected_versions":">=1.11"},{"fix":"Use the provided template tags or manually reference the prefixed field names.","message":"When using the PreferenceForm, the form field names are prefixed with the section and separated by double underscore (e.g., 'general__site_name'). If you manually render fields, ensure you use these names.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to Python 3.6+.","message":"Support for Python 2 was dropped in version 1.10.","severity":"breaking","affected_versions":">=1.10"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'pip install django-dynamic-preferences' and add 'dynamic_preferences' to INSTALLED_APPS in settings.py.","cause":"Package not installed or not added to INSTALLED_APPS correctly.","error":"No module named 'dynamic_preferences'"},{"fix":"Modify your User model to inherit from DynamicPreferencesMixin as described in the quickstart.","cause":"User model does not inherit from DynamicPreferencesMixin.","error":"AttributeError: 'User' object has no attribute 'preferences'"},{"fix":"Ensure you are using double underscore (e.g., 'general__site_name') and that the preference is registered.","cause":"The preference has not been registered or the section/name separator is wrong.","error":"KeyError: 'general__site_name'"},{"fix":"Run 'python manage.py makemigrations dynamic_preferences' and 'python manage.py migrate'.","cause":"Database migrations not applied after adding dynamic_preferences to INSTALLED_APPS.","error":"django.db.utils.OperationalError: no such table: dynamic_preferences_globalpreferencemodel"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}