Where or what is the Transparency member in the tableslots you call below? I guess I forgot to ask for that previously. You may also want to check how your Align is defined (in choices=Align).
> > {%for tableslots in tableslots_list%} > > <text> {{tableslots.Transparency}} </text> > > {%endfor%} > > {%for querysetups in querysetups_list%} > > {{querysetups.dbTemp}} </text> > > {%endfor%} Lastly, for simple debugging purposes, you could comment out either one of the two above for loops (or even both). You mentioned the error occurs when looping through that, although I didn't get if it happens for both individually, or that you've only tried them together. If it happens in only one of the two for-loops, that makes it a lot easier to track down the problem. Oh, if listings get long, you could use http://dpaste.com/ for code listings. (Probably also helps with the indentation, because it appears a bit mixed up below). Cheers, Evert > hi this is my class for columnsetup and querysetup.. thanks a lot > for your help > > class columnSetup(models.Model): > name =models.CharField("Name",max_length=50) > width =models.IntegerField("Width",max_length=3) > align > =models.CharField("Align",max_length=1,choices=Align) > tableList =models.ManyToManyField(tableSlot) > > def __unicode__(self): > return self.name > > def save(self): # update lastupdate > in all possible DS setting > super(columnSetup, self).save() # Call the > "real" save() method. > > class Meta: > verbose_name = ('Column Setup') > > class Admin: > fields = ( > ('Column Setup', { > 'fields' : (('name', 'width', 'align'), 'tableList') > }), > ) > list_display=('name','width','align') > save_as=True > > class querySetup(models.Model): > sqlQue =models.CharField("SQL Query",max_length=200) > dbTemp =models.CharField("Database",max_length=50) > tableList =models.ManyToManyField(tableSlot) > > def __unicode__(self): > return self.sqlQue > > def save(self): # update lastupdate > in all possible DS setting > super(querySetup, self).save() # Call the "real" > save() method. > for tl in self.tableList.all(): > tl.setting.lastUpdate = datetime.now() > tl.setting.save() > > class Meta: > verbose_name = ('Query Setup') > > class Admin: > fields = ( > ('Query Setup', { > 'fields' : (('sqlQue','dbTemp'), 'tableList') > }), > ) > list_display=('sqlQue','dbTemp') > save_as=True > > > ----- Original Message ---- > From: Evert Rol <[EMAIL PROTECTED]> > To: django-users@googlegroups.com > Sent: Saturday, March 29, 2008 1:34:21 AM > Subject: Re: many to many field problem > > > > ds = DigitalSignage.objects.get(pk=ds_id) > > #Digital Signage config & setting > > setting = ds.setting > > textslots = ds.textslot_set.all() > > slots = ds.slot_set.all() > > tableslots = tableSlot.objects.filter(DS_List=ds) > > columnsetups = columnSetup.objects.filter(tableList=tableslots) > > querysetups = querySetup.objects.filter(tableList=tableslots) > > > > but bumps into another problems.. really headache when i call the > > columnsetups or querysetups it will gave me error > > > > {%for tableslots in tableslots_list%} > > <text> {{tableslots.Transparency}} </text> > > {%endfor%} > > {%for querysetups in querysetups_list%} > > {{querysetups.dbTemp}} </text> > > {%endfor%} > > > > Request Method: > > GET > > Request URL: > > http://localhost/reed/1/ds.xml > > Exception Type: > > InterfaceError > > Exception Value: > > Error binding parameter 0 - probably unsupported type. > > Exception Location: > > C:\Python25\lib\site-packages\django\db\backends\sqlite3\base.py in > > execute, line 133 > > Python Executable: > > C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe > > Python Version: 2.5.1 > > Bit of blank guessing from the error message, but there may just be > some awkward/exotic field in one of your models that sqlite cannot > handle; or it's a genuine Django backend bug. What do your model > definitions look like for columnSetup and querySetup? > > > > > > > thanks for reply, but i don't quite understand :( sorry i'm newbie > > > here.... > > > First my models.py is like this > > > class DigitalSignage(models.Model): > > > DS_ID = integerField() > > > > > > class tableSlot(models.Model): > > > ds_id =models.ManyToManyField(DigitalSignage) > > > > > > class columnSetup(models.Model): > > > tableList =models.ManyToManyField(tableSlot) > > > > > > so in my views.py like this: > > > > > > > > > > > ds = DigitalSignage.objects.get(pk=ds_id) > > > > Here, you are retrieving a single object, namely a DigitalSignage > (as > > defined in your model). > > The <m2m-relation>_set identifier will work for objects, as below. > > > > > > > > tableslots = ds.tableslot_set.all() > > > > Here, you're retrieving all tableslots, which results in a QuerySet. > > It is a QuerySet of your tableSlot model, but it's not the model > > itself. A QuerySet allows filtering, but you cannot directly > retrieve > > any of the relations defined in your models, since it's not the > model > > itself. > > Have another look at > > http://www.djangoproject.com/documentation/db-api/#many-to-many-relationships > > You'll see that the <m2m-relation>_set is used for an object, not a > > QuerySet. > > > > > > > > > > > columnsetups = tableslots.columnsetup_set.all() > > > > > > so now if i change upwards... that's mean my models.py should be > > > like this: > > > class DigitalSignage(models.Model): > > > DS_ID = integerField() > > > > > > class columnSetup(models.Model): > > > field1 = models.charField() > > > > > > class tableSlot(models.Model): > > > ds_id =models.ManyToManyField(DigitalSignage) > > > columnList =models.ManyToManyField(columnSetup) > > > > Changing your models has nothing to do with it. > > > > Therefore, continuing with the model defintion you originally had > (top > > of this mail), you should probably access things from the other > side: > > ds = DigitalSignage.objects.get(pk=ds_id) > > tableslots = tableSlot.objects.filter(ds_id=ds) # note: not using > > ds.id. See also note below > > > > Also, have another good luck at > > http://www.djangoproject.com/documentation/db-api/#lookups-that-span-relationships > > > > > > Lastly, I can suggest some renaming, to stay with the usage in > Python > > and Django. Has nothing to do with the problem, so consider it free > > (and possibly unwanted) advice: > > - model names start with a Capital (TableSlot instead of tableSlot); > > as you do for DigitalSignage. > > - m2m relations are often named as the plural of the relation they > > refer to. So ds_id should become something like digital_signages (or > > signages, if you consider that too long). In particular, the ds_id > > naming is rather badly chosen, since it should reflect an object, > not > > the database id of that object (don't think database-level, think > > object-level). It is indeed an id (integer) in the database, but if > > you would retrieve if from your model (through a_table_slot.ds_id), > > it'll show up as a DigitalSignage object, not a number. > > > > Good luck. > > > > > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. > > Try it now. > > > > > > Like movies? Here's a limited-time offer: Blockbuster Total Access > for one month at no cost. > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---