It's been a while since I've used Django (trying to get back into it),
but unless the API has changed dramatically since then, you should be
able to do something like:

def __str__(self):
    return 'Color: %s, Size: %s, Price: %s' % (self.color, self.size,
self.price)

Of course, change the string to suit your own tastes. I had a Person
class and wanted to have them displayed like "last name, first name"
if both names were filled in, but leave out the comma if I only had a
last name. So I did:

    def __str__(self):
        if self.first_name:
            return '%s, %s' % (self.last_name, self.first_name)
        else:
            return self.last_name

Sorry, I haven't yet used SlugField or the 'prepopulate_from'
shortcut, so I don't have any advice on your troubles there.

Good luck,

John-Scott Atlakson

On May 21, 12:01 am, Greg <[EMAIL PROTECTED]> wrote:
> I have the following model
>
> class sdetails(models.Model):
>         color = models.ForeignKey(color)
>         size = models.ForeignKey(size)
>         price = models.ForeignKey(price)
>         theslug = models.SlugField(prepopulate_from=("color", "size",
> "price"))
>
>         class Admin:
>                 pass
>
>         def __str__(self,):
>                 return str(self.size)
>
> However, when I add a new entry and I select a value for each
> ForeignKeys the SlugField doesn't get populated.  The reason why I
> want this is because I don't know how to return multiple fields.
> Right now I have  'return str(self.size)'.  Is there a way that I can
> return color, size, and and price.  For example I would like to have
> something like 'return str(self.color, self.size, self.price)'.


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