aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
authorAlban Gruin2017-01-26 13:18:14 +0100
committerAlban Gruin2017-01-26 13:18:14 +0100
commit46e4a2d58503dd7c97056a4e543edcbc4e4ca353 (patch)
tree0b3f827383e30751a5ee9f6788c1d42176c7809a /models.py
parent7b738361bfac4132c3b563e0922d318d65909d38 (diff)
Ajout d'un extracteur de semaine pour les DateTimeField.
Il marche pour PostgreSQL. Pour SQLite, on devra passer par une requĂȘte brute.
Diffstat (limited to 'models.py')
-rw-r--r--models.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/models.py b/models.py
index 18e0246..62274d2 100644
--- a/models.py
+++ b/models.py
@@ -1,11 +1,17 @@
from django.db import models
from django.db.models import Q
+from django.db.models.functions import Extract
from django.utils.text import slugify
import hashlib
import os
+@models.DateTimeField.register_lookup
+class ExtractWeek(Extract):
+ lookup_name = "week"
+
+
class Timetable(models.Model):
name = models.CharField(max_length=64, unique=True, verbose_name="nom")
url = models.URLField(max_length=255, unique=True, verbose_name="URL")