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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:21:17+00:00 2026-05-21T12:21:17+00:00

Looking at those references etc, I have been unable to come up with a

  • 0

Looking at those references etc, I have been unable to come up with a good way to couple everything together. The problem relates to send back the form and contents if the form is not valid. So what I am doing is pulling out each generated form item by item and displaying in the .html file.

So my question is. How do I get this working. Now I can display the form with css style sheet, but I cannot seem to get validation working on the field and I’m always generating an error.

class Quote(db.Model):
    email = db.StringProperty(required=True)

class QuoteForm(djangoforms.ModelForm):
class Meta:
        model = Quote
        exclude = ['entry_time']

class MainPage(webapp.RequestHandler):
def get(self):
    form = QuoteForm();
    template_values = {}        
    path = os.path.join(os.path.dirname(__file__), 'index.html')
    self.response.out.write(template.render(path, {'form': form}))

def post(self):
        data = QuoteForm(data=self.request.POST)
        if data.is_valid():
                # save here
                self.redirect('/Confirm.html')
        else:
            template_values = {}        
            path = os.path.join(os.path.dirname(__file__), 'index.html')
            self.response.out.write(template.render(path, {'form': data}))

and the part of the .html file is here

<div>
    {{ form.email.errors }}
    <label for="id_email">Your e-mail address:</label>
    {{ form.email }}
</div>

It would nothing that I put into the email field validates correctly. I’m not sure why!? I’m losing the information I have already put into the form. How do I retain this information and actually do proper validation. The model suggests that only a non blank string is required, but nothing ever satisfies the validation.

  • 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-21T12:21:17+00:00Added an answer on May 21, 2026 at 12:21 pm

    You can add your own attributes to widgets (i.e. controls) that Django uses to render your form elements. This includes a class attribute for CSS styling:

    class QuoteForm(djangoforms.ModelForm):
        email = EmailField(widget = TextInput(attrs={'class':'textfield'}))
        class Meta:
            model = Quote
            exclude = ['entry_time']
    

    The downside is that you need to explicitly specify the fields from your model in the form class.

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

Sidebar

Related Questions

I have a content type that references multiple nodes, and I need a way
I'm looking for a regular expression that will match all strings EXCEPT those that
I'm looking to find alternatives to Solr from the Apache Software Foundation. For those
Kinda long title, but anyways... I've been looking at these examples, specifically on the
I have been reading a lot of posts on this site regarding the usage
I'm just looking for a simple, concise explanation of the difference between these two.
I've worked with a few of these in the past, but I'm looking for
Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools
Looking for an example that: Launches an EXE Waits for the EXE to finish.
Looking for C# class which wraps calls to do the following: read and write

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.