Note that there are some explanatory texts on larger screens.

plurals
  1. POapp engine validation with django and css
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <pre><code>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})) </code></pre> <p>and the part of the .html file is here</p> <pre><code>&lt;div&gt; {{ form.email.errors }} &lt;label for="id_email"&gt;Your e-mail address:&lt;/label&gt; {{ form.email }} &lt;/div&gt; </code></pre> <p>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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload