models.py 611 Bytes
Newer Older
1
from django.db import models
Jean Michel Rouly's avatar
Jean Michel Rouly committed
2
3
from django.contrib.auth.models import User
from django.utils import timezone
4
5

# Create your models here.
Jean Michel Rouly's avatar
Jean Michel Rouly committed
6
class URL( models.Model ):
Jean Michel Rouly's avatar
Jean Michel Rouly committed
7
    owner = models.ForeignKey( User )
Jean Michel Rouly's avatar
Jean Michel Rouly committed
8
9
    date_created = models.DateTimeField( default=timezone.now() )

Jean Michel Rouly's avatar
Jean Michel Rouly committed
10
    target = models.URLField( max_length = 1000 )
11
    short = models.CharField( primary_key = True, max_length = 20 )
Jean Michel Rouly's avatar
Jean Michel Rouly committed
12
    clicks = models.IntegerField( default = 0 )
13
    expires = models.DateTimeField( blank = True, null = True )
14
15
16
17
18
19

    def __unicode__(self):
        return '<URL: %s>' % self.short

    class Meta:
        ordering = ['short']