Compare commits

...

10 Commits

Author SHA1 Message Date
7a59fb798f Styling 2022-03-02 16:51:28 +01:00
f7e291af7b Add file paths for displaying 2022-03-02 16:19:14 +01:00
4f8cf91609 Add template using Django templating language 2022-01-04 16:03:43 +01:00
edaa41811f Build all_projects view 2022-01-04 15:38:54 +01:00
77a2e7d954 Add new path for a test page 2022-01-04 15:25:36 +01:00
e79d1e702c Add test project from Django shell 2022-01-04 15:18:09 +01:00
353233ba6e Add image files for the project 2022-01-04 15:06:57 +01:00
530ec8a071 Add course slides 2022-01-04 15:06:02 +01:00
cceb2d82fd Make migration 2022-01-04 15:05:35 +01:00
e6b3b0f715 Add path for static files 2022-01-04 15:00:57 +01:00
10 changed files with 61 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,18 @@
# Generated by Django 4.0 on 2022-01-04 13:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('projects', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='project',
name='image',
field=models.FilePathField(path='/projects/img'),
),
]

View File

@@ -5,4 +5,4 @@ class Project(models.Model):
title = models.CharField(max_length=100)
description = models.TextField()
technology = models.CharField(max_length=20)
image = models.FilePathField(path="/img")
image = models.FilePathField(path="/projects/img")

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View File

@@ -0,0 +1,33 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- CSS only -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>Projects</h1>
<div class="row">
<!-- h1>Hi again</h1 -->
<!--div class="alert alert-warning" role="alert">
Remember that errors are your friends!
</div -->
{% for project in projects%}
<div class="col-md-4">
<div class="card mb-2">
<img class="card-img-top" src="{% static project.image %}" alt="{{ project.description }}">
<div class="card-body">
<h5 class="card-title">{{ project.title }}</h5>
<p class="card-text">{{ project.description }}</p>
<a href="#" class="btn btn-primary">Read More</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</body>
</html>

View File

@@ -2,5 +2,6 @@ from django.urls import path
from projects import views
urlpatterns = [
path("", views.project_list),
path("", views.all_projects),
path("test", views.project_list),
]

View File

@@ -1,5 +1,12 @@
from django.shortcuts import render
from projects.models import Project
# Create your views here.
def project_list(request):
return render(request, "projects/index.html")
def all_projects(request):
# query the db to return all project objects
projects = Project.objects.all()
return render(request, "projects/all_projects.html", {"projects": projects})