Spaces:
Sleeping
Sleeping
Commit
·
dd0091c
1
Parent(s):
4bcaa28
modelos actualizados
Browse files- Dockerfile +1 -1
- app/polls/models.py +13 -1
Dockerfile
CHANGED
@@ -13,7 +13,7 @@ RUN touch db.sqlite3
|
|
13 |
RUN ls -la
|
14 |
RUN chmod 777 db.sqlite3
|
15 |
RUN chmod 777 ./polls/migrations
|
16 |
-
|
17 |
CMD python3 manage.py makemigrations; \
|
18 |
python3 manage.py migrate; \
|
19 |
python3 manage.py runserver 0:7860
|
|
|
13 |
RUN ls -la
|
14 |
RUN chmod 777 db.sqlite3
|
15 |
RUN chmod 777 ./polls/migrations
|
16 |
+
|
17 |
CMD python3 manage.py makemigrations; \
|
18 |
python3 manage.py migrate; \
|
19 |
python3 manage.py runserver 0:7860
|
app/polls/models.py
CHANGED
@@ -1,12 +1,24 @@
|
|
|
|
|
|
1 |
from django.db import models
|
|
|
|
|
2 |
|
3 |
|
4 |
class Question(models.Model):
|
5 |
question_text = models.CharField(max_length=200)
|
6 |
pub_date = models.DateTimeField('date published')
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
class Choice(models.Model):
|
10 |
question = models.ForeignKey(Question, on_delete=models.CASCADE)
|
11 |
choice_text = models.CharField(max_length=200)
|
12 |
votes = models.IntegerField(default=0)
|
|
|
|
|
|
|
|
1 |
+
import datetime
|
2 |
+
|
3 |
from django.db import models
|
4 |
+
from django.utils import timezone
|
5 |
+
|
6 |
|
7 |
|
8 |
class Question(models.Model):
|
9 |
question_text = models.CharField(max_length=200)
|
10 |
pub_date = models.DateTimeField('date published')
|
11 |
+
|
12 |
+
def __str__(self):
|
13 |
+
return self.question_text
|
14 |
+
|
15 |
+
def was_published_recently(self):
|
16 |
+
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
|
17 |
|
18 |
class Choice(models.Model):
|
19 |
question = models.ForeignKey(Question, on_delete=models.CASCADE)
|
20 |
choice_text = models.CharField(max_length=200)
|
21 |
votes = models.IntegerField(default=0)
|
22 |
+
|
23 |
+
def __str__(self):
|
24 |
+
return self.choice_text
|