Quantcast
Channel: Active questions tagged feed - Stack Overflow
Viewing all articles
Browse latest Browse all 540

what is the differences between reverse and reverse_lazey methods in Django?

$
0
0

I can't use reverse() method in a class to generate url

for example, reverse() doesn't work in generic views or Feed classes (reverse_lazy() should be used instead)

but I can use reverse() in functions. what is the differences ?

take a look at following:

class LatestPostFeed(Feed):    title = 'My Django blog'    # link = reverse_lazy('blog:index')    description = 'New posts of my blog'    def items(self):        return models.Post.published.all()[:5]    def item_title(self, item):        return item.title    def item_description(self, item):        return truncatewords(item.body, 30)    def link(self):        return reverse('blog:index')

the link attribute above only works with reverse_lazy() method.but the link function works with both reverse_lazy() and reverse() methods


Viewing all articles
Browse latest Browse all 540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>