Dear Django users, I am writing my first Django application (also new to Python and have not done any web programming for many years) and am trying to produce a screen which allows a row to be added to a table (I know this can be done in admin but once I have it working I will add more features). But I am getting:
AttributeError at /forum/gktest/ 'WSGIRequest' object has no attribute 'gk' Request Method: POST Request URL: http://127.0.0.1/forum/gktest/ Exception Type: AttributeError Exception Value: 'WSGIRequest' object has no attribute 'gk' Exception Location: C:\Documents and Settings\GeoffK\My Documents \Millstream\mysite\forum\views.py in gktest_save_page, line 91 Python Executable: C:\Python26\python.exe Python Version: 2.6.2 Python Path: ['C:\\Documents and Settings\\GeoffK\\My Documents\ \Millstream\\mysite', 'C:\\Python26\\lib\\site-packages\ \setuptools-0.6c9-py2.6.egg', 'C:\\Python26\\lib\\site-packages\ \django_authopenid-1.0-py2.6.egg', 'C:\\Python26\\lib\\site-packages\ \python_openid-2.2.4-py2.6.egg', 'C:\\Python26\\lib\\site-packages\ \recaptcha_client-1.0.3-py2.6.egg', 'C:\\Python26\\lib\\site-packages\ \django_registration-0.7-py2.6.egg', 'C:\\WINDOWS\\system32\ \python26.zip', 'C:\\Python26\\DLLs', 'C:\\Python26\\lib', 'C:\ \Python26\\lib\\plat-win', 'C:\\Python26\\lib\\lib-tk', 'C:\ \Python26', 'C:\\Python26\\lib\\site-packages'] Server time: Fri, 3 Jul 2009 07:34:11 +0100 Traceback Switch to copy-and-paste view C:\Python26\lib\site-packages\django\core\handlers\base.py in get_response response = callback(request, *callback_args, **callback_kwargs) ... ▶ Local vars C:\Documents and Settings\GeoffK\My Documents\Millstream\mysite\forum \views.py in gktest_save_page gk = request.gk .... etc =================== I have simplified the problem to this test: =================== models.py class GKtest(models.Model): gk = models.CharField(max_length=64) def __unicode__(self): return self.gk ================== forms.py from django.forms import ModelForm from forum.models import * .... class GKtestForm(ModelForm): class Meta: model = GKtest ====================== views.py from django.contrib.auth.forms import * from django.shortcuts import render_to_response as render from django.template import RequestContext, loader, Context from django.http import HttpResponse from django.template import Context from django.template.loader import get_template from django.http import HttpResponse, Http404 from django.contrib.auth.models import User from django.shortcuts import get_object_or_404 from django.http import HttpResponseRedirect from django.contrib.auth import logout from django.contrib.auth.decorators import login_required from forum.forms import * from forum.models import * ........ def gktest_save_page(request): if request.method == 'POST': # Creating a form to add a submission. form = GKtestForm(request.POST) if form.is_valid(): gktest, created = GKtest.objects.get_or_create( gk = request.gk ) gktest.save() return HttpResponseRedirect( '/gktest/' ) else: form = GKtestForm() variables = RequestContext(request, { 'form': form }) return render('gktest_save.html', variables) ================================== gktest_save.html {% extends "base.html" %} {% block title %}Save GKtest{% endblock %} {% block head %}Save GKtest{% endblock %} {% block content %} <form method="post" action="."> {{ form.as_p }} <input type="submit" value="save" /> </form> {% endblock %} ============================== Presumably I have missed out something elementary? Any hints gratefully received. Regards Geoff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

