Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9218997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:59:47+00:00 2026-06-18T02:59:47+00:00

I’m a heavy django-tables2 user and I’ve thought of adding a generic extension to

  • 0

I’m a heavy django-tables2 user and I’ve thought of adding a generic extension to the django-table: I want to allow the user to be able to export all the table data to excel (using xlwt) or csv just by clicking a button that would be somewhere near the table.

Now, I’ve implemented this in a non generic way, meaning that I’ve included a POST form and a button in my template and add a check to see if the button has been clicked the view that fills the table. If the button is clicked return the xls instead of the normal template. Also I’ve implemented a generic function that gets a django-table2 table (any table) and converts it to an xlwt sheet (in order to put it to a workbook).

This is working fine but since I will use this button to all my tables, I don’t want to add the export form and button to all my html templates that would contain a table. Also I don’t want to add the POST checks to all my views ! This is definitely not DRY 🙁

Ideally, I’d like to have a class let’s say it ExportTable that would extend the Table class of django-tables2 and would be usable as a replacement – when I’d create my table using the ExportTable as a base class then the button and the view would have the required components to export the table. From what I can understand, this is not possible 🙁

Can somebody propose to me which way should I go to extend django-tables2 in order to be able to add the “export” functionality in the most DRY way possible ? Meaning that I’d be able to use only the {% render_table table %} tag in my templates (or an extension to that) and without the need to add checks to my views to see if the user has clicked the export button (and of course without the need to add extra views and url routes just to handle that). Is generic class views the way to go ?

I will accept the most DRY and complete (I’d like to have some source code with comments please) answer 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:59:48+00:00Added an answer on June 18, 2026 at 2:59 am

    I use django-tables2-reports to export tables2 data to csv and xls. I’m having issues with the xls at the mo (reported here) but I’m sure a solution will pop up soon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.