forked from OpenSourceArk/infomate.club
Add django-debug-toolbar + fix slow SQL qieries
This commit is contained in:
parent
5651475f6f
commit
aadefbc286
|
@ -3,7 +3,7 @@ from datetime import datetime, timedelta
|
|||
|
||||
from django.contrib.humanize.templatetags.humanize import naturaltime
|
||||
from django.db import models
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db.models import JSONField
|
||||
from slugify import slugify
|
||||
|
||||
from boards.icons import DOMAIN_ICONS, DOMAIN_FAVICONS
|
||||
|
|
|
@ -28,7 +28,7 @@ def board(request, board_slug):
|
|||
return cached_page
|
||||
|
||||
blocks = BoardBlock.objects.filter(board=board)
|
||||
feeds = BoardFeed.objects.filter(board=board)
|
||||
feeds = BoardFeed.objects.select_related("articles").filter(board=board)
|
||||
result = render(request, "board.html", {
|
||||
"board": board,
|
||||
"blocks": blocks,
|
||||
|
|
|
@ -10,13 +10,14 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
DEBUG = (os.getenv("DEBUG") != "false") # SECURITY WARNING: don't run with debug turned on in production!
|
||||
SECRET_KEY = os.getenv("SECRET_KEY") or "wow so secret"
|
||||
ALLOWED_HOSTS = ["127.0.0.1", "localhost", "0.0.0.0", "infomate.club"]
|
||||
INTERNAL_IPS = ["127.0.0.1"]
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.humanize",
|
||||
"django_bleach",
|
||||
"boards",
|
||||
"parsing"
|
||||
"parsing",
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -123,3 +124,7 @@ if SENTRY_DSN and not DEBUG:
|
|||
dsn=SENTRY_DSN,
|
||||
integrations=[DjangoIntegration()]
|
||||
)
|
||||
|
||||
if DEBUG:
|
||||
INSTALLED_APPS += ["debug_toolbar"]
|
||||
MIDDLEWARE = ["debug_toolbar.middleware.DebugToolbarMiddleware"] + MIDDLEWARE
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from django.urls import path
|
||||
from django.conf import settings
|
||||
from django.urls import path, include
|
||||
from django.views.decorators.cache import cache_page
|
||||
|
||||
from boards.views import index, board, privacy_policy, what
|
||||
from infomate import settings
|
||||
from parsing.views import TelegramChannelFeed
|
||||
|
||||
urlpatterns = [
|
||||
|
@ -16,5 +16,12 @@ urlpatterns = [
|
|||
path("parsing/telegram/<str:channel_name>/",
|
||||
cache_page(settings.TELEGRAM_CACHE_SECONDS)(TelegramChannelFeed()),
|
||||
name="telegram_channel_feed"),
|
||||
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
import debug_toolbar
|
||||
urlpatterns = [path("__debug__/", include(debug_toolbar.urls))] + urlpatterns
|
||||
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
"SHOW_TOOLBAR_CALLBACK": lambda request: True,
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
Django==3.2.12
|
||||
Django==4.0.4
|
||||
gunicorn==20.1.0
|
||||
uvicorn==0.17.6
|
||||
psycopg2-binary==2.9.3
|
||||
|
@ -13,3 +13,5 @@ sentry-sdk==1.5.8
|
|||
nltk==3.6.6
|
||||
newspaper3k>=0.2.8
|
||||
django-bleach==1.0.0
|
||||
django-debug-toolbar==3.4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load staticfiles %}
|
||||
{% load static %}
|
||||
<link rel="icon" type="image/png" href="{% static "images/favicon/favicon-16x16.png" %}" sizes="16x16">
|
||||
<link rel="icon" type="image/png" href="{% static "images/favicon/favicon-32x32.png" %}" sizes="32x32">
|
||||
<link rel="icon" type="image/png" href="{% static "images/favicon/android-chrome-192x192.png" %}" sizes="192x192">
|
||||
|
|
Loading…
Reference in New Issue