c = Choice.objects.filter(choice=1)
c
> [, , ]
c.size.name
> Traceback (most recent call last):
> File "", line 1, in ?
> AttributeError: 'QuerySet' object has no attribute 'size'
>
> I still can't access the size and price's tied to style number 89b. I
> thought that c.size.nam
> >>> from mysite.rugs.models import Choice, Size, Price
> >>> c = Choice.objects.filter(choice=1)
> >>> c
> [, , ]
You can see here that your queryset maps to three objects.
> >>> c.size.name
> Traceback (most recent call last):
> File "", line 1, in ?
> AttributeError: 'QuerySet' object has
Carole,
I've tried what you suggeted and it still didn't work. I haven't
changed my db structure. Here is what I get when I do it in the
command prompt
>>> from mysite.rugs.models import Choice, Size, Price
>>> c = Choice.objects.filter(choice=1)
>>> c
[, , ]
>>> c.size.name
Traceback (most rec
Ok...then it would be soemthing like this:
choices = Choice.objects.filter(choice=1)
for choice in choices: # you used filter, not get so I'm assuming
this is not the primary key and you are getting multiple objects back
a.size.name
a.price.name
However...if your size/price tables all jus
Ok...then it would be soemthing like this:
choices = Choice.objects.filter(choice=1)
for choice in choices: # you used filter, not get so I'm assuming
this is not the primary key and you are getting multiple objects back
a.size.name
a.price.name
However...if your size/price tables all jus
Ok...then it would be soemthing like this:
choices = Choice.objects.filter(choice=1)
for choice in choices: # you used filter, not get so I'm assuming
this is not the primary key and you are getting multiple objects back
a.size.name
a.price.name
However...if your size/price tables all jus
Ok...then it would be soemthing like this:
choices = Choice.objects.filter(choice=1)
for choice in choices: # you used filter, not get so I'm assuming
this is not the primary key and you are getting multiple objects back
a.size.name
a.price.name
However...if your size/price tables all jus
Yea, I'm not sure why I used choice as the field name. I probably
should of used style. Anyway, here are all my models
class Size(models.Model):
name = models.CharField(maxlength=100)
def __str__(self,):
return self.name
class Admin:
pas
What does the model code look like for Size,Price?
Also,
choice = models.ForeignKey(Style,
edit_inline=models.TABULAR,num_in_admin=5)
Did you mean for that to be:
style = models.ForeignKey(Style,
edit_inline=models.TABULAR,num_in_admin=5)
Just curious..as then it would be consistent with the
Vance,
Ok...that worked. However, I have a new problem. I'm not sure how to
display all the sizes and colors of a particular rug. In my shell
python I do the following
>>> a = Choice.objects.filter(choice=1)
>>> a
[, , ]
>>>
What do I need to type into the shell prompt to get all the sizes an
Vance,
Ok...that worked. However, I have a new problem. I'm not sure how to
display all the sizes and colors of a particular rug. In my shell
python I do the following
>>> a = Choice.objects.filter(choice=1)
>>> a
[, , ]
>>>
What do I need to type into the shell prompt to get all the sizes an
My bet would be that this little bit of code right here:
def __str__(self,):
return self.choice
the return of __str__ needs to be a string not an object.
Vance
On 5/21/07, Greg <[EMAIL PROTECTED]> wrote:
>
> I am trying to display the table in my Choice table. However it's
> error's ou
12 matches
Mail list logo