settings, apprename
This commit is contained in:
parent
31a2e4004c
commit
4479bc8316
@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/4.0/topics/settings/
|
|||||||
For the full list of settings and their values, see
|
For the full list of settings and their values, see
|
||||||
https://docs.djangoproject.com/en/4.0/ref/settings/
|
https://docs.djangoproject.com/en/4.0/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
@ -52,10 +52,25 @@ MIDDLEWARE = [
|
|||||||
|
|
||||||
ROOT_URLCONF = 'LibCasaAdministration.urls'
|
ROOT_URLCONF = 'LibCasaAdministration.urls'
|
||||||
|
|
||||||
|
# TEMPLATES = [
|
||||||
|
# {
|
||||||
|
# 'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
# 'DIRS': [],
|
||||||
|
# 'APP_DIRS': True,
|
||||||
|
# 'OPTIONS': {
|
||||||
|
# 'context_processors': [
|
||||||
|
# 'django.template.context_processors.debug',
|
||||||
|
# 'django.template.context_processors.request',
|
||||||
|
# 'django.contrib.auth.context_processors.auth',
|
||||||
|
# 'django.contrib.messages.context_processors.messages',
|
||||||
|
# ],
|
||||||
|
# },
|
||||||
|
# },
|
||||||
|
# ]
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
'DIRS': [],
|
'DIRS': [os.path.join(BASE_DIR, "templates")],
|
||||||
'APP_DIRS': True,
|
'APP_DIRS': True,
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'context_processors': [
|
'context_processors': [
|
||||||
@ -67,7 +82,6 @@ TEMPLATES = [
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
WSGI_APPLICATION = 'LibCasaAdministration.wsgi.application'
|
WSGI_APPLICATION = 'LibCasaAdministration.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,8 +15,11 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('api/', include('api.urls')),
|
path('api/', include('api.urls')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
]
|
path('', include('forum.urls')),
|
||||||
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from .models import Post, Replie, Profile
|
from .models import Post, Reply, Profile
|
||||||
|
|
||||||
admin.site.register(Post)
|
admin.site.register(Post)
|
||||||
admin.site.register(Replie)
|
admin.site.register(Reply)
|
||||||
admin.site.register(Profile)
|
admin.site.register(Profile)
|
7
forum/forms.py
Normal file
7
forum/forms.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from django import forms
|
||||||
|
from .models import Profile
|
||||||
|
|
||||||
|
class ProfileForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Profile
|
||||||
|
fields = ('image', )
|
@ -2,7 +2,8 @@ from django.shortcuts import render, redirect, HttpResponse, Http404
|
|||||||
from .models import User, Profile, Post, Reply
|
from .models import User, Profile, Post, Reply
|
||||||
from django.contrib.auth import authenticate, login, logout
|
from django.contrib.auth import authenticate, login, logout
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from .forms import ProfileForm
|
||||||
def UserRegister(request):
|
def UserRegister(request):
|
||||||
if request.method=="POST":
|
if request.method=="POST":
|
||||||
username = request.POST['username']
|
username = request.POST['username']
|
||||||
@ -34,6 +35,11 @@ def UserLogin(request):
|
|||||||
return render(request, 'login.html', {'alert':alert})
|
return render(request, 'login.html', {'alert':alert})
|
||||||
return render(request, "login.html")
|
return render(request, "login.html")
|
||||||
|
|
||||||
|
def UserLogout(request):
|
||||||
|
logout(request)
|
||||||
|
messages.success(request, "Successfully logged out")
|
||||||
|
return redirect('/login')
|
||||||
|
|
||||||
def forum(request):
|
def forum(request):
|
||||||
profile = Profile.objects.all()
|
profile = Profile.objects.all()
|
||||||
if request.method=="POST":
|
if request.method=="POST":
|
||||||
@ -60,3 +66,18 @@ def discussion(request, myid):
|
|||||||
alert = True
|
alert = True
|
||||||
return render(request, "discussion.html", {'alert':alert})
|
return render(request, "discussion.html", {'alert':alert})
|
||||||
return render(request, "discussion.html", {'post':post, 'replies':replies})
|
return render(request, "discussion.html", {'post':post, 'replies':replies})
|
||||||
|
|
||||||
|
@login_required(login_url = '/login')
|
||||||
|
def myprofile(request):
|
||||||
|
if request.method=="POST":
|
||||||
|
user = request.user
|
||||||
|
profile = Profile(user=user)
|
||||||
|
profile.save()
|
||||||
|
form = ProfileForm(data=request.POST, files=request.FILES)
|
||||||
|
if form.is_valid():
|
||||||
|
form.save()
|
||||||
|
obj = form.instance
|
||||||
|
return render(request, "profile.html",{'obj':obj})
|
||||||
|
else:
|
||||||
|
form=ProfileForm()
|
||||||
|
return render(request, "profile.html", {'form':form})
|
||||||
|
Reference in New Issue
Block a user