The HTML is showing all the attributes from my models.py.  I only want
to show first name and last name. In views.py, only first_name and
last_name were listed, why are the rest of the attribute show up in
the html page?  How do i limit to a selection of attributes to show up
in an html page.
So i did more research and look at examples, below is my new attempt.

I really apprecaited the respond.

Regards,
-T

========= models.py =======================
class BusinessUser(db.Model):
    """Basic user profile with personal details."""
    first_name = db.StringProperty()
    last_name = db.StringProperty()
    street_address = db.StringProperty()
    city =  db.StringProperty()
    state = db.StringProperty()
    zip_code = db.StringProperty()

========= form.html =====================
{% extends 'layout.html' %}
{% block title %}Create person{% endblock %}

{% block content %}

<form action="" method="POST">
  {{ form.as_ul}}

    <input type="submit" name="create" value="Create">

</form>

{% endblock %}



========  views.py =============
class CreateBusinessForm(djangoforms.ModelForm):
        class Meta:
                model = BusinessUser
                fields = ['first_name','last_name']

def add_person(request):
        if request.method == 'POST': # If the form has been submitted...
                form = CreateBusinessForm(request.POST)
                if form.is_valid():
                        post = 
BusinessUser(first_name=form.clean_data['first_name'])
                        post = 
BusinessUser(first_name=form.clean_data['last_name'])
                        post.put()
                        return HttpResponseRedirect('/')
        else:
                form = CreateBusinessForm()
        return create_object(request, BusinessUser)


On Dec 21, 1:28 pm, Thomas <thomas.pels...@googlemail.com> wrote:
> HiyinDojo,
>
> I'm not sure, if I understood your problem.
>
> You have a template like this - lets call it "index.html"
>
> <---
> <html>
>  <body>
>   <form action="" method="post">
>    {{form.as_p }}
>    <input type="submit" name="create" value="Create">
>   </form>
>  </body>
> </html>
> <---
>
> Right??
>
> Then your models.py has to look like this:
> <---
> import os
> from google.appengine.ext import webapp
> from google.appengine.ext.webapp.util import run_wsgi_app
> from google.appengine.ext.webapp import template
>
> class MainHandler(webapp.RequestHandler):
>
>   def get(self):
>     template_values = {
>       'form.as_p' : '<input type="text" name="first_name"><input
> type="text" name="last_name">'
>       }
>     path = os.path.join(os.path.dirname(__file__), './index.html')
>     self.response.out.write(template.render(path, template_values))
>
> def main():
>     run_wsgi_app(webapp.WSGIApplication([('/', MainHandler)],
> debug=True))
>
> if __name__ == '__main__':
>     main()
> -->
>
> Per "self.response.out.write(template.render(path, template_values))"
> you take a file path to the template file and a dictionary of values,
> and return the rendered text. Take a look 
> tohttp://www.djangoproject.com/documentation/0.96/templates/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to