django_popcorn
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.
Installation
Get it from the cheeseshop:
pip install django_popcorn
Usage
Read on:
Include the following in your INSTALLED_APPS settings:
'popcorn',
Add this to your settings.py (If you do not already have it):
TEMPLATE_CONTEXT_PROCESSORS = ( "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", "django.contrib.messages.context_processors.messages", "django.core.context_processors.request", "popcorn.context_processors.admin_media_prefix", ) POPCORN_MODELS = ('auth.Group', 'auth.Permission')Add the following to your base.html template:
<script src="{{ ADMIN_MEDIA_PREFIX }}js/admin/RelatedObjectLookups.js"></script>We will create a view for auth.User and use the utility get_popcorn_urls function to generate popcorn views and urls:
urlpatterns = patterns('', url(r'^$', CreateView.as_view(model=User, success_url='.'), name='auth_user_create'), url(r'^admin/', include(admin.site.urls)), ) urlpatterns += get_popcorn_urls()
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> </form>
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.
History
1.0.0 (2014-06-23)
98% test coverage. Ready for big-time.
0.2.0 (2013-12-9)
Added support for permissions.
0.1.0 (2013-12-2)
First release on PyPI.
Metadata
Release files for django_popcorn 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_popcorn-1.0.0.tar.gz | 14.8 kB | Without provenance | Details |
Release files / django_popcorn-1.0.0.tar.gz
| Download URL | django_popcorn-1.0.0.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f86018e333ea0e2daad2dd2b74c3aedcd17a5da031f8251ca80a2c26388fabee
|
|
BLAKE2b-256 checksum How to use checksums |
cee0401c19faab7e3a9d91e7b0c5ba63bf28854c443e7cb3b3ad02b05e1e0c40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django_popcorn 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.