Skip to content

Commit 6cbae2e

Browse files
committed
My Todo App
1 parent 1d9f69b commit 6cbae2e

File tree

19 files changed

+386
-0
lines changed

19 files changed

+386
-0
lines changed

Code/renan/django/todo/manage.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_proj.settings')
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

Code/renan/django/todo/todo_app/__init__.py

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.contrib import admin
2+
from .models import *
3+
# Register your models here
4+
admin.site.register(Task)
5+
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class TodoAppConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'todo_app'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django import forms
2+
from django.forms import ModelForm
3+
from .models import *
4+
5+
class TaskForm(forms.ModelForm):
6+
class Meta:
7+
model = Task
8+
fields = '__all__'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 4.0.3 on 2022-04-15 03:27
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Task',
16+
fields=[
17+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('title', models.CharField(max_length=200)),
19+
('complete', models.BooleanField(default=False)),
20+
('created', models.DateTimeField(auto_now_add=True)),
21+
],
22+
),
23+
]

Code/renan/django/todo/todo_app/migrations/__init__.py

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.db import models
2+
3+
# Create your models here.
4+
class Task(models.Model):
5+
title = models.CharField(max_length=200)
6+
complete = models.BooleanField(default=False)
7+
created = models.DateTimeField(auto_now_add=True)
8+
9+
10+
def __str__(self):
11+
return self.title
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Delete</title>
8+
</head>
9+
<body>
10+
<p>Do You Really Want to Delete {{item}}</p>
11+
<a href="{%url 'index'%}">Cancel</a>
12+
13+
<form method="POST" action="">
14+
{% csrf_token %}
15+
<input type="submit" name="Confirm">
16+
</form>
17+
</body>
18+
</html>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<h1>Todo</h1>
11+
12+
<form method="POST" action="">
13+
{% csrf_token %}
14+
{{form.title}}
15+
16+
</form>
17+
18+
{% for task in tasks %}
19+
<div>
20+
21+
<a href="{% url 'update' task.id %}">Update</a>
22+
<a href="{% url 'delete' task.id %}">Delete</a>
23+
24+
{% if task.complete %}
25+
<strike>{{task}}</strike>
26+
{% else %}
27+
<span>{{task}}</span>
28+
29+
{% endif %}
30+
</div>
31+
32+
{% endfor %}
33+
34+
35+
</body>
36+
</html>

0 commit comments

Comments
 (0)