Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Django 2 Web Development Cookbook - Third Edition

You're reading from  Django 2 Web Development Cookbook - Third Edition

Product type Book
Published in Oct 2018
Publisher
ISBN-13 9781788837682
Pages 544 pages
Edition 3rd Edition
Languages
Authors (2):
Jake Kronika Jake Kronika
Profile icon Jake Kronika
Aidas Bendoraitis Aidas Bendoraitis
Profile icon Aidas Bendoraitis
View More author details
Toc

Table of Contents (14) Chapters close

Preface 1. Getting Started with Django 2.1 2. Database Structure and Modeling 3. Forms and Views 4. Templates and JavaScript 5. Customizing Template Filters and Tags 6. Model Administration 7. Security and Performance 8. Django CMS 9. Hierarchical Structures 10. Importing and Exporting Data 11. Bells and Whistles 12. Testing and Deployment 13. Other Books You May Enjoy

Creating admin actions

The Django administration system provides actions that we can execute for selected items in the list. There is one action given, by default, and it is used to delete selected instances. In this recipe, we will create an additional action for the list of the Product model, which will allow the administrators to export selected products to Excel spreadsheets.

Getting ready

We will start with the products app that we created in the previous recipe.

Make sure that you have the openpyxl module installed in your virtual environment, to create an Excel spreadsheet, as follows:

(myproject_env)$ pip3 install openpyxl~=2.5.0

If you are using a Docker project, add the dependency to your requirements and rebuild...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}