add models to django

This commit is contained in:
Norbert 2020-02-02 03:45:16 +01:00
parent e4395ccc4f
commit 17296c870b
22 changed files with 85 additions and 3 deletions

View File

@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'imguploader.apps.ImguploaderConfig',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -103,9 +104,9 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/ # https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'pl'
TIME_ZONE = 'UTC' TIME_ZONE = 'CET'
USE_I18N = True USE_I18N = True

View File

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

Binary file not shown.

View File

View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class ImguploaderConfig(AppConfig):
name = 'imguploader'

View File

@ -0,0 +1,40 @@
# Generated by Django 3.0.2 on 2020-02-02 02:41
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Competitions',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('comp_slug', models.CharField(max_length=100)),
('comp_name', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='Photo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('url', models.CharField(max_length=50)),
('comp_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='imguploader.Competitions')),
],
),
migrations.CreateModel(
name='PhotoMeta',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('meta_key', models.CharField(max_length=50)),
('meta_value', models.CharField(max_length=50)),
('photo_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='imguploader.Photo')),
],
),
]

View File

@ -0,0 +1,15 @@
from django.db import models
# Create your models here.
class Competitions(models.Model):
comp_slug = models.CharField(max_length=100)
comp_name = models.CharField(max_length=100)
class Photo(models.Model):
comp_id = models.ForeignKey(Competitions, on_delete=models.CASCADE)
url = models.CharField(max_length=50)
class PhotoMeta(models.Model):
photo_id = models.ForeignKey(Photo, on_delete=models.CASCADE)
meta_key = models.CharField(max_length=50)
meta_value = models.CharField(max_length=50)

View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

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

View File

@ -0,0 +1,7 @@
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse("Hello, world. This is imageUploader")