S
S
s_katala2018-05-20 21:22:28
Django
s_katala, 2018-05-20 21:22:28

How to make a link to an article of this kind?

How to link an article like
mysite.com/1-my_article
mysite.com/2-my_article2
at the moment

def get_absolute_url(self):
  return reverse('posts:fullstory', kwargs={"pk": self.pk})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Web Dentist, 2018-05-21
@s_katala

Curve option -

class YourModel(...):
  ...
  AutoSlugField(populate_from='title')
  ...
  def get_abs_url(self):
    return ('/%s-%s/', % self.id ,%self.slug)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question