Commit f84862df authored by Alessandro Olivar's avatar Alessandro Olivar

Rendered models onto html templates.

parent 3cb8d0d3
No preview for this file type
from django.contrib import admin from django.contrib import admin
# Register your models here. # Register your models here.
from .models import qBoard from .models import *
admin.site.register(qBoard) admin.site.register(QBoard)
\ No newline at end of file admin.site.register(Quest)
\ No newline at end of file
# Generated by Django 3.1.7 on 2021-12-15 01:40
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('qBoard', '0002_auto_20211214_2127'),
]
operations = [
migrations.AddField(
model_name='quest',
name='qBoard',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='qBoard.qboard'),
),
]
# Generated by Django 3.1.7 on 2021-12-15 09:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('qBoard', '0003_quest_qboard'),
]
operations = [
migrations.RenameField(
model_name='quest',
old_name='qBoard',
new_name='QBoard',
),
migrations.AlterField(
model_name='qboard',
name='desc',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='quest',
name='desc',
field=models.CharField(blank=True, max_length=200, null=True),
),
]
...@@ -2,18 +2,18 @@ from django.db import models ...@@ -2,18 +2,18 @@ from django.db import models
# Create your models here. # Create your models here.
class qBoard(models.Model): class QBoard(models.Model):
name = models.CharField(max_length = 200, null = True) name = models.CharField(max_length = 200, null = True)
desc = models.CharField(max_length = 200, null = True) desc = models.CharField(max_length = 200, null = True, blank = True)
stars = models.CharField(max_length = 200, null = True) stars = models.CharField(max_length = 200, null = True)
def __str__(self): def __str__(self):
return self.name return self.name
class quest(models.Model): class Quest(models.Model):
#qBoard = QBoard = models.ForeignKey(QBoard, null = True, on_delete = models.SET_NULL)
name = models.CharField(max_length = 200, null = True) name = models.CharField(max_length = 200, null = True)
desc = models.CharField(max_length = 200, null = True) desc = models.CharField(max_length = 200, null = True, blank = True)
stars = models.CharField(max_length = 200, null = True) stars = models.CharField(max_length = 200, null = True)
student1 = models.CharField(max_length = 200, null = True) student1 = models.CharField(max_length = 200, null = True)
student2 = models.CharField(max_length = 200, null = True) student2 = models.CharField(max_length = 200, null = True)
......
...@@ -6,16 +6,18 @@ ...@@ -6,16 +6,18 @@
<div class="col-md-5"> <div class="col-md-5">
<h5>QUESTBOARDS</h5> <h5>QUESTBOARDS</h5>
<hr> <hr>
<div class="card card-body">
<a class="btn btn-primary btn-sm btn-block" href="">New Questboard</a> <a class="btn btn-primary btn-sm btn-block" href="">New Questboard</a>
<hr>
{% for i in qboards %}
<div class="card card-body">
<a class="btn btn-primary btn-sm btn-block" href="">Go</a>
<table class="table table-sm"> <table class="table table-sm">
<tr> <tr>
<th></th> <th class="text-center">{{i.name}}</th>
<th>Questboard</th>
</tr> </tr>
</table> </table>
</div> </div>
{% endfor %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% extends 'qBoard/main.html' %}
{% block content %}
<h1>Homepage</h1>
<div class="row">
<div class="col-md-5">
<h5>QUESTBOARDS</h5>
<hr>
<a class="btn btn-primary btn-sm btn-block" href="">New Questboard</a>
<hr>
{% for i in quests %}
<div class="card card-body">
<a class="btn btn-primary btn-sm btn-block" href="">Edit Questboard</a>
<table class="table table-sm">
<tr>
<th colspan = 3 class="text-center">{{i.name}}</th>
</tr>
<tr>
<td colspan = 3 class="text-center"><p>{{i.desc}}</p></td>
</tr>
<tr>
<td rowspan = 3>Dibs:</td>
<td colspan = 2 class="text-left">{{i.student1}}</td>
</tr>
<tr>
<td colspan = 2 class="text-left">{{i.student2}}</td>
</tr>
<tr>
<td colspan = 2 class="text-left">{{i.student3}}</td>
</tr>
<tr>
<td colspan = 3 class="text-center">{{i.stars}}</td>
</tr>
</table>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
...@@ -3,4 +3,5 @@ from . import views ...@@ -3,4 +3,5 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.home), path('', views.home),
path('questBoard/', views.quests),
] ]
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
# Create your views here. # Create your views here.
from .models import *
def home(request): def home(request):
return render(request,'qBoard/homepage.html') qboards = QBoard.objects.all
\ No newline at end of file return render(request,'qBoard/homepage.html', {'qboards' : qboards})
def quests(request):
quests = Quest.objects.all()
return render(request, 'qBoard/quests.html', {'quests' : quests})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment