Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finished #352

Open
wants to merge 4 commits into
base: richard-django-lab-3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Code/Richard/django/lab-01/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Empty file.
7 changes: 7 additions & 0 deletions Code/Richard/django/lab-01/todo_app/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from .models import Priority, TodoItem

# Register your models here.

admin.site.register(Priority),
admin.site.register(TodoItem)
6 changes: 6 additions & 0 deletions Code/Richard/django/lab-01/todo_app/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class TodoAppConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'todo_app'
31 changes: 31 additions & 0 deletions Code/Richard/django/lab-01/todo_app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 4.0 on 2021-12-31 02:35

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Priority',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=20)),
],
),
migrations.CreateModel(
name='TodoItem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('todo_item_text', models.CharField(max_length=200)),
('created_date', models.DateTimeField(auto_now_add=True)),
('priority', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='todoitems', to='todo_app.priority')),
],
),
]
Empty file.
23 changes: 23 additions & 0 deletions Code/Richard/django/lab-01/todo_app/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.db import models
from django.db.models.deletion import CASCADE
from django.db.models.fields import CharField
from django.db.models.fields.related import ForeignKey

# Create your models here.


class Priority(models.Model):
name = CharField(max_length=20)

def __str__(self):
return self.name


class TodoItem(models.Model):
todo_item_text = models.CharField(max_length=200)
priority = models.ForeignKey(Priority, on_delete=CASCADE, related_name='todoitems')

created_date = models.DateTimeField(auto_now_add=True)

def __str__(self):
return f"{self.todo_item_text}/n {self.priority} {self.created_date}"
Loading