2025-07-26
This commit is contained in:
@@ -10,7 +10,14 @@ https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
from draft.routing import websocket_urlpatterns
|
||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||
from channels.auth import AuthMiddlewareStack
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'boxofficefantasy_project.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
application = ProtocolTypeRouter({
|
||||
"http": get_asgi_application(),
|
||||
"websocket":AuthMiddlewareStack(URLRouter(websocket_urlpatterns)),
|
||||
})
|
||||
print("✅ ASGI server is running")
|
||||
@@ -34,6 +34,7 @@ TMDB_API_KEY = os.environ.get("TMDB_API_KEY")
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"daphne",
|
||||
'boxofficefantasy',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
@@ -41,7 +42,9 @@ INSTALLED_APPS = [
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize'
|
||||
'django.contrib.humanize',
|
||||
"draft",
|
||||
"channels"
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -59,7 +62,7 @@ ROOT_URLCONF = 'boxofficefantasy_project.urls'
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [BASE_DIR / 'templates'],
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
@@ -135,3 +138,14 @@ CSRF_TRUSTED_ORIGINS = [
|
||||
"http://localhost:3000",
|
||||
"http://127.0.0.1:3000",
|
||||
]
|
||||
|
||||
ASGI_APPLICATION = "boxofficefantasy_project.asgi.application"
|
||||
|
||||
# Channel layers
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels.layers.InMemoryChannelLayer",
|
||||
},
|
||||
}
|
||||
|
||||
HASHIDS_SALT = "your-very-secret-salt-string"
|
||||
|
||||
@@ -22,7 +22,8 @@ from django.conf.urls.static import static
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path("", include("boxofficefantasy.urls"))
|
||||
path("", include("boxofficefantasy.urls")),
|
||||
path("draft/", include("draft.urls")),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
|
||||
11
boxofficefantasy_project/utils.py
Normal file
11
boxofficefantasy_project/utils.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from hashids import Hashids
|
||||
from django.conf import settings
|
||||
|
||||
hashids = Hashids(min_length=8, salt=settings.HASHIDS_SALT)
|
||||
|
||||
def encode_id(id):
|
||||
return hashids.encode(id)
|
||||
|
||||
def decode_id(hashid):
|
||||
decoded = hashids.decode(hashid)
|
||||
return int(decoded[0]) if decoded else None
|
||||
Reference in New Issue
Block a user