Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7주차 Assignment - 오동재 #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added dongjae/dongjaeprj/db.sqlite3
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from .models import Ex_Post
from .models import Ex2_Post

# Register your models here.
admin.site.register(Ex_Post)
admin.site.register(Ex2_Post)
6 changes: 6 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class DongjaeappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'dongjaeapp'
29 changes: 29 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.2.1 on 2023-05-24 13:13

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Ex_Post',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('content', models.TextField()),
('create_time', models.DateTimeField(auto_now_add=True)),
('updated_time', models.DateTimeField(auto_now=True)),
('only_time', models.TimeField(blank=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
28 changes: 28 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/migrations/0002_ex2_post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 4.2.1 on 2023-05-24 13:48

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('dongjaeapp', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Ex2_Post',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('content', models.TextField()),
('create_time', models.DateTimeField(auto_now_add=True)),
('updated_time', models.DateTimeField(auto_now=True)),
('only_time', models.TimeField(blank=True)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.db import models

# Create your models here.
class Ex_Post(models.Model):
user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
title = models.CharField(max_length=100)
content = models.TextField()
create_time = models.DateTimeField(auto_now_add=True)
updated_time = models.DateTimeField(auto_now=True)
only_time = models.TimeField(blank = True)

def __str__(self):
return self.title

class Ex2_Post(models.Model):
user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
title = models.CharField(max_length=100)
content = models.TextField()
create_time = models.DateTimeField(auto_now_add=True)
updated_time = models.DateTimeField(auto_now=True)
only_time = models.TimeField(blank = True)

def __str__(self):
return self.title
19 changes: 19 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/static/css/base.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
body {
background-color: antiquewhite;
}
p {
font-size: 15pt;
}
.img {
text-align: center;
}
.content1 {
display: flex;
justify-content: space-around;
}
.img img {
width: 300px;
}
.table table-striped {
margin: 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/templates/dongjae.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends 'main.html' %}

{% block title %}
<title>희망 포지션</title>
{% endblock %}

{% block content %}
<h1>희망 포지션</h1>
{% endblock %}

{% block content2 %}
{% for ex2_posts in ex2_posts %}
<h2>{{ ex2_posts.title }}</h2>
<p>{{ ex2_posts.content }}</p>
<hr>
{% endfor %}
{% endblock %}


66 changes: 66 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/templates/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{% load static %}

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}">
{% block title %}
<title>동네 소개하기</title>
{% endblock %}
</head>
<body>
<nav class="navbar navbar-expand-lg bg-light"> <!--bootstrap 적용1-->
<div class="container-fluid">
<a class="navbar-brand" href="{% url 'main' %}">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="{% url 'main' %}">우리 동네</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'dongjae' %}">희망 포지션</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="content1">
<div class="img">
<img src="{% static 'img/dongjae.jpg' %}" alt="오동재">
</div>
<table class="table table-striped" style="margin-bottom: 0px;"> <!--bootstrap 적용2-->
<thead>
<th>이름</th>
<th>학교</th>
<th>학년</th>
<th>나이</th>
</thead>
<tr>
<td>오동재</td>
<td>성공회대학교</td>
<td>3학년 1학기</td>
<td>25세</td>
</tr>
</table>
</div>
<hr>
{% block content %}
<h1>우리 동네 소개하기</h1>
{% endblock %}
<hr>
{% block content2 %}
{% for ex_posts in ex_posts %}
<h2>{{ ex_posts.title }}</h2>
<p>{{ ex_posts.content }}</p>
<hr>
{% endfor %}
{% endblock %}
</body>
</html>
3 changes: 3 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
11 changes: 11 additions & 0 deletions dongjae/dongjaeprj/dongjaeapp/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.shortcuts import render
from .models import Ex_Post, Ex2_Post

# Create your views here.
def main(request):
ex_posts = Ex_Post.objects.all
return render(request, 'main.html', {'ex_posts' : ex_posts})

def dongjae(request):
ex2_posts = Ex2_Post.objects.all
return render(request, 'dongjae.html', {'ex2_posts' : ex2_posts})
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions dongjae/dongjaeprj/dongjaeprj/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for dongjaeprj project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dongjaeprj.settings')

application = get_asgi_application()
144 changes: 144 additions & 0 deletions dongjae/dongjaeprj/dongjaeprj/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
"""
Django settings for dongjaeprj project.

Generated by 'django-admin startproject' using Django 4.2.1.

For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""

from pathlib import Path
import os, json
from django.core.exceptions import ImproperlyConfigured

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
secret_file = os.path.join(BASE_DIR, 'secrets.json')

with open(secret_file) as f:
secrets = json.loads(f.read())

def get_secret(setting, secrets = secrets):
try:
return secrets[setting]
except KeyError:
error_msg = "Set the {} enviroment variable".format(setting)
raise ImproperlyConfigured(error_msg)

SECRET_KEY = get_secret("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'dongjaeapp'
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'dongjaeprj.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'dongjaeprj.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'dongjaeapp', 'static')
]

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

STATIC_URL = 'static/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
Loading