Skip to content

Commit b60f74e

Browse files
committed
initial commit
0 parents  commit b60f74e

Some content is hidden

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

60 files changed

+669
-0
lines changed

blog/__init__.py

Whitespace-only changes.
126 Bytes
Binary file not shown.

blog/__pycache__/admin.cpython-37.pyc

237 Bytes
Binary file not shown.

blog/__pycache__/apps.cpython-37.pyc

338 Bytes
Binary file not shown.
750 Bytes
Binary file not shown.

blog/__pycache__/urls.cpython-37.pyc

303 Bytes
Binary file not shown.

blog/__pycache__/views.cpython-37.pyc

579 Bytes
Binary file not shown.
717 Bytes
Binary file not shown.

blog/admin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from django.contrib import admin
2+
from .models import Post
3+
4+
admin.site.register(Post)

blog/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class BlogConfig(AppConfig):
5+
name = 'blog'

blog/migrations/0001_initial.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 2.2.3 on 2019-07-31 07:54
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
import django.utils.timezone
7+
8+
9+
class Migration(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+
]

blog/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.
137 Bytes
Binary file not shown.

blog/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django.db import models
2+
from django.utils import timezone
3+
from django.contrib.auth.models import User
4+
5+
class Post(models.Model):
6+
title = models.CharField(max_length=100)
7+
content = models.TextField()
8+
date_posted = models.DateTimeField(default=timezone.now)
9+
author = models.ForeignKey(User, on_delete=models.CASCADE)
10+
11+
def __str__(self):
12+
return self.title

blog/static/blog/main.css

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: 10px 20px;
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-metadata a: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+
}

blog/templates/blog/about.html

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 %}

blog/templates/blog/base.html

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+
<!-- Required meta tags -->
6+
<meta charset="utf-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
8+
9+
<!-- Bootstrap CSS -->
10+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
11+
12+
<link rel="stylesheet" type="text/css" href="{% static 'blog/main.css'%}">
13+
14+
{% if title %}
15+
<title>Django Blog - {{ title }} </title>
16+
{% else %}
17+
<title>Django Blog </title>
18+
{% endif %}
19+
</head>
20+
<body>
21+
<header class="site-header">
22+
<nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
23+
<div class="container">
24+
<a class="navbar-brand mr-4" href="{% url 'blog-home' %}">Django Blog</a>
25+
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
26+
<span class="navbar-toggler-icon"></span>
27+
</button>
28+
<div class="collapse navbar-collapse" id="navbarToggle">
29+
<div class="navbar-nav mr-auto">
30+
<a class="nav-item nav-link" href="{% url 'blog-home' %}">Home</a>
31+
<a class="nav-item nav-link" href="{% url 'blog-about' %}">About</a>
32+
</div>
33+
<!-- Navbar Right Side -->
34+
<div class="navbar-nav">
35+
{% if user.is_authenticated %}
36+
<a class="nav-item nav-link" href="{% url 'profile' %}">Profile</a>
37+
<a class="nav-item nav-link" href="{% url 'logout' %}">Logout</a>
38+
39+
{% else %}
40+
<a class="nav-item nav-link" href="{% url 'login' %}">Login</a>
41+
<a class="nav-item nav-link" href="{% url 'register' %}">Register</a>
42+
{% endif %}
43+
</div>
44+
</div>
45+
</div>
46+
</nav>
47+
</header>
48+
<main role="main" class="container">
49+
<div class="row">
50+
<div class="col-md-8">
51+
{% if messages %}
52+
{%for message in messages %}
53+
<div class="alert alert-{{ message.tags }}">
54+
{{ message }}
55+
</div>
56+
{% endfor %}
57+
{% endif %}
58+
{% block content %}{% endblock %}
59+
</div>
60+
<div class="col-md-4">
61+
<div class="content-section">
62+
<h3>Our Sidebar</h3>
63+
<p class='text-muted'>You can put any information here you'd like.
64+
<ul class="list-group">
65+
<li class="list-group-item list-group-item-light">Latest Posts</li>
66+
<li class="list-group-item list-group-item-light">Announcements</li>
67+
<li class="list-group-item list-group-item-light">Calendars</li>
68+
<li class="list-group-item list-group-item-light">etc</li>
69+
</ul>
70+
</p>
71+
</div>
72+
</div>
73+
</div>
74+
</main>
75+
76+
<!-- Optional JavaScript -->
77+
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
78+
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
79+
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
80+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
81+
</body>
82+
</body>
83+
</html>

blog/templates/blog/home.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% extends "blog/base.html" %}
2+
{% block content %}
3+
{% for post in posts%}
4+
<article class="media content-section">
5+
<div class="media-body">
6+
<div class="article-metadata">
7+
<a class="mr-2" href="#">{{ post.author }}</a>
8+
<small class="text-muted">{{ post.date_posted | date:"F d, Y" }}</small>
9+
</div>
10+
<h2><a class="article-title" href="#">{{ post.title }}</a></h2>
11+
<p class="article-content">{{ post.content }}</p>
12+
</div>
13+
</article>
14+
{% endfor %}
15+
{% endblock content %}

blog/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

blog/urls.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.urls import path
2+
from . import views
3+
4+
urlpatterns = [
5+
path('', views.home, name='blog-home'),
6+
path('about/', views.about, name='blog-about'),
7+
8+
]

blog/views.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.shortcuts import render
2+
from django.http import HttpResponse
3+
from .models import Post
4+
5+
6+
def home(request):
7+
context = {
8+
'posts':Post.objects.all()
9+
}
10+
return render(request, 'blog/home.html', context)
11+
12+
def about(request):
13+
return render(request, 'blog/about.html', {'title': 'About'})

db.sqlite3

144 KB
Binary file not shown.

django_project/__init__.py

Whitespace-only changes.
136 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
1.45 KB
Binary file not shown.
553 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)