dodanie widoku i bd

This commit is contained in:
Jędrzej Klepacki 2020-12-03 19:32:50 +01:00
parent 9fab809f98
commit af00024fa4
16 changed files with 61 additions and 5 deletions

View File

@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'homepage.apps.HomepageConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@ -75,12 +76,16 @@ WSGI_APPLICATION = 'SocialHelper.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'socialhelperdb',
'USER': 'postgres',
'PASSWORD': 'admin',
'HOST': 'localhost'
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

Binary file not shown.

Binary file not shown.

View File

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

View File

@ -0,0 +1,28 @@
# Generated by Django 2.1.5 on 2020-12-03 18:24
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Product',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('create_date', models.DateField(default=datetime.date.today, verbose_name='Date')),
('user_owner', models.TextField(default='', max_length=40)),
('type', models.IntegerField(choices=[(1, 'Potrzebuje'), (2, 'Oddam')], default='')),
('title', models.TextField(default='', max_length=40)),
('description', models.TextField(default='', max_length=6000)),
('place', models.TextField(default='', max_length=40)),
('keywords', models.TextField(default='', max_length=6000)),
],
),
]

View File

@ -1,3 +1,16 @@
from django.db import models
import datetime
# Create your models here.
TYPE_T = (
(1,'Potrzebuje'),
(2,'Oddam'),
)
class Product(models.Model):
create_date = models.DateField(("Date"), default=datetime.date.today)
user_owner = models.TextField(max_length=40, blank=False, default="")
type = models.IntegerField(choices = TYPE_T, blank=False, default="")
title = models.TextField(max_length=40, blank=False, default="")
description = models.TextField(max_length=6000, blank=False, default="")
place = models.TextField(max_length=40, blank=False, default="")
keywords = models.TextField(max_length=6000, blank=False, default="")

View File

@ -0,0 +1,6 @@
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.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")