Hi All,

I've been studying Django over this weekend and so far its really
amazing and the kind of thing which makes you say its about damn time
someone made something so cool :)

However, I was saddened a bit to know that some of the very very cool
features have not been released yet and are under development. I can't
wait for the Newform-admin functionality, instantiable admin site.
Update/create/delete generic templates still use the old forms. The
NewForms use FormPreview instead

FormPreview is however is a very under-documented feature; it does
have instructions in its code:
http://code.djangoproject.com/browser/django/trunk/django/contrib/formtools/preview.py
but I can't seem to get this stuff to work. Can anyone share a working
copy/sample code using this stuff? Here's mine but it doesn't quite
work:

(its test/learning scrap code, so forgive the very horrible code
mixing)

models.py

from django.db import models

class Company(models.Model):
        class Admin:
                pass

        def __str__(self):
                return self.name

        name = models.CharField(maxlength=200)

class Contact(models.Model):

        created_by = models.CharField(maxlength=200)
        created_on = models.DateTimeField()
        first_name = models.CharField(maxlength=200)
        last_name = models.CharField(maxlength=200)
        title = models.CharField(maxlength=200)
        company = models.ForeignKey(Company)
        background = models.TextField()

        class Admin:
                pass

        def __str__(self):
                return "%s %s" % (self.first_name, self.last_name)

in urls.py

from django.conf.urls.defaults import *
from cases.todo.models import *
from django.newforms import form_for_model
from django.contrib.formtools.preview import FormPreview

class MyForm(FormPreview):
        def done(request, cleaned_data):
                return HttpResponseRedirect('/')

ContactForm=form_for_model(Contact)
c=ContactForm(Contact.objects.get(id=1).__dict__)

urlpatterns = patterns('',
        (r'^post/$', MyForm(c)),
        (r'^admin/', include('django.contrib.admin.urls')),
)

but when I run

//127.0.0.1:8000/post

I get


Traceback (most recent call last):
File "c:\Python24\Lib\site-packages\django\core\handlers\base.py" in
get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "c:\Python24\Lib\site-packages\django\contrib\formtools
\preview.py" in __call__
  74. return method(request)
File "c:\Python24\Lib\site-packages\django\contrib\formtools
\preview.py" in preview_get
  94. f = self.form(auto_id=AUTO_ID)

  TypeError at /post/
  'ContactForm' object is not callable

I'm new to both django and python, so I could be doing something wrong
which could be painfully simple. Thank you all for your patience


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to