Sorry, I realized my own mistake a few hours later. The problem was that I copied and pasted the fields from my Model. The entities in my Form class were:
django.models instead of django.forms Changing this solved the problem. On Oct 23, 1:37 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'n new to django, and I am having trouble with forms: I tried > following the example on the web > page:http://docs.djangoproject.com/en/dev/topics/forms/#topics-forms-index > > I setup a quick unit test, but I am unable to get the desired result > with forms.Form. I replaced my forms.Form object with a ModelForm, and > it works fine. Unfortunately I need to use the standard Form, because > the form doesn't really match my model that much. > > I am using django1.0 > > Example 1: with forms > > from django import forms > > class UploadImageForm(forms.Form): > name = models.CharField(max_length=200) > notes = models.CharField(max_length=200) > image = models.ImageField(upload_to='images') > > import unittest > from django.test.client import Client > > class BasicTest(unittest.TestCase): > > def testStuff(self): > > u = UploadImageForm() > > print '****' > print u.as_p() > print '****' > > I ran mange.py test.... > > Output (nothing): > **** > > **** > > It is a forms.Form object. When I print out dir() I get all the other > object data, but for some reason as_p(), as_table(), etc... don't > produce any output. > > Example 2: with ModelForm > > from django.forms import ModelForm > > class UploadImageForm(ModelForm): > > class Meta: > fields = ('notes','image') > model = ImageResource #defined elsewhere > > This time, when I run the unit test, I get the following output (it > works): > > **** > <p><label for="id_notes">Notes:</label> <input id="id_notes" > type="text" name="notes" maxlength="200" /></p> > <p><label for="id_image">Image:</label> <input type="file" > name="image" id="id_image" /></p> > **** > > Any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

