Skip to content

Commit eab2e89

Browse files
ToDo webapp using Django, made perfectly!
1 parent 649aed7 commit eab2e89

File tree

17 files changed

+400
-0
lines changed

17 files changed

+400
-0
lines changed
Binary file not shown.
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_site.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()

nitkarshchourasia/django_projects/ToDo_webapp/todo/__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 Todo
3+
4+
# Register your models here.
5+
6+
admin.site.register(Todo)
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 TodoConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "todo"
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 .models import Todo
3+
4+
5+
class TodoForm(forms.ModelForm):
6+
class Meta:
7+
model = Todo
8+
fields = "__all__"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Generated by Django 4.2.5 on 2023-09-30 16:11
2+
3+
from django.db import migrations, models
4+
import django.utils.timezone
5+
6+
7+
class Migration(migrations.Migration):
8+
initial = True
9+
10+
dependencies = []
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name="Todo",
15+
fields=[
16+
(
17+
"id",
18+
models.BigAutoField(
19+
auto_created=True,
20+
primary_key=True,
21+
serialize=False,
22+
verbose_name="ID",
23+
),
24+
),
25+
("title", models.CharField(max_length=100)),
26+
("details", models.TextField()),
27+
("date", models.DateTimeField(default=django.utils.timezone.now)),
28+
],
29+
),
30+
]

nitkarshchourasia/django_projects/ToDo_webapp/todo/migrations/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import Any
2+
from django.db import models
3+
from django.utils import timezone
4+
5+
# Create your models here.
6+
7+
8+
class Todo(models.Model):
9+
title = models.CharField(max_length=100)
10+
details = models.TextField()
11+
date = models.DateTimeField(default=timezone.now)
12+
13+
def __str__(self) -> str:
14+
return self.title
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<!DOCTYPE html>
2+
<html lang="en" dir="ltr">
3+
4+
<head>
5+
6+
<meta charset="utf-8">
7+
<title>{{title}}</title>
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
10+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
11+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
12+
<!--style-->
13+
<style>
14+
.card {
15+
16+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.5),
17+
0 6px 20px 0 rgba(0, 0, 0, 0.39);
18+
background: lightpink;
19+
margin-bottom: 5%;
20+
border-radius: 25px;
21+
padding: 2%;
22+
overflow: auto;
23+
resize: both;
24+
text-overflow: ellipsis;
25+
}
26+
27+
.card:hover {
28+
background: lightblue;
29+
}
30+
31+
.submit_form {
32+
33+
text-align: center;
34+
padding: 3%;
35+
background: pink;
36+
border-radius: 25px;
37+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.4),
38+
0 6px 20px 0 rgba(0, 0, 0, 0.36);
39+
}
40+
</style>
41+
42+
</head>
43+
44+
<body class="container-fluid">
45+
46+
{% if messages %}
47+
{% for message in messages %}
48+
<div class="alert alert-info">
49+
<strong>{{message}}</strong>
50+
</div>
51+
{% endfor %}
52+
{% endif %}
53+
54+
<center class="row">
55+
<h1><i>__TODO LIST__</i></h1>
56+
<hr />
57+
</center>
58+
59+
<div class="row">
60+
61+
<div class="col-md-8">
62+
63+
{% for i in list %}
64+
<div class="card">
65+
<center><b>{{i.title}}</b></center>
66+
<hr />
67+
{{i.date}}
68+
<hr />
69+
{{i.details}}
70+
<br />
71+
<br />
72+
<form action="/del/{{i.id}}" method="POST" style=" padding-right: 4%; padding-bottom: 3%;">
73+
{% csrf_token %}
74+
<button value="remove" type="submit" class="btn btn-primary" style="float: right;"><span
75+
class="glyphicon glyphicon-trash"></span> remove</button>
76+
</form>
77+
</div>
78+
{% endfor%}
79+
</div>
80+
<div class="col-md-1"> </div>
81+
<div class="col-md-3">
82+
<div class="submit_form">
83+
<form method="POST">
84+
{% csrf_token %}
85+
{{forms}}
86+
<center>
87+
<input type="submit" class="btn btn-default" value="submit" />
88+
</center>
89+
</form>
90+
</div>
91+
</div>
92+
</div>
93+
</body>
94+
95+
</html>

0 commit comments

Comments
 (0)