Commit a7b1b050 authored by Pranav Jerry's avatar Pranav Jerry

added template taleverse

added a field pub_date to the model Story
added a new view 'index'
parent c4b38e8e
include LICENSE
recursive-include polls/static *
recursive-include polls/templates *
recursive-include taleverse/static *
recursive-include taleverse/templates *
#!/usr/bin/env python3
import os
from setuptools import find_packages, setup
......@@ -9,6 +9,7 @@ class Story(models.Model):
language = models.CharField(max_length=7, choices=settings.LANGUAGES,
help_text="The language of the story")
content = models.TextField(help_text="The markdown source of the story")
pub_date = models.DateTimeField('Date published')
def __str__(self):
return self.title
<!DOCTYPE html>
{% if stories %}
{% for story in stories %}
<li>{{ story.title }}</li>
{% endfor %}
{% else %}
<p>No stories available</p>
{% endif %}
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('', views.index, name='index')
from django.http import HttpResponse
from django.shortcuts import render
from .models import Story
def index(request):
return HttpResponse("Hello, world! Welcome to taleverse.")
latest_story_list = Story.objects.order_by('-pub_date')[:5]
context = {"stories": latest_story_list}
return render(request, 'taleverse/index.html', context)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment