Commit a1fd5c39 authored by Florent Chehab's avatar Florent Chehab
Browse files

Initial commit

from django.contrib import admin
from .models import Post
from django.apps import AppConfig
class RexConfig(AppConfig):
name = 'rex'
# Generated by Django 2.0.3 on 2018-03-20 11:47
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
operations = [
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
('text', models.TextField()),
('created_date', models.DateTimeField(,
('published_date', models.DateTimeField(blank=True, null=True)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
from django.db import models
from django.utils import timezone
class Post(models.Model):
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(
published_date = models.DateTimeField(
blank=True, null=True)
def publish(self):
self.published_date =
def __str__(self):
return self.title
\ No newline at end of file
<h1><a href="/">Django Girls Blog</a></h1>
{% for post in posts %}
<p>publié: {{ post.published_date }}</p>
<h1><a href="">{{ post.title }}</a></h1>
<p>{{ post.text|linebreaksbr }}</p>
{% endfor %}
<link rel="stylesheet" href="//">
<link rel="stylesheet" href="//">
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.post_list, name='post_list'),
\ No newline at end of file
from django.shortcuts import render
from django.utils import timezone
from .models import Post
def post_list(request):
posts = Post.objects.filter('published_date')
return render(request, 'rex/post_list.html', {'posts': posts})
\ 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