Skip to content

Commit

Permalink
Merge pull request #343 from PdxCodeGuild/richard-django-lab-01
Browse files Browse the repository at this point in the history
django lab-01
  • Loading branch information
perennialAutodidact authored Mar 12, 2022
2 parents fbe8dac + c2f5605 commit 8031c71
Show file tree
Hide file tree
Showing 17 changed files with 799 additions and 0 deletions.
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

0 comments on commit 8031c71

Please sign in to comment.