Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11d4c9f

Browse files
committed
Code snippets
1 parent16bd511 commit11d4c9f

File tree

48 files changed

+1224
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1224
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Mac
2+
.DS_Store
3+
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
pip-wheel-metadata/
27+
share/python-wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.nox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*.cover
53+
.hypothesis/
54+
.pytest_cache/
55+
56+
# Translations
57+
*.mo
58+
*.pot
59+
60+
# Django stuff:
61+
*.log
62+
local_settings.py
63+
db.sqlite3
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
.python-version
87+
88+
# celery beat schedule file
89+
celerybeat-schedule
90+
91+
# SageMath parsed files
92+
*.sage.py
93+
94+
# Environments
95+
.env
96+
.venv
97+
env/
98+
venv/
99+
ENV/
100+
env.bak/
101+
venv.bak/
102+
103+
# Spyder project settings
104+
.spyderproject
105+
.spyproject
106+
107+
# Rope project settings
108+
.ropeproject
109+
110+
# mkdocs documentation
111+
/site
112+
113+
# mypy
114+
.mypy_cache/
115+
.dmypy.json
116+
dmypy.json
117+
118+
# Pyre type checker
119+
.pyre/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn django_project.wsgi

‎Django_Blog/13-Deployment-Heroku/django_project/blog/__init__.py

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fromdjango.contribimportadmin
2+
from .modelsimportPost
3+
4+
admin.site.register(Post)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fromdjango.appsimportAppConfig
2+
3+
4+
classBlogConfig(AppConfig):
5+
name='blog'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 2.1 on 2018-08-28 02:32
2+
3+
fromdjango.confimportsettings
4+
fromdjango.dbimportmigrations,models
5+
importdjango.db.models.deletion
6+
importdjango.utils.timezone
7+
8+
9+
classMigration(migrations.Migration):
10+
11+
initial=True
12+
13+
dependencies= [
14+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15+
]
16+
17+
operations= [
18+
migrations.CreateModel(
19+
name='Post',
20+
fields=[
21+
('id',models.AutoField(auto_created=True,primary_key=True,serialize=False,verbose_name='ID')),
22+
('title',models.CharField(max_length=100)),
23+
('content',models.TextField()),
24+
('date_posted',models.DateTimeField(default=django.utils.timezone.now)),
25+
('author',models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,to=settings.AUTH_USER_MODEL)),
26+
],
27+
),
28+
]

