Friday, May 24, 2013

object is not iterable

Hello all,

I have an insoluble problem when I try to use the formsets...

This is my models:
class Relais(models.Model): 
nom = models.CharField(max_length=100,blank=True)
competition = models.ForeignKey(Competition)
sport = models.ForeignKey(Sport)
ordre = models.IntegerField()

def __unicode__(self):
if self.nom:
return self.nom 
else:
return "%s - %d - %s" % (self.competition.nom,self.ordre,self.sport.nom)

my forms.py:
class RelaisForm(ModelForm):
class Meta:
model = Relais

and the part of my views.py which cause this problem:
        relaisList = competition.relais_set.all()
RelaisFormSet = formset_factory(RelaisForm)
formset = RelaisFormSet(initial=relaisList) # <== this line


The error is:
Exception Type:TypeError
Exception Value:
'Relais' object is not iterable



Have you got an idea on what cause this problem ?
Thank you ;)

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate