{"id":8095,"library":"django-extra-views","title":"Django Extra Views","description":"Django Extra Views provides a collection of useful, advanced class-based views for Django, extending the built-in generic views. It's particularly strong for handling complex formsets and inlines. The current version is 0.16.0, and releases are typically feature-driven, providing new views or compatibility updates for Django.","status":"active","version":"0.16.0","language":"en","source_language":"en","source_url":"https://github.com/AndrewIngram/django-extra-views","tags":["django","views","class-based-views","formsets","inlines","mixins"],"install":[{"cmd":"pip install django-extra-views","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for all views and mixins.","package":"Django>=3.2","optional":false},{"reason":"Required for `SearchableListMixin` to enable filtering capabilities.","package":"django-filter>=2.0","optional":true}],"imports":[{"symbol":"InlineFormSetView","correct":"from extra_views import InlineFormSetView"},{"symbol":"CreateWithInlinesView","correct":"from extra_views import CreateWithInlinesView"},{"symbol":"UpdateWithInlinesView","correct":"from extra_views import UpdateWithInlinesView"},{"symbol":"ModelFormSetView","correct":"from extra_views import ModelFormSetView"},{"symbol":"SearchableListMixin","correct":"from extra_views import SearchableListMixin"}],"quickstart":{"code":"from django.db import models\nfrom django.views.generic import ListView\nfrom extra_views import CreateWithInlinesView, InlineFormSetFactory\n\n# models.py example\nclass Parent(models.Model):\n    name = models.CharField(max_length=100)\n\n    def __str__(self):\n        return self.name\n\nclass Child(models.Model):\n    parent = models.ForeignKey(Parent, on_delete=models.CASCADE)\n    item = models.CharField(max_length=100)\n\n    def __str__(self):\n        return f'{self.item} ({self.parent.name})'\n\n# views.py example\nclass ChildInline(InlineFormSetFactory):\n    model = Child\n    fields = ['item']\n    factory_kwargs = {'extra': 1}\n\nclass CreateParentWithChildrenView(CreateWithInlinesView):\n    model = Parent\n    fields = ['name']\n    inlines = [ChildInline]\n    template_name = 'parent_create_with_children.html'\n    success_url = '/parents/' # Or reverse_lazy('parent-list')\n\n# urls.py example\n# from django.urls import path\n# from .views import CreateParentWithChildrenView\n#\n# urlpatterns = [\n#     path('parents/create/', CreateParentWithChildrenView.as_view(), name='parent-create-with-children'),\n# ]\n\n# parent_create_with_children.html (simplified fragment)\n# <form method=\"post\">\n#     {% csrf_token %}\n#     {{ form.as_p }}\n#     <h3>Children</h3>\n#     {{ inlines.childinline.management_form }}\n#     {% for formset in inlines.childinline %}\n#         {{ formset.as_p }}\n#     {% endfor %}\n#     <button type=\"submit\">Save</button>\n# </form>\n\n# To make this runnable, we need a minimal Django setup.\n# For testing purposes, you could try:\n# from django.conf import settings\n# if not settings.configured:\n#     settings.configure(DEBUG=True, INSTALLED_APPS=['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.admin', 'django.contrib.messages'], DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}})\n# import django\n# django.setup()\n# # Then define Parent and Child models and run migrations implicitly.\n# from django.core.management import call_command\n# call_command('makemigrations', 'your_app_name', interactive=False)\n# call_command('migrate', interactive=False)\n# # This example is primarily for demonstrating the view setup.","lang":"python","description":"This quickstart demonstrates how to use `CreateWithInlinesView` to create a parent object along with its related child objects in a single form. It defines a `Parent` model and a `Child` model, then sets up an `InlineFormSetFactory` for `Child` and integrates it into `CreateWithInlinesView`. Remember to define corresponding URL patterns and templates in your Django project."},"warnings":[{"fix":"Upgrade your Django project to version 3.2 or higher. Alternatively, pin `django-extra-views` to a compatible version like `django-extra-views<0.13`.","message":"Django 2.x support was dropped in version 0.13.0. Projects using older Django versions (2.x) will need to upgrade Django to >=3.2 or stick to an older `django-extra-views` release (<0.13.0).","severity":"breaking","affected_versions":">=0.13.0"},{"fix":"Update your custom `get_queryset` method to accept the new `ordering` parameter: `def get_queryset(self, ordering=None): ...`. Ensure your logic handles the `ordering` parameter or passes it appropriately to the super method.","message":"The `SortableListMixin.get_queryset` method signature changed in version 0.10.0, adding an `ordering` parameter. If you override this method in your custom views, your existing implementation will break.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Migrate to `InlineFormSetFactory` or use Django's built-in `inlineformset_factory` if `FormSetFactory` was used for model-based formsets. For non-model formsets, use Django's `formset_factory` directly.","message":"The `FormSetFactory` class was removed in version 0.9.0. If you were directly using `FormSetFactory` to create formsets, you will need to refactor your code.","severity":"deprecated","affected_versions":">=0.9.0"},{"fix":"Install `django-filter` via `pip install django-filter` and ensure your view or mixin has a `search_fields` attribute defined, e.g., `search_fields = ['name__icontains']`.","message":"When using `SearchableListMixin`, `SearchableList` or `SortableListMixin`, `django-filter` must be installed. For `SearchableListMixin`, make sure to also define `search_fields`.","severity":"gotcha","affected_versions":"All versions (where applicable)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change your import statement from `from extra_views.mixins import SearchableListMixin` to `from extra_views import SearchableListMixin`.","cause":"Attempting to import from old submodule paths. In recent versions, most components are available directly under the `extra_views` namespace.","error":"ModuleNotFoundError: No module named 'extra_views.mixins'"},{"fix":"Ensure your `InlineFormSetFactory` class explicitly defines `model = YourRelatedModel` or `form_class = YourCustomForm`.","cause":"You are using `InlineFormSetFactory` (or an older `FormSetFactory`) but have not specified either the `model` attribute (for model-based formsets) or `form_class` (for custom forms).","error":"ImproperlyConfigured: One of 'form_class', 'model' should be set for FormSetFactory."},{"fix":"Ensure your view class has `model = YourModel` or `queryset = YourModel.objects.all()` defined, or that you override `get_queryset` correctly.","cause":"This error can occur with list-based views (e.g., `SortableListMixin` or `SearchableListMixin` when combined with a `ListView`) if you forget to specify the base queryset or model for the view.","error":"django.core.exceptions.ImproperlyConfigured: ListView is missing a QuerySet. Define .model, .queryset, or override .get_queryset()."}]}