def shorturl_generate(sender, instance, created, **kwargs): if GENERATE_SHORT_URL: if not instance.short_url: instance.short_url = GooglUrlShort( instance.get_http_absolute_url() ).short() instance.save()
def save(self, *args, **kwargs): if not self.short_url: self.short_url = GooglUrlShort(self.get_http_absolute_url())\ .short() self.channel_name = self.channel.name self.channel_long_slug = self.channel.long_slug self.child_class = self.__class__.__name__ super(Article, self).save(*args, **kwargs)
def googlshort(url): uid = uuid.uuid3(uuid.NAMESPACE_DNS, url) cache_url = cache.get('googlshort_%s' % uid) if cache_url: return cache_url cache_url = GooglUrlShort(url).short(False) cache.set('googlshort_%s' % uid, cache_url) return cache_url
def save(self, *args, **kwargs): if not self.short_url: self.short_url = GooglUrlShort(self.get_http_absolute_url())\ .short()