All Projects → AndrewIngram → Django Extra Views

AndrewIngram / Django Extra Views

Licence: mit
Django's class-based generic views are awesome, let's have more of them.

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Django Extra Views

Django Todolist
exemplary django application - small to do list web app
Stars: ✭ 47 (-95.64%)
Mutual labels:  django
Django Preferences
Django app allowing users to set app specific preferences through the admin interface.
Stars: ✭ 51 (-95.27%)
Mutual labels:  django
Urljects
Deprecated! (Django routing without urls.py files, inspired by Flask.)
Stars: ✭ 53 (-95.08%)
Mutual labels:  django
Django Unifi Portal
Authenticate Unifi WiFi Guests with Django
Stars: ✭ 50 (-95.36%)
Mutual labels:  django
Django Campaign
Newsletter management app for Django
Stars: ✭ 50 (-95.36%)
Mutual labels:  django
Django Channels React Multiplayer
turn based strategy game using django channels, redux, and react hooks
Stars: ✭ 52 (-95.18%)
Mutual labels:  django
Django Celery Tutorial
Django Celery Tutorial
Stars: ✭ 48 (-95.55%)
Mutual labels:  django
River Admin
🚀 A shiny admin interface for django-river built with DRF, Vue & Vuetify
Stars: ✭ 55 (-94.9%)
Mutual labels:  django
Django Money
Money fields for Django forms and models.
Stars: ✭ 1,064 (-1.3%)
Mutual labels:  django
Channelstream
Channelstream is a websocket communication server for web applications
Stars: ✭ 52 (-95.18%)
Mutual labels:  django
Yesterday I Learned
Brainfarts are caused by the rupturing of the cerebral sphincter.
Stars: ✭ 50 (-95.36%)
Mutual labels:  django
Grocerystore With Server
Grocery Store with server integration
Stars: ✭ 51 (-95.27%)
Mutual labels:  django
Django Custom User Model
django custom user model
Stars: ✭ 52 (-95.18%)
Mutual labels:  django
Spirit
Spirit is a modern Python based forum built on top of Django framework
Stars: ✭ 1,045 (-3.06%)
Mutual labels:  django
Kala App
Kala Document Management System
Stars: ✭ 53 (-95.08%)
Mutual labels:  django
Hubblemon
Stars: ✭ 48 (-95.55%)
Mutual labels:  django
Django Dashboard Adminlte
AdminLTE Django - Open-source seed project | AppSeed
Stars: ✭ 51 (-95.27%)
Mutual labels:  django
Opentaps seas
opentaps Smart Energy Applications Suite
Stars: ✭ 55 (-94.9%)
Mutual labels:  django
Django Airports
✈️ It's like django-cities, but django-airports
Stars: ✭ 54 (-94.99%)
Mutual labels:  django
Django Rest Framework Tricks
Collection of various tricks for Django REST framework.
Stars: ✭ 52 (-95.18%)
Mutual labels:  django

|travis| |codecov| |docs-status|

Django Extra Views - The missing class-based generic views for Django

Django-extra-views is a Django package which introduces additional class-based views in order to simplify common design patterns such as those found in the Django admin interface.

Full documentation is available at read the docs_.

.. _read the docs: https://django-extra-views.readthedocs.io/

.. |travis| image:: https://secure.travis-ci.org/AndrewIngram/django-extra-views.svg?branch=master :target: https://travis-ci.org/AndrewIngram/django-extra-views :alt: Build Status

.. |codecov| image:: https://codecov.io/github/AndrewIngram/django-extra-views/coverage.svg?branch=master :target: https://codecov.io/github/AndrewIngram/django-extra-views?branch=master :alt: Coverage Status

.. |docs-status| image:: https://readthedocs.org/projects/django-extra-views/badge/?version=latest :target: https://django-extra-views.readthedocs.io/ :alt: Documentation Status

.. installation-start

Installation

Install the stable release from pypi (using pip):

.. code-block:: sh

pip install django-extra-views

Or install the current master branch from github:

.. code-block:: sh

pip install -e git://github.com/AndrewIngram/django-extra-views.git#egg=django-extra-views

Then add 'extra_views' to your INSTALLED_APPS:

.. code-block:: python

INSTALLED_APPS = [
    ...
    'extra_views',
    ...
]

.. installation-end

.. features-start

Features

  • FormSet and ModelFormSet views - The formset equivalents of FormView and ModelFormView.
  • InlineFormSetView - Lets you edit a formset related to a model (using Django's inlineformset_factory).
  • CreateWithInlinesView and UpdateWithInlinesView - Lets you edit a model and multiple inline formsets all in one view.
  • GenericInlineFormSetView, the equivalent of InlineFormSetView but for GenericForeignKeys.
  • Support for generic inlines in CreateWithInlinesView and UpdateWithInlinesView.
  • Support for naming each inline or formset in the template context with NamedFormsetsMixin.
  • SortableListMixin - Generic mixin for sorting functionality in your views.
  • SearchableListMixin - Generic mixin for search functionality in your views.
  • SuccessMessageMixin and FormSetSuccessMessageMixin - Generic mixins to display success messages after form submission.

.. features-end

Still to do

Add support for pagination in ModelFormSetView and its derivatives, the goal being to be able to mimic the change_list view in Django's admin. Currently this is proving difficult because of how Django's MultipleObjectMixin handles pagination.

.. quick-examples-start

Quick Examples

FormSetView ^^^^^^^^^^^^^^^^^^^^^^^

Define a :code:FormSetView, a view which creates a single formset from :code:django.forms.formset_factory and adds it to the context.

.. code-block:: python

from extra_views import FormSetView
from my_forms import AddressForm

class AddressFormSet(FormSetView):
    form_class = AddressForm
    template_name = 'address_formset.html'

Then within address_formset.html, render the formset like this:

.. code-block:: html

<form method="post">
  ...
  {{ formset }}
  ...
  <input type="submit" value="Submit" />
</form>

ModelFormSetView ^^^^^^^^^^^^^^^^^^^^

Define a :code:ModelFormSetView, a view which works as :code:FormSetView but instead renders a model formset using :code:django.forms.modelformset_factory.

.. code-block:: python

from extra_views import ModelFormSetView


class ItemFormSetView(ModelFormSetView):
    model = Item
    fields = ['name', 'sku']
    template_name = 'item_formset.html'

CreateWithInlinesView or UpdateWithInlinesView ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Define :code:CreateWithInlinesView and :code:UpdateWithInlinesView, views which render a form to create/update a model instance and its related inline formsets. Each of the :code:InlineFormSetFactory classes use similar class definitions as the :code:ModelFormSetView.

.. code-block:: python

from extra_views import CreateWithInlinesView, UpdateWithInlinesView, InlineFormSetFactory


class ItemInline(InlineFormSetFactory):
    model = Item
    fields = ['sku', 'price', 'name']


class ContactInline(InlineFormSetFactory):
    model = Contact
    fields = ['name', 'email']


class CreateOrderView(CreateWithInlinesView):
    model = Order
    inlines = [ItemInline, ContactInline]
    fields = ['customer', 'name']
    template_name = 'order_and_items.html'


class UpdateOrderView(UpdateWithInlinesView):
    model = Order
    inlines = [ItemInline, ContactInline]
    fields = ['customer', 'name']
    template_name = 'order_and_items.html'

Then within order_and_items.html, render the formset like this:

.. code-block:: html

<form method="post">
  ...
  {{ form }}

  {% for formset in inlines %}
    {{ formset }}
  {% endfor %}
  ...
  <input type="submit" value="Submit" />
</form>

.. quick-examples-end

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].