initial commit. displays simple hierarchy and lists of models. includes fixtures for initial data.

This commit is contained in:
2021-11-07 14:05:07 -06:00
parent a253c38bf0
commit 0f5c7d27e6
54 changed files with 1398 additions and 0 deletions

0
teams/__init__.py Normal file
View File

5
teams/admin.py Normal file
View File

@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import Team
# Register your models here.
admin.site.register(Team)

6
teams/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class TeamsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'teams'

View File

@@ -0,0 +1,96 @@
- model: teams.team
pk: 1
fields:
name: Chicago Firefighters
- model: teams.team
pk: 2
fields:
name: Boston Flowers
- model: teams.team
pk: 3
fields:
name: Philly Pies
- model: teams.team
pk: 4
fields:
name: Yellowstone Magic
- model: teams.team
pk: 5
fields:
name: Tokyo Lift
- model: teams.team
pk: 6
fields:
name: Unlimited Tacos
- model: teams.team
pk: 7
fields:
name: Dallas Steaks
- model: teams.team
pk: 8
fields:
name: Charleston Shoe Thieves
- model: teams.team
pk: 9
fields:
name: Hades Tigers
- model: teams.team
pk: 10
fields:
name: Hellmouth Sunbeams
- model: teams.team
pk: 11
fields:
name: San Francisco Lovers
- model: teams.team
pk: 12
fields:
name: Hawai'i Fridays
- model: teams.team
pk: 13
fields:
name: Breckenridge Jazz Hands
- model: teams.team
pk: 14
fields:
name: Houston Spies
- model: teams.team
pk: 15
fields:
name: New York Millennials
- model: teams.team
pk: 16
fields:
name: Kansas City Breath Mints
- model: teams.team
pk: 17
fields:
name: Mexico City Wild Wings
- model: teams.team
pk: 18
fields:
name: Miami Dale
- model: teams.team
pk: 19
fields:
name: Seattle Garages
- model: teams.team
pk: 20
fields:
name: Canada Moist Talkers
- model: teams.team
pk: 21
fields:
name: Atlantis Georgias
- model: teams.team
pk: 22
fields:
name: Ohio Worms
- model: teams.team
pk: 23
fields:
name: Core Mechanics
- model: teams.team
pk: 24
fields:
name: Baltimore Crabs

View File

@@ -0,0 +1,23 @@
# Generated by Django 3.2.6 on 2021-11-07 17:43
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Team',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50)),
('image', models.FileField(null=True, upload_to='images/', validators=[django.core.validators.FileExtensionValidator(['jpg', 'png', 'svg'])])),
],
),
]

View File

9
teams/models.py Normal file
View File

@@ -0,0 +1,9 @@
from django.db import models
from django.core.validators import FileExtensionValidator
class Team(models.Model):
name = models.CharField(max_length = 50)
image = models.FileField(upload_to='images/', validators=[FileExtensionValidator(['jpg', 'png', 'svg'])], null=True)
def __str__(self):
return f"{self.name}"

View File

@@ -0,0 +1,13 @@
{% load bootstrap5 %}
{% bootstrap_css %}
{% bootstrap_javascript %}
<Title>Teams</Title>
<h1>Teams</h1>
<ol>
{% for team in teams %}
<li>
{{ team.name }}
</li>
{% endfor %}
</ol>

10
teams/urls.py Normal file
View File

@@ -0,0 +1,10 @@
from django.contrib import admin
from django.urls import path, include
from . import views
urlpatterns = [
path('', views.root, name="root"),
path('list', views.list, name="teams_list")
]

9
teams/views.py Normal file
View File

@@ -0,0 +1,9 @@
from django.shortcuts import render, redirect
from .models import Team
def root(request):
return redirect('/teams/list')
def list(request):
teams = Team.objects.all()
return render(request, 'teams/list.html', {'teams': teams})