Compare commits

...

10 Commits

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