Add simple tasks app.

This commit is contained in:
2023-07-12 20:28:00 +03:00
parent 15b73b0dbf
commit 7cb8cf4c54
14 changed files with 125 additions and 1 deletions
View File
+5
View File
@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import Task
admin.site.register(Task)
+7
View File
@@ -0,0 +1,7 @@
from django.apps import AppConfig
class TasksConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "tasks"
+41
View File
@@ -0,0 +1,41 @@
# Generated by Django 4.2.3 on 2023-07-12 17:15
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="Task",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=64)),
("description", models.TextField(max_length=5000)),
(
"status",
models.CharField(
choices=[
("TODO", "TODO"),
("DOING", "DOING"),
("DONE", "DONE"),
("CANCELED", "CANCELED"),
],
default="TODO",
max_length=8,
),
),
],
),
]
View File
+27
View File
@@ -0,0 +1,27 @@
from django.db import models
class Task(models.Model):
name = models.CharField(max_length=64)
description = models.TextField(max_length=5000)
# Constants for status
TODO = "TODO"
DOING = "DOING"
DONE = "DONE"
CANCELED = "CANCELED"
STATUSES = [
(TODO, "TODO"),
(DOING, "DOING"),
(DONE, "DONE"),
(CANCELED, "CANCELED"),
]
status = models.CharField(
max_length=8,
choices=STATUSES,
default=TODO,
)
def __str__(self):
return self.name
+2
View File
@@ -0,0 +1,2 @@
from django.test import TestCase
+10
View File
@@ -0,0 +1,10 @@
from django.conf.urls import include
from django.urls import path
from . import views
app_name = 'polls'
urlpatterns = [
path('', views.index, name='index'),
]
+6
View File
@@ -0,0 +1,6 @@
from django.shortcuts import render
def index(request):
context = {}
return render(request, 'tasks/index.html', context)