{"id":6590,"library":"django-braces","title":"Django Braces","description":"Django Braces provides a collection of reusable, generic mixins designed to simplify the use of Django's class-based views. These mixins often replicate the functionality of Django's function-based view decorators, addressing common development challenges with class-based views. The library is considered stable and mature, focusing its support on Python versions still receiving fixes and Django LTS releases. The current version is 1.17.0.","status":"active","version":"1.17.0","language":"python","source_language":"en","source_url":"https://github.com/brack3t/django-braces/","tags":["django","mixins","class-based-views","cbv","authentication","permissions"],"install":[{"cmd":"pip install django-braces","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core framework dependency for all functionality.","package":"Django","optional":false}],"imports":[{"wrong":"from braces.views import LoginRequiredMixin","symbol":"LoginRequiredMixin","correct":"from braces.views import LoginRequiredMixin"}],"quickstart":{"code":"from django.views.generic import TemplateView\nfrom braces.views import LoginRequiredMixin\n\nclass SomeSecretView(LoginRequiredMixin, TemplateView):\n    template_name = \"path/to/secret_template.html\"\n    login_url = \"/login/\"  # Optional: Redirect URL if not authenticated\n    redirect_field_name = \"next\" # Optional: Parameter name for the next URL\n    raise_exception = False # Optional: Raise PermissionDenied instead of redirecting\n\n    def get(self, request, *args, **kwargs):\n        return self.render_to_response({})\n","lang":"python","description":"This example demonstrates how to use the `LoginRequiredMixin` to restrict access to a Django class-based view. The mixin ensures that only authenticated users can access `SomeSecretView`, redirecting unauthenticated users to the specified `login_url`."},"warnings":[{"fix":"Ensure your project runs on Python 3.7+ and a supported Django LTS version before upgrading to django-braces v1.15.0 or later.","message":"Explicit support for Python versions before 3.7 and non-LTS versions of Django was dropped in `django-braces` v1.15.0.","severity":"breaking","affected_versions":">=1.15.0"},{"fix":"If upgrading from older versions, replace `CreateAndRedirectToEditView` with custom `get_success_url` logic or a combination of other mixins.","message":"The `CreateAndRedirectToEditView` mixin was marked for deprecation since v1.0.0 and subsequently removed in v1.11.0.","severity":"deprecated","affected_versions":">=1.11.0"},{"fix":"Upgrade to `django-braces` v1.9.0 or newer to benefit from fixes addressing these redirect loop issues.","message":"Prior to v1.9.0, certain access mixins (like `MultipleGroupRequiredMixin` and `GroupRequiredMixin`) could lead to redirect loops for users without appropriate permissions or group memberships.","severity":"gotcha","affected_versions":"<1.9.0"},{"fix":"For versions 1.0.0 and later, configure `LoginRequiredMixin` using `login_url`, `redirect_field_name`, and `raise_exception` class attributes directly on your view.","message":"The `LoginRequiredMixin` was rewritten in v1.0 to align with other access mixins. Older implementations might not correctly utilize `login_url`, `redirect_field_name`, or `raise_exception` class attributes.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Always set the `permission_required` class attribute as a string (e.g., `'app_label.add_model'`) when using `PermissionRequiredMixin`.","message":"The `PermissionRequiredMixin` will raise an `ImproperlyConfigured` exception if the `permission_required` attribute is not explicitly set on the view class.","severity":"gotcha","affected_versions":"All"},{"fix":"If your user model or group setup is custom, override the `check_membership` method within your view using `GroupRequiredMixin` to implement your specific group checking logic.","message":"The `GroupRequiredMixin` assumes that you are using Django's default `Group` model and that your user model has a `groups` ManyToMany relationship. Deviations require overriding `check_membership`.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'1.17.0':71 'address':38 'authent':79 'base':22,35,45,76 'brace':2,4 'cbv':78 'challeng':41 'class':21,44,75 'class-bas':20,43 'class-based-view':74 'collect':7 'common':39 'consid':50 'current':68 'decor':37 'design':12 'develop':40 'django':1,3,18,31,64,72 'fix':62 'focus':54 'function':29,34 'function-bas':33 'generic':10 'librari':48 'lts':65 'matur':53 'mixin':11,25,73 'often':26 'permiss':80 'provid':5 'python':58 'receiv':61 'releas':66 'replic':27 'reusabl':9 'simplifi':14 'stabl':51 'still':60 'support':56 'use':16 'version':59,69 'view':23,36,46,77","created_at":"2026-04-15T18:34:26.381414+00:00","updated_at":"2026-04-16T14:28:22.648755+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmp12xl45gw/venv/lib/python3.12/site-packages/braces/views/__init__.py\", line 1, in <module>\n    from ._access import (\n  File \"/tmp/tmp12xl45gw/venv/lib/python3.12/site-packages/braces/views/_access.py\", line 7, "},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.17.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/brack3t/django-braces","docs":null,"changelog":null,"pypi":"https://pypi.org/project/django-braces/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","database","auth-security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}