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 other objects.

On May 22, 12:43 pm, Greg <[EMAIL PROTECTED]> wrote:
> 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
>
> [<Choice: 89b>, <Choice: 89b>, <Choice: 89b>]
>
>
>
> What do I need to type into the shell prompt to get all the sizes and
> colors associated with style 89b.  I currently have 3 sizes and colors
> associated with style 89b, but I can't seem to figure out how to
> access them.  a.size, a[size], etc....
>
> Here are my model files.
>
> class Style(models.Model):
>     name = models.CharField(maxlength=200)
>     theslug = models.SlugField(prepopulate_from=('name',))
>
>     class Admin:
>         search_fields = ['name']
>
>     def __str__(self,):
>         return self.name
>
> class Choice(models.Model):
>     choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> num_in_admin=5)
>     size = models.ForeignKey(Size, core=True)
>     price = models.ForeignKey(Price, core=True)
>
>     def __str__(self,):
>         return str(self.choice)
>
> Thanks
>
> On May 22, 2:41 am, "Vance Dubberly" <[EMAIL PROTECTED]> wrote:
>
> > 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 out everytime I try to see the contents of the table.
>
> > > In my python shell prompt I do the following and get the error
>
> > > C:\django\mysite>python manage.py shell
> > > (InteractiveConsole)
> > > >>> from mysite.rugs.models import Choice
> > > >>> c = Choice.objects.all()
> > > >>> c
> > > Traceback (most recent call last):
> > >   File "<console>", line 1, in ?
> > >   File "c:\Python24\lib\site-packages\django\db\models\query.py", line
> > > 102, in _
> > > _repr__
> > >     return repr(self._get_data())
> > >   File "c:\Python24\lib\site-packages\django\db\models\base.py", line
> > > 86, in __r
> > > epr__
> > >     return '<%s: %s>' % (self.__class__.__name__, self)
> > > TypeError: __str__ returned non-string (type Style)
>
> > > Here are my choice models file
>
> > > class Choice(models.Model):
> > >     choice = models.ForeignKey(Style, edit_inline=models.TABULAR,
> > > num_in_admin=5)
> > >     size = models.ForeignKey(Size, core=True)
> > >     price = models.ForeignKey(Price, core=True)
>
> > >     def __str__(self,):
> > >         return self.choice
>
> > > Does anybody know why I can't display the data in the table?
>
> > --
> > To pretend, I actually do the thing: I have therefore only pretended to 
> > pretend.
> >   - Jacques Derrida- Hide quoted text -
>
> > - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
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