Skip to content

Commit e2b7d25

Browse files
committed
speakers api added
1 parent dd974a3 commit e2b7d25

File tree

6 files changed

+51
-31
lines changed

6 files changed

+51
-31
lines changed

pyconbalkan/core/admin.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
from django.apps import AppConfig
2+
from django.contrib import admin
3+
4+
from pyconbalkan.core.models import Speaker, SpeakerPhoto
25

36

47
class CoreConfig(AppConfig):
58
name = 'core'
9+
10+
11+
class SpeakerImageInline(admin.TabularInline):
12+
model = SpeakerPhoto
13+
14+
15+
class SpeakerAdmin(admin.ModelAdmin):
16+
inlines = [SpeakerImageInline]
17+
18+
19+
admin.site.register(Speaker, SpeakerAdmin)

pyconbalkan/core/models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
from django.db import models
22

33
# Create your models here.
4+
5+
6+
class Speaker(models.Model):
7+
name = models.CharField(max_length=50)
8+
job = models.CharField(max_length=100)
9+
10+
def __str__(self):
11+
return self.name
12+
13+
14+
class SpeakerPhoto(models.Model):
15+
speaker = models.ForeignKey('Speaker', related_name='images')
16+
profile_picture = models.ImageField(upload_to="static/img")
-195 KB
Binary file not shown.

pyconbalkan/core/templates/index.html

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -122,35 +122,20 @@ <h1 class="font900 font-blue">Early bird tickets</h1>
122122
</div>
123123

124124
<div class="card-deck moveDown">
125-
{# <div class="card">#}
126-
{# <div class="row">#}
127-
{# <div class="col-sm">#}
128-
{# <img src="{% static 'img/user1.png' %}">#}
129-
{# <ul class="card-body h-100 justify-content-center">#}
130-
{# <li><b>Luka Kladarić</b></li>#}
131-
{# <hr>#}
132-
{# <li>Senior Software Engineer at Noom Inc.</li>#}
133-
{# </ul>#}
134-
{# </div>#}
135-
{##}
136-
{# <div class="col-sm">#}
137-
{# <img src="{% static 'img/user1.png' %}">#}
138-
{# <ul class="card-body h-100 justify-content-center">#}
139-
{# <li><b>Krzysztof Žuraw</b></li>#}
140-
{# <hr>#}
141-
{# <li>Python Developer at STX Next</li>#}
142-
{# </ul>#}
143-
{# </div>#}
144-
{# <div class="col-sm">#}
145-
{# <img src="{% static 'img/user1.png' %}">#}
146-
{# <ul class="card-body h-100 justify-content-center">#}
147-
{# <li><b>Luka Kladarić</b></li>#}
148-
{# <hr>#}
149-
{# <li>Senior Software Engineer at Noom Inc.</li>#}
150-
{# </ul>#}
151-
{# </div>#}
152-
{# </div>#}
153-
{# </div>#}
125+
<div class="card">
126+
<div class="row">
127+
{% for speaker in speakerPhoto %}
128+
<div class="col-sm">
129+
<img src="{{ speaker.profile_picture }}">
130+
<ul class="card-body h-100 justify-content-center">
131+
<li><b>{{ speaker.speaker.name }}</b></li>
132+
<hr>
133+
<li>{{ speaker.speaker.job }}</li>
134+
</ul>
135+
</div>
136+
{% endfor %}
137+
</div>
138+
</div>
154139
</div>
155140

156141
<div class="moveDown">

pyconbalkan/core/views.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
from django.shortcuts import render
2+
from .models import Speaker, SpeakerPhoto
23

34

45
def home(request):
5-
return render(request, 'index.html')
6+
speaker = Speaker.objects.all()
7+
speakerPh = SpeakerPhoto.objects.all()
8+
context = {'speakers': speaker, 'speakerPhoto': speakerPh}
9+
return render(request, 'index.html', context)
10+
11+

pyconbalkan/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,6 @@
121121
STATIC_URL = '/static/'
122122
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
123123

124-
PDF_ROOT = os.path.join(BASE_DIR, 'pyconbalkan/core/static/pdf/')
124+
PDF_ROOT = os.path.join(BASE_DIR, 'pyconbalkan/core/static/pdf/')
125+
MEDIA_ROOT = os.path.join(BASE_DIR, 'pyconbalkan/core/static/img/')
126+
MEDIA_URL = '/img/'

0 commit comments

Comments
 (0)