add index view; add Project and Issue models

This commit is contained in:
Lexi / Zoe 2019-03-20 23:35:33 +01:00
parent 6c43c8b360
commit 9d77a7d232
Signed by: binaryDiv
GPG Key ID: F8D4956E224DA232
7 changed files with 78 additions and 6 deletions

View File

@ -1,3 +1,6 @@
from django.contrib import admin
# Register your models here.
from .models import Project, Issue
admin.site.register(Project)
admin.site.register(Issue)

View File

@ -0,0 +1,39 @@
# Generated by Django 2.1.7 on 2019-03-20 22:34
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Issue',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
('text', models.TextField(blank=True)),
('create_date', models.DateTimeField(default=django.utils.timezone.now)),
],
),
migrations.CreateModel(
name='Project',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('project_key', models.CharField(max_length=16, unique=True)),
('name', models.CharField(max_length=200)),
('description', models.TextField(blank=True)),
],
),
migrations.AddField(
model_name='issue',
name='project',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='issues.Project'),
),
]

View File

@ -1,3 +1,21 @@
from django.db import models
from django.utils import timezone
# Create your models here.
class Project(models.Model):
project_key = models.CharField(max_length=16, unique=True)
name = models.CharField(max_length=200)
description = models.TextField(blank=True)
def __str__(self):
return self.name
class Issue(models.Model):
project = models.ForeignKey(Project, on_delete=models.CASCADE)
title = models.CharField(max_length=200)
text = models.TextField(blank=True)
create_date = models.DateTimeField(default=timezone.now)
def __str__(self):
return self.title

7
issues/urls.py Normal file
View File

@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index')
]

View File

@ -1,3 +1,6 @@
from django.shortcuts import render
# from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse('Hello Tofu.')

View File

@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'issues.apps.IssuesConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@ -105,7 +106,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True

View File

@ -14,8 +14,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import include, path
urlpatterns = [
path('issues/', include('issues.urls')),
path('admin/', admin.site.urls),
]