Last active
August 29, 2015 14:22
-
-
Save aprilsnow7870/cb4087b1ead7b3e8d96d to your computer and use it in GitHub Desktop.
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
#Views: | |
from django.shortcuts import render_to_response, redirect | |
from django.core.context_processors import csrf | |
from django.template import RequestContext | |
# Create your views here. | |
from theater.models import Cinema | |
from theater.models import CinemaForm | |
def cinema(request): | |
all_cinema = Cinema.objects.all() | |
cinema_form = CinemaForm() | |
if request.POST: | |
newpost_form = CinemaForm(request.POST) | |
if newpost_form.is_valid(): | |
newpost_form.save() | |
return redirect("/") | |
return render_to_response("theatername.html", {"cinema": all_cinema, "form": cinema_form}) | |
#Template: | |
{% extends 'main.html' %} | |
{% load staticfiles %} | |
{% block theater %} | |
{% for theater in cinema %} | |
<table class="table table-bordered"> | |
<thead> | |
<tr> | |
<th>Адрес</th> | |
<th>Название кинотеатра</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>{{ theater.theater_address }}</td> | |
<td>{{ theater.theater_name }}</td> | |
</tr> | |
</tbody> | |
</table> | |
<br> | |
{% endfor %} | |
<form method="post"> | |
{% csrf_token %} | |
{{ form.as_ul }} | |
<input class="btn btn-success" type="submit" value="Добавить"> | |
</form> | |
{% endblock %} | |
{% block seance %} | |
{% for theater in cinema %} | |
<table class="table table-bordered"> | |
<thead> | |
<tr> | |
<th>Название кинотеатра</th> | |
<th>Расписание и название фильма</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr> | |
<td>{{ theater.theater_name }}</td> | |
<td>{{ theater.cinema_timetable }} - {{ theater.cinema_name }}</td> | |
</tr> | |
</tbody> | |
</table> | |
<br> | |
{% endfor %} | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment