Skip to content

Commit

Permalink
added a projects page
Browse files Browse the repository at this point in the history
  • Loading branch information
chris234567 committed Dec 27, 2020
1 parent bd08d08 commit 8d7db31
Show file tree
Hide file tree
Showing 32 changed files with 114 additions and 26 deletions.
12 changes: 12 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified db.sqlite3
Binary file not shown.
Binary file removed hello_world/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file removed hello_world/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file removed hello_world/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file removed hello_world/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file removed hello_world/__pycache__/views.cpython-39.pyc
Binary file not shown.
5 changes: 0 additions & 5 deletions hello_world/apps.py

This file was deleted.

Binary file not shown.
3 changes: 0 additions & 3 deletions hello_world/models.py

This file was deleted.

6 changes: 0 additions & 6 deletions hello_world/templates/hello_world.html

This file was deleted.

6 changes: 0 additions & 6 deletions hello_world/urls.py

This file was deleted.

4 changes: 0 additions & 4 deletions hello_world/views.py

This file was deleted.

Binary file modified personal_portfolio/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file modified personal_portfolio/__pycache__/urls.cpython-39.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion personal_portfolio/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'hello_world',
'projects',
]

MIDDLEWARE = [
Expand Down
2 changes: 1 addition & 1 deletion personal_portfolio/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('hello_world.urls'))
path("projects/", include("projects.urls")),
]
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions projects/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ProjectsConfig(AppConfig):
name = 'projects'
24 changes: 24 additions & 0 deletions projects/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.1.4 on 2020-12-27 17:08

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Project',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('description', models.TextField()),
('technology', models.CharField(max_length=20)),
('image', models.FilePathField(path='\\img')),
],
),
]
File renamed without changes.
7 changes: 7 additions & 0 deletions projects/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.db import models

class Project(models.Model):
title = models.CharField(max_length = 100)
description = models.TextField()
technology = models.CharField(max_length = 20)
image = models.FilePathField(path = "\img")
Binary file added projects/static/img/project1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/static/img/project2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added projects/static/img/project3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions projects/templates/project_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends "base.html" %}
{% load static %}

{% block page_content %}
<h1>{{ project.title }}</h1>
<div class="row">
<div class="col-md-8">
<img src="{% static project.image %}" alt="" width="100%">
</div>
<div class="col-md-4">
<h5>About the project:</h5>
<p>{{ project.description }}</p>
<br>
<h5>Technology used:</h5>
<p>{{ project.technology }}</p>
</div>
</div>
{% endblock %}
22 changes: 22 additions & 0 deletions projects/templates/project_index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "base.html" %}
{% load static %}
{% block page_content %}
<h1>Projects</h1>
<div class="row">
{% for project in projects %}
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top" src="{% static project.image %}">
<div class="card-body">
<h5 class="card-title">{{ project.title }}</h5>
<p class="card-text">{{ project.description }}</p>
<a href="{% url 'project_detail' project.pk %}"
class="btn btn-primary">
Read More
</a>
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
File renamed without changes.
7 changes: 7 additions & 0 deletions projects/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path
from . import views

urlpatterns = [
path("", views.project_index, name = "project_index"),
path("<int:pk>/", views.project_detail, name = "project_detail")
]
16 changes: 16 additions & 0 deletions projects/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.shortcuts import render
from projects.models import Project

def project_index(request):
projects = Project.objects.all()
context = {
'projects': projects
}
return render(request, 'project_index.html', context)

def project_detail(request, pk):
project = Project.objects.get(pk = pk)
context = {
'project': project
}
return render(request, 'project_detail.html', context)

0 comments on commit 8d7db31

Please sign in to comment.