Thanks for such a quick reply Richard. Yep think it was a combination of not displaying and also not having an additional comma at the end of the prepopulate_from tuple.
On Aug 13, 10:26 pm, RichardH <[EMAIL PROTECTED]> wrote: > Mike, welcome to Django. > The prepopulate_from relies on Javascript in the admin pages, so only > works in the site admin interface. However you have also set > editable=False, so it will not be seen in the admin pages anyway.>From the > Model Reference documentation: > > "SlugField ... Accepts an extra option, prepopulate_from, which is a > list of fields from which to auto-populate the slug, via JavaScript, > in the object's admin form" > What you need is the slugify function from > django.template.defaultfilters in your save function to set the slug. > or there is an alternative at:http://www.djangosnippets.org/snippets/168/ > > Richard > > On Aug 13, 9:25 pm, MikeHowarth <[EMAIL PROTECTED]> wrote: > > > Hi > > > I was wondering whether anyone could help me, I just starting out with > > Django and am attempting to write a simple web app. Ideally I'd like > > to use a slug field populated based on the name of my product. > > > However the slug field is not being populated, my model looks like > > this: > > > class Product(models.Model): > > > name = models.CharField(maxlength=255) > > category = models.ForeignKey(Category) > > slug = > > models.SlugField(prepopulate_from=("name",),unique=True,editable=False) > > description = models.TextField() > > size = models.CharField(maxlength=50) > > price = models.FloatField(max_digits=5, decimal_places=2) > > delivery = models.ForeignKey(Delivery) > > in_stock = models.BooleanField() > > display = models.BooleanField() > > pub_date = models.DateTimeField(editable=False) > > > def __str__(self): > > return self.name > > > def save(self): > > if not self.id: > > self.pub_date = datetime.datetime.now() > > super(Product, self).save() > > > Any help would be greatly appreciated --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---