(self)
return urls[0].url if urls else None
The main URL of the model
The main URL of the model
The main URL of the model
def url(self):
        """The main URL of the model"""
        # We could also use self.urls.first() here, but this would result in a
        # different query and would render a .prefetch_related('urls') useless
        # The assumption is that we will never have loads of URLS, so
        # fetching all won't hurt
        urls = list(self.urls.all())
        return urls[0].url if urls else None
def url ( self ) : # We could also use self.urls.first() here, but this would result in a # different query and would render a .prefetch_related('urls') useless # The assumption is that we will never have loads of URLS, so # fetching all won't hurt urls = list ( self . urls . all ( ) ) return urls [ 0 ] . url if urls else None