django admin view on site don't use get_absolute_url

566 views Asked by At

I'm using default django admin. I registered models in admin.py,i define get_absolute_url in my models, but when i'm on editing form of my model button view on site redirect me to basic localhost:8000 no metter what i writing in get_absolute_url, it appears that admin didn't use it at all.

class Products(models.Model):
  name=models.CharField(max_length=30,unique=True)
  slug=models.CharField(max_length=30)
  description=models.TextField(max_length=200)
  price=models.FloatField()
  created_at=models.DateTimeField()
  modified_at=models.DateTimeField(blank=True,null=True)

  def __unicode__(self):
    return (self.name)

  def get_absolute_url(self):
    return '/foo/bar/'

decision:

def get_absolute_url(self):
    from products.views import single_product
    return reverse(single_product, args=[self.slug])
0

There are 0 answers