Hello,

I have a page displaying a list of "Data" objects and I placed at the
same page a "submit" button opening a form that updates the "Data"
table at DB. Pretty simple.

class Thing(models.Model):
    thing_id = models.BigIntegerField(primary_key=True)
    etc...

class Data(models.Model):
    data_id = models.AutoField(primary_key=True)
    thing = models.ForeignKey(Thing)
    key = models.CharField(max_length=200, blank=False)
    value = models.CharField(max_length=200, blank=False)
    def __unicode__(self):
        return unicode(self.thing)

I've created then a form:

class DataForm(ModelForm):
    class Meta:
        model = Data


At my template I've added:

<form action="/submit/" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>

The issue,
I get the following after clicking "Submit":

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/django/core/servers/basehttp.py",
line 280, in run
    self.result = application(self.environ, self.start_response)
  File "/usr/lib/pymodules/python2.7/django/core/servers/basehttp.py",
line 674, in __call__
    return self.application(environ, start_response)
  File "/usr/lib/pymodules/python2.7/django/core/handlers/wsgi.py",
line 252, in __call__
    response = middleware_method(request, response)
  File "/usr/lib/pymodules/python2.7/django/middleware/csrf.py", line
221, in process_response
    if response['Content-Type'].split(';')[0] in _HTML_TYPES:
  File "/usr/lib/pymodules/python2.7/django/forms/forms.py", line 106,
in __getitem__
    raise KeyError('Key %r not found in Form' % name)
KeyError: "Key 'Content-Type' not found in Form"


I've already added at settings.py:
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.middleware.csrf.CsrfResponseMiddleware',

p.s.
I've also tried to change my models using use the contenttypes
framework - but it didn't help. I got the same error.

Any help will be really appreciated!

Thanks in advance.


-- 
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