我的虚拟主机文件:
<VirtualHost *:80>
ServerName myapp.cl
ServerAlias *.myapp.cl myapp.cl
Alias /static /home/ubuntu/django_projects/myapp/static
<Directory /home/ubuntu/django_projects/myapp/static>
Require all granted
</Directory>
<Directory /home/ubuntu/django_projects/myapp/myapp>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIProcessGroup myapp
WSGIDaemonProcess myapp python-path=/home/ubuntu/django_projects/myapp
WSGIScriptAlias / /home/ubuntu/django_projects/myapp/myapp/wsgi.py process-group=myapp application-group=%{GLOBAL}
</VirtualHost>
和我的url_file:
rom django.conf.urls import url, include
from django.contrib import admin
from . import views as views_ini
from django.contrib.auth.views import login, logout, password_change, password_change_done
from myapp.views import aviso_sistema, inicio, LoginForm
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^login/$', login, {'template_name': 'loginrex.html',
'authentication_form': LoginForm,
}, name='django.contrib.auth.views.login'),
url(r'^logout/$', logout, {'next_page': '/login'}, name='logout'),
# ....Avisos del sistema
url(r'^aviso_sistema/(?P<titulo>[\w\ ]+)/(?P<detalle>[\w\ ]+)/(?P<tipo>[\w\ ]+)$', aviso_sistema, name='aviso_sistema'),
]
我的/myapp/myapp/views.py
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import AuthenticationForm
from django import forms
from myapp.definiciones.preferenciasDefi import unaPref
from myapp.deposito import procesoAnombre
from django.shortcuts import redirect
from django.conf import settings
@login_required()
def inicio(request):
#if not request.user.is_authenticated:
# raise ValueError('Usuario OK pero no logueado')
# return redirect('%s?next=%s' % (settings.LOGIN_URL, request.path))
mdp = unaPref('mesActual')
dato = procesoAnombre(mdp)
datos = {
'mmp': dato,
'idv': ' ',
}
return render(request, 'inicio.html', datos)
class LoginForm(AuthenticationForm):
username = forms.CharField(label="Usuario", max_length=30,
widget=forms.TextInput(attrs={'class': 'form-control', 'name': 'username'}),
)
password = forms.CharField(label="Clave", max_length=30,
widget=forms.PasswordInput(attrs={'class': 'form-control', 'name': 'password'}),
)
# ........Genera los avisos del sistema
def aviso_sistema(request, titulo, detalle, tipo):
datos = {
'titulo': titulo,
'detalle': detalle,
'tipo': tipo,
}
return render(request, 'aviso_sistema.html', datos)
我真的很感激这方面的一些帮助。 感谢
答案 0 :(得分:1)
我终于找到了问题,这是位于settings.py中的两个必须设置为False的变量。
不是问题,因为它没有进行任何安全验证。当SSL证书应用于站点时,它们可能必须等于True。