# -*- coding: utf-8 -*-
from flask import Flask, request
import telebot
from flask_sslify import SSLify
bot = telebot.TeleBot("yourtgtoken", threaded=False)
bot.remove_webhook()
time.sleep(1)
bot.set_webhook(url="https://yourhost.com")
app = Flask(__name__)
sslify = SSLify(app)
@app.route('/', methods=["POST"])
def webhook():
bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
return "ok", 200
### commands
@bot.message_handler(commands=['start'])
def start(message):
### Пишем здесь остальную логику
if __name__ == '__main__':
app.run()
python manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings.
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
raise ImproperlyConfigured("You're using the staticfiles app "
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
class Meta:
ordering = ['people']
{% extends "base_generic.html" %}
{% block content %}<h1>State List</h1>
{% regroup object_list by people as list %}
<table class="table">
<thead>
<tr>
<th>People/Day</th>
{% for i in list %}
{% if forloop.first %}
{% for d in i.list %}
<th>{{d.date}}</th>
{% endfor %}
{% endif %}
{% endfor %}
</tr>
</thead>
<tbody>
{% for i in list %}
<tr scope = "row">
<th>{{i.grouper}}</th>
{% for d in i.list %}
<th>{{d.status}}</th>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
- использую тег regroupfrom django.shortcuts import render
from .models import People, State, School_class
from django.views import generic
def index(request):
num_state = State.objects.all().count()
num_people = People.objects.all().count()
return render(
request,
'index.html',
context = {'num_date':num_state, 'num_people':num_people})
class StateListView(generic.ListView):
model = State
На русском