This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% load static %} | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>To Do</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block content %} | |
<div class="jumbotron"> | |
<div class="container"> | |
<h1>My To Do List</h1> | |
<p>{{todos|length}} items</p> | |
<button type="button" class="btn btn-primary">Add New</button> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from .models import Todo | |
# Create your views here. | |
def list_todos(request): | |
""" Displays a list of posts """ | |
todos = Todo.objects.filter(completed=False).order_by('-created_on') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Todo(models.Model): | |
title = models.CharField(max_length=255) | |
notes = models.TextField(blank=True, null=True) | |
created_on = models.DateTimeField(auto_now_add=True) | |
completed = models.BooleanField(default=False) | |
def __str__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
from .models import Todo | |
# Create your tests here. | |
todo_title = "Book Dentist Appointment" | |
class TestTodoModel(TestCase): | |
def setUp(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase, Client | |
from django.urls import reverse | |
from .models import Todo | |
# Create your tests here. | |
todo_title = "Book Dentist Appointment" | |
class TestTodoModel(TestCase): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% load static %} | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="{% static 'css/styles.css' %}" rel="stylesheet"> | |
<title>Django Cinema</title> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from autoslug import AutoSlugField | |
from django.utils.text import slugify | |
class Genre(models.Model): | |
name = models.CharField(max_length=100) | |
api_id = models.IntegerField(unique=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from django.db import IntegrityError | |
from django.test import TestCase | |
from django.urls import reverse | |
from django.utils.text import slugify | |
from .models import Genre, Movie | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib import auth | |
USER = auth.get_user_model() | |
class UserProfile(models.Model): | |
user = models.OneToOneField(to=USER, related_name="profile", on_delete=models.PROTECT) | |
first_name = models.CharField(max_length=255) | |
last_name = models.CharField(max_length=255) | |
bio = models.TextField() |
OlderNewer