Everybody knows about
permalink, but it's usually used only in
get_absolute_url. I prefer to use it for all related model urls.
class Event(models.Model): # ... @models.permalink def edit_url(self): return ('event_edit', (self.pk, ))
And then in template:
It appears that not everyone knows that in python you can create classes dynamically without metaclasses. I'll show an example of how to do it.So we've learned how to use custom QuerySet to chain requests:Article.objects.old().public()Now we need to make it work for related objects:user.articles.old().public()This is done using use_for_related_fields, but it needs a little trick.
Welcome all who are reading this article. I was given a task of creating a parser (spider) with the Scrapy library and parsing FTP server with data. The parser had to find lists of files on the server and handle each file separately depending on the requirement to the parser.