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 129877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:51:34+00:00 2026-05-11T05:51:34+00:00

I want to show a title and description from a db query in each

  • 0

I want to show a title and description from a db query in each form, but I don’t want it to be in a charfield, I want it to be html-formatted text.

sample template code:

{% for form, data in zipped_data %}    <div class='row'>       <div class='first_col'>          <span class='title'>{{ data.0 }}</span>          <div class='desc'>             {{ data.1|default:'None' }}          </div>       </div>       {% for field in form %}          <div class='fieldWrapper' style='float: left; '>             {{ field.errors }}             {{ field }}          </div>       {% endfor %} {% endfor %} 

Is this the most idiomatic way of doing this? Or, is there a way to add text that will not be displayed inside of a textarea or text input to my model:

class ReportForm(forms.Form):    comment = forms.CharField() 

?

  • 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. 2026-05-11T05:51:35+00:00Added an answer on May 11, 2026 at 5:51 am

    Instead of zipping your forms with the additional data, you can override the constructor on your form and hold your title/description as instance-level member variables. This is a bit more object-oriented and learning how to do this will help you solve other problems down the road such as dynamic choice fields.

    class MyForm (forms.Form):     def __init__ (self, title, desc, *args, **kwargs):         self.title = title         self.desc = desc         super (MyForm, self).__init__ (*args, **kwargs) # call base class 

    Then in your view code:

    form = MyForm ('Title A', 'Description A') 

    Adjust accordingly if you need these values to come from the database. Then in your template, you access the instance variables just like you do anything else, e.g.:

       <h1>{{ form.title }}</h1>    <p>{{ form.desc }}</p> 

    From the way you phrased your question, I think you probably have some confusion around the way Django uses Python class attributes to provide a declarative form API versus instance-level attributes that you apply to individual instances of a class, in this case your form objects.

    • Check out this link for a good discussion on the distinction
    • And this one
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show only my TODAYS events in my html output. But with
By default in all browsers, title attributes only show on mouse over. I want
I want to show the status of some files in a Java GUI. Each
so i continue from this question YouTube: get youtube title+ image+description like facebook `
i want to show the StudentNo, SubjectCode,SubjectDescription and grade but when ever students get
If I have Table A with columns title and description , and I want
When I click the href, I want to display the image and description from
I have a list of divs (simplified example) <div class=title>text</div> <div class=description>text</div> <div class=title>text</div>
I want show annotation view (above one of my pin) after load map. For
hii I want show a pop up Dialog box when i click on to

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.