Commit 6d0dedb1 authored by Gab De Jesus's avatar Gab De Jesus

Added sample prof data, and url linking to index. Displays all reviews in a loop

parent d61aacda
......@@ -37,6 +37,8 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'reviews',
]
MIDDLEWARE = [
......
......@@ -16,6 +16,9 @@ Including another URLconf
from django.conf.urls import url
from django.contrib import admin
from reviews import views as reviews_views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', reviews_views.index, name="reviews_index")
]
File added
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-12 04:12
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('reviews', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=15, unique=True)),
('description', models.CharField(max_length=100)),
],
),
]
......@@ -15,7 +15,6 @@ class Prof(models.Model):
def __str__ (self):
return self.first_name + self.last_name
class Review(models.Model):
message = models.TextField(max_length = 4000)
created_at = models.DateTimeField(auto_now_add = True)
......
<center><h1>Reviews</h1></center>
{% for review in reviews %}
<h2>{{ review.prof.first_name }} {{ review.prof.last_name }}</h2>
<p>{{ review.message }}</p>
{% endfor %}
\ No newline at end of file
......@@ -4,4 +4,4 @@ from .models import Review
# Create your views here.
def index(request):
reviews = Review.objects.all()
return render(request, 'reviews.html', {'reviews': reviews})
\ No newline at end of file
return render(request, 'index.html', {'reviews': reviews})
\ No newline at end of file
{% for review in reviews %}
{{ review.message }}
{% endfor %}
\ 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