Commit a310f439 authored by Jean Michel Rouly's avatar Jean Michel Rouly
Browse files

Generate correct absolute url for urls models

parent 8e1f9ce8
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils import timezone from django.utils import timezone
from django.conf import settings
import random, string import random, string
...@@ -25,6 +26,9 @@ class URL( models.Model ): ...@@ -25,6 +26,9 @@ class URL( models.Model ):
class Meta: class Meta:
ordering = ['short'] ordering = ['short']
def get_absolute_url(self):
return "%s/%s" % (settings.SERVERURL, self.short)
@staticmethod @staticmethod
def generate_valid_short(): def generate_valid_short():
selection = string.ascii_lowercase + string.digits selection = string.ascii_lowercase + string.digits
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment