Hi, You need to implement the save() method in your custom manipulator. Cheers
On 7/14/06, Robert <[EMAIL PROTECTED]> wrote: > > Hello, > > When using custom Manipulator (which in fact does nothing.. I've cut > some additional custom validation here) I'm getting error as follows: > ---------------- > Traceback (most recent call last): > File > "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/handlers/base.py" > in get_response > 74. response = callback(request, *callback_args, **callback_kwargs) > File "/usr/local/www/data/django/projects/pbook/../pbook/book/views.py" > in create_entry > 23. new_entry = manipulator.save(new_data) > File > "/usr/local/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/forms/__init__.py" > in save > 92. raise NotImplementedError > > NotImplementedError at / > ----------------- > > Python 2.4.2, DB: SQLite, svn from trunk as of July 13th > > Error occurs on POST when submitting, I am able to see & fill in the > form. > > This is my code: > > ---> book/models.py > from django.db import models > > class Entry(models.Model): > name = models.CharField(blank=False, maxlength=30) > last = models.CharField(blank=False, maxlength=50) > nr = models.IntegerField(unique=True, blank=True, maxlength=10) > nr_mobile = models.IntegerField(unique=True, blank=True, > maxlength=9) > > def __str__(self): > return self.name > > class Admin: > pass > > --> book/views.py > from django.shortcuts import render_to_response > from django.core import validators > from django import forms > from pbook.book.models import Entry > from django.http import Http404, HttpResponse, HttpResponseRedirect > > def create_entry(request): > manipulator = EntryManipulator() > > if request.POST: > new_data = request.POST.copy() > > errors = manipulator.get_validation_errors(new_data) > > if not errors: > manipulator.do_html2python(new_data) > new_entry = manipulator.save(new_data) > return HttpResponse("Entry created: %s" % new_entry) > else: > errors = new_data = {} > > form = forms.FormWrapper(manipulator, new_data, errors) > return render_to_response('book/entry_form.html', {'form': form }) > > class EntryManipulator(forms.Manipulator): > def __init__(self): > self.fields = ( > forms.TextField(field_name='name', > is_required=True, maxlength=30), > forms.TextField(field_name='last', > is_required=True, maxlength=50), > forms.IntegerField(field_name='nr', > maxlength=10), > forms.IntegerField(field_name='nr_mobile', > maxlength=9), > ) > > ---> urls.py > from django.conf.urls.defaults import * > from pbook.book.models import Entry > > urlpatterns = patterns('', > (r'^$', 'pbook.book.views.create_entry'), > (r'^admin/', include('django.contrib.admin.urls')), > ) > > ---> templates/book/entry_form.html > {% if form.has_errors %} > <h2>Please correct the following error{{ form.error_dict|pluralize > }}:</h2> > {% endif %} > > <form method="post" action="."> > <p> > <label for="id_imie">Name:</label> {{ form.name }} > {% if form.name.errors %}*** {{ form.name.errors|join:", " }}{% > endif %} > </p> > <p> > <label for="id_last">Last:</label> {{ form.last }} > {% if form.last.errors %}*** {{ form.last.errors|join:", " }}{% > endif %} > </p> > <p> > <label for="id_nr">Phone nr:</label> {{ form.nr }} > {% if form.nr.errors %}*** {{ form.nr.errors|join:", " }}{% endif > %} > </p> > <p> > <label for="id_nr_mobile">Mobile nr:</label> {{ form.nr_mobile }} > {% if form.nr_mobile.errors %}*** {{ form.nr_mobile.errors|join:", > " }}{% endif %} > </p> > <input type="submit" /> > </form> > > Thanks, > Robert > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---