‎Django_Blog/13-Deployment-Heroku/django_project/blog/migrations/__init__.py

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
fromdjango.dbimportmodels
2+
fromdjango.utilsimporttimezone
3+
fromdjango.contrib.auth.modelsimportUser
4+
fromdjango.urlsimportreverse
5+
6+
7+
classPost(models.Model):
8+
title=models.CharField(max_length=100)
9+
content=models.TextField()
10+
date_posted=models.DateTimeField(default=timezone.now)
11+
author=models.ForeignKey(User,on_delete=models.CASCADE)
12+
13+
def__str__(self):
14+
returnself.title
15+
16+
defget_absolute_url(self):
17+
returnreverse('post-detail',kwargs={'pk':self.pk})
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
body {
2+
background:#fafafa;
3+
color:#333333;
4+
margin-top:5rem;
5+
}
6+
7+
h1,h2,h3,h4,h5,h6 {
8+
color:#444444;
9+
}
10+
11+
ul {
12+
margin:0;
13+
}
14+
15+
.bg-steel {
16+
background-color:#5f788a;
17+
}
18+
19+
.site-header .navbar-nav .nav-link {
20+
color:#cbd5db;
21+
}
22+
23+
.site-header .navbar-nav .nav-link:hover {
24+
color:#ffffff;
25+
}
26+
27+
.site-header .navbar-nav .nav-link.active {
28+
font-weight:500;
29+
}
30+
31+
.content-section {
32+
background:#ffffff;
33+
padding:10px20px;
34+
border:1px solid#dddddd;
35+
border-radius:3px;
36+
margin-bottom:20px;
37+
}
38+
39+
.article-title {
40+
color:#444444;
41+
}
42+
43+
a.article-title:hover {
44+
color:#428bca;
45+
text-decoration: none;
46+
}
47+
48+
.article-content {
49+
white-space: pre-line;
50+
}
51+
52+
.article-img {
53+
height:65px;
54+
width:65px;
55+
margin-right:16px;
56+
}
57+
58+
.article-metadata {
59+
padding-bottom:1px;
60+
margin-bottom:4px;
61+
border-bottom:1px solid#e3e3e3
62+
}
63+
64+
.article-metadataa:hover {
65+
color:#333;
66+
text-decoration: none;
67+
}
68+
69+
.article-svg {
70+
width:25px;
71+
height:25px;
72+
vertical-align: middle;
73+
}
74+
75+
.account-img {
76+
height:125px;
77+
width:125px;
78+
margin-right:20px;
79+
margin-bottom:16px;
80+
}
81+
82+
.account-heading {
83+
font-size:2.5rem;
84+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% extends "blog/base.html" %}
2+
{% block content %}
3+
<h1>About Page</h1>
4+
{% endblock content %}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{% load static %}
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
6+
<!-- Required meta tags -->
7+
<metacharset="utf-8">
8+
<metaname="viewport"content="width=device-width, initial-scale=1, shrink-to-fit=no">
9+
10+
<!-- Bootstrap CSS -->
11+
<linkrel="stylesheet"href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"crossorigin="anonymous">
12+
13+
<linkrel="stylesheet"type="text/css"href="{% static 'blog/main.css' %}">
14+
15+
{% if title %}
16+
<title>Django Blog - {{ title }}</title>
17+
{% else %}
18+
<title>Django Blog</title>
19+
{% endif %}
20+
</head>
21+
<body>
22+
<headerclass="site-header">
23+
<navclass="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
24+
<divclass="container">
25+
<aclass="navbar-brand mr-4"href="{% url 'blog-home' %}">Django Blog</a>
26+
<buttonclass="navbar-toggler"type="button"data-toggle="collapse"data-target="#navbarToggle"aria-controls="navbarToggle"aria-expanded="false"aria-label="Toggle navigation">
27+
<spanclass="navbar-toggler-icon"></span>
28+
</button>
29+
<divclass="collapse navbar-collapse"id="navbarToggle">
30+
<divclass="navbar-nav mr-auto">
31+
<aclass="nav-item nav-link"href="{% url 'blog-home' %}">Home</a>
32+
<aclass="nav-item nav-link"href="{% url 'blog-about' %}">About</a>
33+
</div>
34+
<!-- Navbar Right Side -->
35+
<divclass="navbar-nav">
36+
{% if user.is_authenticated %}
37+
<aclass="nav-item nav-link"href="{% url 'post-create' %}">New Post</a>
38+
<aclass="nav-item nav-link"href="{% url 'profile' %}">Profile</a>
39+
<aclass="nav-item nav-link"href="{% url 'logout' %}">Logout</a>
40+
{% else %}
41+
<aclass="nav-item nav-link"href="{% url 'login' %}">Login</a>
42+
<aclass="nav-item nav-link"href="{% url 'register' %}">Register</a>
43+
{% endif %}
44+
</div>
45+
</div>
46+
</div>
47+
</nav>
48+
</header>
49+
<mainrole="main"class="container">
50+
<divclass="row">
51+
<divclass="col-md-8">
52+
{% if messages %}
53+
{% for message in messages %}
54+
<divclass="alert alert-{{ message.tags }}">
55+
{{ message }}
56+
</div>
57+
{% endfor %}
58+
{% endif %}
59+
{% block content %}{% endblock %}
60+
</div>
61+
<divclass="col-md-4">
62+
<divclass="content-section">
63+
<h3>Our Sidebar</h3>
64+
<pclass='text-muted'>You can put any information here you'd like.
65+
<ulclass="list-group">
66+
<liclass="list-group-item list-group-item-light">Latest Posts</li>
67+
<liclass="list-group-item list-group-item-light">Announcements</li>
68+
<liclass="list-group-item list-group-item-light">Calendars</li>
69+
<liclass="list-group-item list-group-item-light">etc</li>
70+
</ul>
71+
</p>
72+
</div>
73+
</div>
74+
</div>
75+
</main>
76+
77+
<!-- Optional JavaScript -->
78+
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
79+
<scriptsrc="https://code.jquery.com/jquery-3.2.1.slim.min.js"integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"crossorigin="anonymous"></script>
80+
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"crossorigin="anonymous"></script>
81+
<scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"crossorigin="anonymous"></script>
82+
</body>
83+
</html>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{% extends "blog/base.html" %}
2+
{% block content %}
3+
{% for post in posts %}
4+
<articleclass="media content-section">
5+
<imgclass="rounded-circle article-img"src="{{ post.author.profile.image.url }}">
6+
<divclass="media-body">
7+
<divclass="article-metadata">
8+
<aclass="mr-2"href="{% url 'user-posts' post.author.username %}">{{ post.author }}</a>
9+
<smallclass="text-muted">{{ post.date_posted|date:"F d, Y" }}</small>
10+
</div>
11+
<h2><aclass="article-title"href="{% url 'post-detail' post.id %}">{{ post.title }}</a></h2>
12+
<pclass="article-content">{{ post.content }}</p>
13+
</div>
14+
</article>
15+
{% endfor %}
16+
{% if is_paginated %}
17+
18+
{% if page_obj.has_previous %}
19+
<aclass="btn btn-outline-info mb-4"href="?page=1">First</a>
20+
<aclass="btn btn-outline-info mb-4"href="?page={{ page_obj.previous_page_number }}">Previous</a>
21+
{% endif %}
22+
23+
{% for num in page_obj.paginator.page_range %}
24+
{% if page_obj.number == num %}
25+
<aclass="btn btn-info mb-4"href="?page={{ num }}">{{ num }}</a>
26+
{% elif num> page_obj.number|add:'-3' and num<page_obj.number|add:'3' %}
27+
<aclass="btn btn-outline-info mb-4"href="?page={{ num }}">{{ num }}</a>
28+
{% endif %}
29+
{% endfor %}
30+
31+
{% if page_obj.has_next %}
32+
<aclass="btn btn-outline-info mb-4"href="?page={{ page_obj.next_page_number }}">Next</a>
33+
<aclass="btn btn-outline-info mb-4"href="?page={{ page_obj.paginator.num_pages }}">Last</a>
34+
{% endif %}
35+
36+
{% endif %}
37+
{% endblock content %}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp