Purpose: to create a question when the user creates a poll question, which is the "mad-libs" style (ie, "Fool yourself with _ (text) __ if she did not meet _ (text) _ ?").
Code: This file creates a django form corresponding to the appengine object.
from django import newforms as forms
import models
from google.appengine.ext.db import djangoforms
class PollForm(djangoforms.ModelForm):
class Meta:
model = models.Poll
This is an excerpt from the models.py file
from google.appengine.ext import db
from django import newforms as forms
class Poll(db.Model):
question = db.StringProperty()
created_on = db.DateTimeProperty(auto_now_add = 1)
created_by = db.UserProperty()
def __str__(self):
return '%s' %self.question
def get_absolute_url(self):
return '/poll/%s/' % self.key()
here is the html for this section
<form action="." method="post">
{{pollform.as_p}}
{% for form in choiceforms %}
{{form.as_p}}
{% endfor %}
<input type="submit" name="createpoll" value="createpoll" />
</form>
Is there a pretty simple way to create such a question with some pre-coded text and some input text? Can I specify it in HTML?
Any direction is welcome!
source
share