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

  • Home
  • SEARCH
  • 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 6140973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:11:10+00:00 2026-05-23T18:11:10+00:00

I am curious about making a mad lib style form (cf. http://www.lukew.com/ff/entry.asp?1007 ) for

  • 0

I am curious about making a “mad lib” style form (cf. http://www.lukew.com/ff/entry.asp?1007) for my django form. I could do it by iterating over all the form fields and laying out the text by hand, e.g. <li>There should be {{ form.num_widgets }} widgets</li>, however I dislike how the label on the form field is unused, how it’s partially spread from the form definition file and the template file, and how it’s hard to i18n that.

Is there any neater/all-in-one-place way to do mad lib forms in django? Something where I set the label of the widget to "There should be %(something)s widgets", and it’ll replace the %(something)s with the rendered form of the field, so that I can call {{ form.as_p }} and it’ll work automatically?

  • 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-05-23T18:11:10+00:00Added an answer on May 23, 2026 at 6:11 pm

    This is a good case for a custom template tag, as documented here: https://docs.djangoproject.com/en/dev/howto/custom-template-tags/

    You could easily create a tag that does something along the lines of:

    @register.simple_tag
    def madlibfield(formfield):
       return formfield.label % formfield
    

    You could then use that in your template as

    {% madlibfield form.num_widgets %}
    

    If you want to get fancier with the output (like replicating the as_p functionality), it’s trivial to do so in the tag.

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

Sidebar

Related Questions

I am curious about COM+, DCOM. I know that MSFT does not encourage you
I'm making some pretty string-manipulation-intensive code in C#.NET and got curious about some Joel
I have a couple special use cases for Django admin, and I'm curious about
I am very curious about making a handwriting recognition application in a web browser.
i've been making an app for android in java, but i'm curious about convering
Curious about running multiple xvfb displays: I have between 10-50 instances of a script
Being curious about how maven works exactly, I've checked out its source codes. Astonishingly,
I'm curious about the correct way to architect an application that consists of the
I am curious about git add action, so I do some test. create a
I am a bit curious about how this works - if I have 5

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.