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
# Register your models here.
from .models import qBoard
admin.site.register(qBoard)
\ No newline at end of file
from .models import *
admin.site.register(QBoard)
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
# Create your models here.
class qBoard(models.Model):
class QBoard(models.Model):
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)
def __str__(self):
return self.name
class quest(models.Model):
#qBoard =
class Quest(models.Model):
QBoard = models.ForeignKey(QBoard, null = True, on_delete = models.SET_NULL)
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)
student1 = models.CharField(max_length = 200, null = True)
student2 = models.CharField(max_length = 200, null = True)
......
......@@ -6,16 +6,18 @@
<div class="col-md-5">
<h5>QUESTBOARDS</h5>
<hr>
<div class="card card-body">
<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">
<tr>
<th></th>
<th>Questboard</th>
<th class="text-center">{{i.name}}</th>
</tr>
</table>
</div>
{% endfor %}
</div>
</div>
{% 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
urlpatterns = [
path('', views.home),
path('questBoard/', views.quests),
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
from .models import *
def home(request):
return render(request,'qBoard/homepage.html')
\ No newline at end of file
qboards = QBoard.objects.all
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