Django Custom Managers

class PreprintAuthor(models.Model):
preprint = models.ForeignKey('Preprint')
author = models.ForeignKey('Author')
order = models.PositiveIntegerField(default=0)
{% for preprint in preprints %}
{{ preprint.preprintauthor_set.0.author.full_name }}
{% endfor %}
class PreprintAuthorManager(models.Manager):
def get_queryset(self):
return super().get_queryset().select_related('author')
class PreprintAuthor(models.Model):
preprint = models.ForeignKey('Preprint')
author = models.ForeignKey('Author')
order = models.PositiveIntegerField(default=0)
objects = PreprintAuthorManager()

 by the author.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andy Byers

Andy Byers

Pub Tech developer for Birkbeck CTP