Your view doesn't pass a context to the template.  It needs to do this,
and your form needs to be part of the context.


something like:

from myweb.meekapp.models import mobForm
from django.shortcuts import render_to_response
from django.template import RequestContext

def home(request):
    return render_to_response('home.html', {'mobForm': mobForm},
                             context_instance=RequestContext(requeoust))

The RequestContext bit lets you access information about the HTTP
request from inside your template.  Not strictly necessary in this case,
but it's a good habit to get into.  You never know when you're going to
want to know where the user was referred from, or what browser they're
using, for instance.

Cheers,
Cliff



On Tue, 2012-01-24 at 05:32 -0800, coded kid wrote:
> Hi guys, I’m trying to let this form display but it’s not displaying
> in my browser. When I open up the browser, only a blank page shows up.
> How can I go about it? Below are my codes:
> 
> In models.py
> from django.db import models
> from django.forms import ModelForm, Textarea, HiddenInput
> from django.contrib.auth.models import User
> from string import join
> from settings import MEDIA_ROOT
> class group(models.Model):
>     desc=models.TextField(max_length=25)
> 
>     def __unicode__(self):
>         return unicode(self.id)
> 
>     def get_absolute_url(self):
>         return "/g/%s" % unicode(self.id)
> 
>     class Admin:
>         list_display=('id','desc')
>     class Meta:
>         ordering=['-id']
> 
> class mob (models.Model):
>     author=models.ForeignKey(User,blank=True, null=True)
>     state_province=models.CharField(max_length=50)
>     body=models.TextField(max_length=10000)
>     date=models.DateTimeField('Date')
>     group=models.ForeignKey(group)
> 
> 
>     def __unicode__(self):
>         return u"%s - %s - %s - %s" % (self.author,
> self.state_province, self.body, self.date)
> 
>     def get_absolute_url(self):
>         return "/post/%s/" % unicode(self.id)
>     def get_author_url(self):
>         return "/u/%s/p/0" % (self.author)
> 
>     class Admin:
>         list_display=('author','body','date')
>         date_hierarchy='date'
>     class Meta:
>         ordering=['-date']
> 
> 
> class mobForm(ModelForm):
>     class Meta:
>         model=mob
>         fields=('body','author','state_province','date','group')
>         widgets={
>             'body':Textarea(attrs={"rows":2, "cols":40}),
>             'author': (HiddenInput),
>             'state_province': (HiddenInput),
>             'date':(HiddenInput),
>             'group': (HiddenInput),
>         }
> class grpForm(ModelForm):
>     class Meta:
>         model=group
>         field=('desc')
> 
> In views.py
> 
> from myweb.meekapp.models import mobForm
> from django.shortcuts import render_to_response
> from django.http import HttpResponse
> from django.template import RequestContext
> from django.http import HttpResponseRedirect
> from django.views.decorators.csrf import csrf_exempt
> from django.contrib.auth.decorators import login_required
> from django.contrib.auth.views import login, logout
> 
> 
> def home(request):
> return render_to_response('home.html')
> 
> in my template:
> 
> {% extends "base.html" %}
> 
> {% load pagination_tags %}
> 
> 
> {% autopaginate object_list %}
> {% block newsol %}
> {% if user.is_authenticated %}
> <div class="form">
>       <form action="." method="post" enctype="multipart/form-data">
>         <table>
>               {{ mobForm }}
>         </table>
>         <input type="submit" value="Update" />
>       </form>
> </div>
> {% endif %}
> {% paginate %}
> {% endblock newsol%}
> How can I make the mobForm display? Thanks!
> 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to