Add-another pop-ups a la django-admin.

The popup views are implemented using a mixin to the generic CreateView. Also, the popups now support permissions. As a result, a user will only get the add-another link next to a ForeignKey or a ManyToMany field if he has the add permission for the target model. In order to install, django-popcorn, use pip:

pip install django_popcorn

In order to use django-popcorn in your project, follow these steps:

  1. Include the following in your INSTALLED_APPS settings:


  1. Add this to your (If you do not already have it):
    POPCORN_MODELS = ('auth.Group', 'auth.Permission')
  1. Add the following to your base.html template:
<script src="js/admin/RelatedObjectLookups.js"></script>
  1. We will create a view for auth.User and use the utility get_popcorn_urls function to generate popcorn views and urls:
urlpatterns = patterns('',
            CreateView.as_view(model=User, success_url='.'), 
        url(r'^admin/', include(,

    urlpatterns += get_popcorn_urls()
  1. Render your forms like so:
<form method="POST" action="{{ request.get_full_path }}">
        {% csrf_token %}
        {% include 'popcorn/form.html' %}
        <button type="submit">Submit</button>
        <a href="../">Cancel</a>

Thats it! sync your DB, run the dev server and fire up your browser at localhost. You should see a form wthout the add-another links. This is because popcorn add-another links are only enabled for users who have add permission for the target model. Now log-in - possibly via admin after enabling it and hit localhost again. You should see a little + next to ForeignKey and ManyToMany fields. Click it and the add-another popup would appear. If you are having any problems, please check out the test project for a working implementation.