diff --git a/bartczak_tech/portfolio/admin.py b/bartczak_tech/portfolio/admin.py index 846f6b4..f050823 100644 --- a/bartczak_tech/portfolio/admin.py +++ b/bartczak_tech/portfolio/admin.py @@ -1 +1,5 @@ -# Register your models here. +from django.contrib import admin + +from .models import Hobby + +admin.site.register(Hobby) diff --git a/bartczak_tech/portfolio/migrations/0001_initial.py b/bartczak_tech/portfolio/migrations/0001_initial.py new file mode 100644 index 0000000..53a8d74 --- /dev/null +++ b/bartczak_tech/portfolio/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2.13 on 2024-09-03 14:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Hobby', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ('description', models.TextField(max_length=300)), + ('icon', models.CharField(default='fas fa-code', max_length=50)), + ('link', models.URLField(blank=True)), + ('link_text', models.CharField(blank=True, max_length=30)), + ], + options={ + 'verbose_name_plural': 'Hobbies', + }, + ), + ] diff --git a/bartczak_tech/portfolio/models.py b/bartczak_tech/portfolio/models.py index 6b20219..ac14e76 100644 --- a/bartczak_tech/portfolio/models.py +++ b/bartczak_tech/portfolio/models.py @@ -1 +1,15 @@ -# Create your models here. +from django.db import models + + +class Hobby(models.Model): + name = models.CharField(max_length=50) + description = models.TextField(max_length=300) + icon = models.CharField(max_length=50, default="fas fa-code") + link = models.URLField(max_length=200, blank=True) + link_text = models.CharField(max_length=30, blank=True) + + class Meta: + verbose_name_plural = "Hobbies" + + def __str__(self): + return self.name diff --git a/bartczak_tech/portfolio/urls.py b/bartczak_tech/portfolio/urls.py new file mode 100644 index 0000000..6299e3d --- /dev/null +++ b/bartczak_tech/portfolio/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from .views import home + +urlpatterns = [ + path("", home, name="home"), +] diff --git a/bartczak_tech/portfolio/views.py b/bartczak_tech/portfolio/views.py index 60f00ef..7e9a655 100644 --- a/bartczak_tech/portfolio/views.py +++ b/bartczak_tech/portfolio/views.py @@ -1 +1,13 @@ -# Create your views here. +from django.shortcuts import render + +from .models import Hobby + + +def home(request): + hobbies = Hobby.objects.all() + + context = { + "hobbies_list": hobbies, + } + + return render(request, "portfolio/portfolio.html", context) diff --git a/bartczak_tech/templates/portfolio/hobbies.html b/bartczak_tech/templates/portfolio/hobbies.html new file mode 100644 index 0000000..12340d7 --- /dev/null +++ b/bartczak_tech/templates/portfolio/hobbies.html @@ -0,0 +1,30 @@ +{% load static i18n %} + +{% if hobbies %} +
+
+
+
+
HOBBIES
+

What are my passions?

+
+
+
+ {% for hobby in hobbies %} +
+
+
+ +
+
{{ hobby.name }}
+

{{ hobby.description }}

+ {% if hobby.link and hobby.link_text %} + {{ hobby.link_text }} + {% endif %} +
+
+ {% endfor %} +
+
+
+{% endif %} diff --git a/bartczak_tech/templates/portfolio/portfolio.html b/bartczak_tech/templates/portfolio/portfolio.html index cba9705..8a82c31 100644 --- a/bartczak_tech/templates/portfolio/portfolio.html +++ b/bartczak_tech/templates/portfolio/portfolio.html @@ -25,49 +25,7 @@

- -
-
-
-
-
HOBBIES
-

What are my passions?

-
-
-
-
-
-
- -
-
Software Development
-

I create Python applications for my personal use and learning coding teamwork

- Read More -
-
-
-
-
- -
-
Photography
-

I enjoy sharing my view on the world using lens eye

- Read More -
-
-
-
-
- -
-
Music
-

I"m doing first steps with creating music on bass guitar

- Read More -
-
-
-
-
+ {% include 'portfolio/hobbies.html' with hobbies=hobbies_list %}
diff --git a/config/urls.py b/config/urls.py index c1e4e10..1361afe 100644 --- a/config/urls.py +++ b/config/urls.py @@ -12,9 +12,7 @@ from rest_framework.authtoken.views import obtain_auth_token urlpatterns = [ - path( - "", TemplateView.as_view(template_name="portfolio/portfolio.html"), name="home" - ), + path("", include("bartczak_tech.portfolio.urls")), path( "about/", TemplateView.as_view(template_name="pages/about.html"),