Skip to content

Commit

Permalink
here we go again
Browse files Browse the repository at this point in the history
  • Loading branch information
ArkTZ committed Jul 12, 2022
1 parent 18c377d commit 599a840
Show file tree
Hide file tree
Showing 32 changed files with 150 additions and 30 deletions.
Binary file modified personal_blog/blog/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file modified personal_blog/blog/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added personal_blog/blog/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added personal_blog/blog/__pycache__/views.cpython-310.pyc
Binary file not shown.
5 changes: 4 additions & 1 deletion personal_blog/blog/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from django.contrib import admin

# Register your models here.
from django.contrib import admin
from .models import Blog

admin.site.register(Blog)
23 changes: 23 additions & 0 deletions personal_blog/blog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.0.5 on 2022-06-14 03:12

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Project',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
('description', models.TextField()),
('date', models.DateField()),
],
),
]
17 changes: 17 additions & 0 deletions personal_blog/blog/migrations/0002_rename_project_blog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.0.5 on 2022-06-14 03:26

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('blog', '0001_initial'),
]

operations = [
migrations.RenameModel(
old_name='Project',
new_name='Blog',
),
]
Binary file not shown.
Binary file not shown.
8 changes: 7 additions & 1 deletion personal_blog/blog/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from django.db import models

# Create your models here.
class Blog(models.Model):
title = models.CharField(max_length=200)
description = models.TextField()
date = models.DateField()

def __str__(self):
return self.title
16 changes: 16 additions & 0 deletions personal_blog/blog/templates/blog/all_blogs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends 'portfolio/base.html' %}

{% block content %}

<h1>Blog</h1>

<h2>Temirlan has written {{ blogs.count }} blog{{blogs.count|pluralize}}</h2>
{% for blog in blogs %}

<a href="{% url 'blog:detail' blog.id %}"><h2>{{ blog.title }}</h2></a>
<h5>{{ blog.date|date:'M d Y'|upper }}</h5>
<p>{{ blog.description|striptags|truncatechars:100 }}</p>


{% endfor %}
{% endblock %}
22 changes: 12 additions & 10 deletions personal_blog/blog/templates/blog/detail.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>$Title$</title>
</head>
<body>
$END$
</body>
</html>
{% extends 'portfolio/base.html' %}

{% block content %}


<h1>{{ blog.title}}</h1>
<h2> --{{ blog.date|date:'F jS Y'}}--</h2>


{{ blog.description|safe}}

{% endblock %}
9 changes: 9 additions & 0 deletions personal_blog/blog/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path
from . import views

app_name = 'blog'

urlpatterns = [
path('', views.all_blogs, name='all_blogs'),
path('<int:blog_id>/', views.detail, name='detail'),
]
15 changes: 13 additions & 2 deletions personal_blog/blog/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from .models import Blog

# Create your views here.


def all_blogs(request):
blogs_count = Blog.objects.count
blogs = Blog.objects.order_by('-date')[:5]
return render(request, 'blog/all_blogs.html', {'blogs': blogs})


def detail(request, blog_id):
blog = get_object_or_404(Blog, pk=blog_id)
return render(request, 'blog/detail.html', {'blog':blog})
Binary file modified personal_blog/db.sqlite3
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified personal_blog/personal_blog/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file modified personal_blog/personal_blog/__pycache__/urls.cpython-310.pyc
Binary file not shown.
5 changes: 4 additions & 1 deletion personal_blog/personal_blog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""

import os.path
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
Expand Down Expand Up @@ -119,6 +119,9 @@
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = 'static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
Expand Down
9 changes: 8 additions & 1 deletion personal_blog/personal_blog/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from portfolio import views

urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home, name='home' ),
path('blog/', include('blog.urls')),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Binary file modified personal_blog/portfolio/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file modified personal_blog/portfolio/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion personal_blog/portfolio/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib import admin
from .models import Project

# Register your models here.
admin.site.register(Project)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion personal_blog/portfolio/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ class Project(models.Model):
title = models.CharField(max_length=100)
description = models.CharField(max_length=250)
image = models.ImageField(upload_to='portfolio/images/')
url = models.URLField(blank=True)
url = models.URLField(blank=True)

def __str__(self):
return self.title
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion personal_blog/portfolio/templates/portfolio/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Expand Down
34 changes: 24 additions & 10 deletions personal_blog/portfolio/templates/portfolio/home.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>$Title$</title>
</head>
<body>
$END$
</body>
</html>
{% extends 'portfolio/base.html' %}

{% block content %}

<h1>Temirlan's Portfolio</h1>

{% load static %}

<img src="{% static 'portfolio/b3a632a5547d22c553075514add449db.jpg' %}">

{% for project in projects %}

<h2>{{project.title}}</h2>
<p>{{project.description}}</p>
<img src="{{ project.image.url }}" height=70 , width=70>
{% if project.url %}
<br><a href="{{ project.url }}">Link</a>
{% endif %}

{% endfor %}
<a a href="{% url 'blog:all_blogs' %}">Blog</a>
<br>

{% endblock %}
7 changes: 6 additions & 1 deletion personal_blog/portfolio/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from django.shortcuts import render
from .models import Project

# Create your views here.


def home(request):
projects = Project.objects.all()
return render(request, 'portfolio/home.html', {'projects':projects})

0 comments on commit 599a840

Please sign in to comment.