thank you nikhil and nevio.......:) On Sun, May 27, 2012 at 2:48 PM, Nevio Vesic <nevio.ve...@gmail.com> wrote:
> You're missing a `content` at def view_page. I've marked possible solution > *(as red)* that could fix it. > > def view_page(request, page_name): > try: > page = Page.objects.get(pk=page_name) > *content = page.content* > > except Page.DoesNotExist: > return render_to_response("create.** > html",{"page_name":page_name}) > return render_to_response("view.html"**, {"page_name":page_name, > "content":content},context_**instance=RequestContext(**request)) > > > On Sunday, May 27, 2012 10:58:13 AM UTC+2, Ali Shaikh wrote: >> >> 'model.py` >> from django.db import models >> >> class Page(models.Model): >> name = models.CharField(max_length=**20, primary_key=True) >> content = models.TextField(blank=True) >> >> # Create your models here. >> >> `view.py` >> from wiki.models import Page >> from django.shortcuts import render_to_response >> from django.http import HttpResponseRedirect, HttpResponse >> from django.shortcuts import get_object_or_404, render_to_response >> from django.core.urlresolvers import reverse >> from django.template import RequestContext >> from django.shortcuts import render_to_response >> from django.core.context_processors import csrf >> >> >> def view_page(request, page_name): >> try: >> page = Page.objects.get(pk=page_name) >> except Page.DoesNotExist: >> return >> render_to_response("create.**html",{"page_name":page_name}) >> >> return render_to_response("view.html"**, {"page_name":page_name, >> "content":content},context_**instance=RequestContext(**request)) >> >> def edit_page(request, page_name): >> try: >> page = Page.objects.get(pk=page_name) >> content= page.contents >> except Page.DoesNotExist: >> content= "" >> return render_to_response("edit.html"**, {"page_name":page_name, >> "content":content},context_**instance=RequestContext(**request)) >> >> def save_page(request, page_name): >> content= request.POST["content"] >> try: >> page = Page.objects.get(pk=page_name) >> page.content= content >> except Page.DoesNotExist: >> page = Page(name=page_name,content=**content) >> page.save() >> return HttpResponseRedirect("/**wikicamp/" + page_name + "/") >> >> Traceback >> >> >> Environment: >> Request Method: GET >> Request URL: >> >> Django Version: 1.4 >> Python Version: 2.6.6 >> Installed Applications: >> ('django.contrib.auth', >> 'django.contrib.contenttypes'**, >> 'django.contrib.sessions', >> 'django.contrib.sites', >> 'django.contrib.messages', >> 'django.contrib.staticfiles', >> 'wiki') >> Installed Middleware: >> ('django.middleware.common.**CommonMiddleware', >> 'django.contrib.sessions.**middleware.SessionMiddleware', >> 'django.middleware.csrf.**CsrfViewMiddleware', >> 'django.contrib.auth.**middleware.**AuthenticationMiddleware', >> 'django.contrib.messages.**middleware.MessageMiddleware') >> >> >> Traceback: >> >> enter code here >> >> File "/usr/local/lib/python2.6/**dist-packages/django/core/**handlers/ >> base.py" in get_response >> 111. response = callback(request, >> *callback_args, **callback_kwargs) >> File "/home/tanveer/djcode/**wikicamp/wiki/views.py" in view_page >> 16. return render_to_response("view.html"**, >> {"page_name":page_name, >> "content":content},context_**instance=RequestContext(**request)) >> >> Exception Type: NameError at /wikicamp/start/ >> Exception Value: global name 'content' is not defined >> >> >> PLs help..........:( > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/nojisJrWsyQJ. > > 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. > -- 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.