【发布时间】:2021-02-09 15:14:05
【问题描述】:
在本地主机上它正在工作,但是当我在网站上应用它时..它向我显示了这个错误..有人可以帮我找到这个错误。
1.Base.html
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="google-site-verification" content="BsNTKCunl4MclRtIE86x1ldHNv2umlZuzPmJV_B-tCc" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{% static 'css/firstpage.css' %}">
<title>My Website</title>
</head>
<body>
<!-- Header -->
<section id="header">
<div class="header container">
<div class="nav-bar">
<div class="brand" >
<a href="#hero" id = "main"><img src = "{% static 'css/lasso4.png' %}" class= "logo"></a>
<a href="#hero"><h1><span>C</span>are for <span>A</span>LL</h1></a>
</div>
<div class="nav-list">
<div class="hamburger"><div class="bar"></div></div>
<ul>
<li><a href="#hero" data-after="Home">Home</a></li>
<li><a href="#services" data-after="Service">Services</a></li>
<li><a href="#projects" data-after="Blogs">Blogs</a></li>
<li><a href="#about" data-after="About">About</a></li>
<li><a href="#contact" data-after="Contact">Contact</a></li>
{% if user.is_authenticated %}
<li><a href="{% url 'careforallapp:user_logout' %}" data-after="Logout">Logout</a></li>
{% else %}
<li><a href="{% url 'careforallapp:user_login' %}" data-after="login">Login</a></li>
{% endif %}
</ul>
</div>
</div>
</div>
</section>
<!-- End Header -->
<!-- Hero Section -->
<section id="hero">
<div class="hero container">
<div>
<h1>Happy <span></span></h1>
<h1>Republic Day, <span></span></h1>
<h1>INDIA<span><img src = "{% static 'css/ind.jpg' %}"></span></h1>
<p align = "justify">"Every indian should now forget that he is a Rajput, a Sikh or a Jat. He must remember that he is an Indian." - Sir, Sardar Patel<span></span></p>
</div>
</div>
</section>
<!-- End Hero Section -->
<!-- Service Section -->
<section id="services">
<div class="services container">
<div class="service-top">
<h1 class="section-title">Serv<span>i</span>ces</h1>
<p>We don't want to push our ideas on to readers, we simply want to make what they want.</p>
</div>
<div class="service-bottom">
<div class="service-item">
<div class="icon"><img src="{% static 'css/4.jpg' %}"/></div>
<h2>4 Best Topics</h2>
<p>We give you the 4 best topics. You can visit anyone of them. They are all hot topics.</p>
</div>
<div class="service-item">
<div class="icon"><img src="{% static 'css/OIP.jpeg' %}"/></div>
<h2>Trusted Knowledge</h2>
<p>We provide you the valid and trusted data. We dont provide fake data</p>
</div>
<div class="service-item">
<div class="icon"><img src="{% static 'css/wp.jpg' %}"/></div>
<h2>Safe Website</h2>
<p>You are in safe environment, we use all type of hashing and layers to protect our websites.</p>
</div>
<div class="service-item">
<div class="icon"><img src="{% static 'css/OIP (3).jpeg' %}"/></div>
<h2>Contact Us Anytime</h2>
<p>Contact us for any queries related to these topic. We are excited to solve your queries. </p>
</div>
</div>
</div>
</section>
<!-- End Service Section -->
<!-- Projects Section -->
<section id="projects">
<div class="projects container">
<div class="projects-header">
<h1 class="section-title">TOPICS <span>To COVER</span></h1>
</div>
<div class="all-projects">
<div class="project-item">
<div class="project-info">
<a href="{% url 'fitness:fitness' %}" style="color: #8ebf42"><h1>Health and Fitness</h1>
<h2>The Science Behind A Good Workout</h2>
<p>We’ve all been there before: a tough day at work or in school. We’re exhausted, both mentally and physically, but we still manage to push ourselves and get to the gym. Why do we do it? Because we know how much better we’ll feel after an evening indoor cycling class, an hour of football or a challenging weight workout. We leave feeling refreshed, rejuvenated and invigorated—truly transformed. Clearly, there’s a relationship between exercise and the brain, but what is it?</p>
</a>
</div>
<div class="project-img">
<img src="{% static 'css/fit-3.jpg' %}" alt="img">
</div>
</div>
<div class="project-item">
<div class="project-info">
<a href="{% url 'personality:personality' %}" style="color: #8ebf42"><h1>Personality Development</h1>
<h2>THE IMPORTANCE OF GOAL SETTING </h2>
<p>We know the importance of goal setting, but most times our goals are not measurable and clearly defined. You hear people say things like “I want to lose weight”, though losing weight is a goal it can be clearly defined if you add things like: “I want to lose weight, by eating healthy and exercising. When you compare both statements, the first one only states what you intend to do, the second one states what you intend to do and how you intend to do it. </p>
</a>
</div>
<div class="project-img">
<img src="{% static 'css/tt.jpg' %}" alt="img">
</div>
</div>
<div class="project-item">
<div class="project-info">
<a href="{% url 'datasecurity:datasecurity' %}" style="color: #8ebf42"><h1>Data Security</h1>
<h2>Data Is The Modern Fuel</h2>
<p>Digital technology is changing the way in which society is operating and the ways we live our lives. Every day, there is new ways to work and to play, new methods of interacting with one another. As our digital footprint grows exponentially, we are forming our own online identities.</p>
</a>
</div>
<div class="project-img">
<img src="{% static 'css/ds.jpg' %}" alt="img">
</div>
</div>
<div class="project-item">
<div class="project-info">
<a href="#" style="color: #8ebf42"><h1>General Awareness</h1>
<h2>Comming Soon</h2>
<p>Knowledge is power, and it can help you overcome any fear of the unexpected.</p>
</a>
</div>
<div class="project-img">
<img src="{% static 'css/pexels-janko-ferlic-590493.jpg' %}" alt="img">
</div>
</div>
</div>
</section>
<!-- End Projects Section -->
<!-- About Section -->
<div class="service-top">
<h1 class="section-title">ABO<span>U</span>T</h1>
<p align="center">The reason of making this website is to provide a platform for all the community people to read and be aware about the things that are happening around them. In this we are providing you all the information which are very legit and will for sure make you a very informative person. We hope that you all will enjoy reading the contents and make us as your daily insight’s choice.</p>
</div>
<section id="about">
<div class="about container">
<div class="col-left">
<div class="about-img">
<img src="{% static 'css/hit.jpeg' %}" alt="img">
</div>
</div>
<div class="col-right">
<h1 class="section-title">Mr.<span>Hitesh Kumar</span></h1>
<h2>Designer and Editor</h2>
<p>Qualification: Pursuing PGDM from Indus Business Academy, Bangalore</p>
</div>
</div>
<section id="about">
<div class="about container">
<div class="col-left">
<div class="about-img">
<img src="{% static 'css/asuu.png' %}" alt="img">
</div>
</div>
<div class="col-right">
<h1 class="section-title">Mr.<span>Asutosh Singh</span></h1>
<h2>Content Writer and Editor</h2>
<p>Qualification: Pursuing B.A From Hislop College, Nagpur</p>
</div>
</div>
<section id="about">
<div class="about container">
<div class="col-left">
<div class="about-img">
<img src="{% static 'css/naman.png' %}" alt="img">
</div>
</div>
<div class="col-right">
<h1 class="section-title">Mr.<span>Naman Rohilla</span></h1>
<h2>Full-Stack Developer</h2>
<p>Qualification: Pursuing Integrated Course in M.Sc Mathematics from NIT, Surat</p>
</div>
</div>
</section>
</section>
</section>
<section id="about">
<div class="about container">
<div class="col-left">
<div class="about-img">
<img src="{% static 'css/ash-2.jpeg' %}" alt="img">
</div>
</div>
<div class="col-right">
<h1 class="section-title">Mr.<span>Ashwini Kumar</span></h1>
<h2>Content Writer</h2>
<p>Qualification: Pursuing B.Tech From MVIT, Bangalore</p>
</div>
</div>
<section id="about">
<div class="about container">
<div class="col-left">
<div class="about-img">
<img src="{% static 'css/hrithil.png' %}" alt="img">
</div>
</div>
<div class="col-right">
<h1 class="section-title">Mr.<span>Hrithik Singh</span></h1>
<h2>Frontend-App Developer</h2>
<p>Qualification: Pursuing B.Tech in IT from VIIT, Pune</p>
</div>
</div>
</section>
</section>
<!-- End About Section -->
<!-- Contact Section -->
<section id="contact">
<div class="contact container">
<div><h1 class="section-title">Contact <span>info</span></h1></div>
<div class="contact-items">
<div class="contact-item">
<div class="icon"><a href = "https://mail.google.com/"><img src="https://img.icons8.com/bubbles/100/000000/new-post.png"/></a></div>
<div class="contact-info">
<h1>Email</h1>
<a href = "https://mail.google.com/"><h2>careall249@gmail.com</h2></a>
</div>
</div>
<div class="contact-item">
<div class="icon"><img src="https://img.icons8.com/bubbles/100/000000/map-marker.png"/></div>
<div class="contact-info">
<h1>Address</h1>
<h2>MVIT, Bangalore</h2>
</div>
</div>
</div>
</div>
</section>
<!-- End Contact Section -->
<!-- Footer -->
<section id="footer">
<div class="footer container">
<div class="brand"><h1><span>C</span>are For <span>A</span>ll</h1></div>
<h2 align= "center">For your awareness CARE FOR ALL at your Service.</h2>
<div class="social-icon">
<div class="social-item">
<a href="https://www.instagram.com/_care4all_/?igshid=r0bnwlhb8cbm"><img src="https://img.icons8.com/bubbles/100/000000/instagram-new.png"/></a>
</div>
<div class="social-item">
<a href="https://twitter.com/CareForAll249?s=08"><img src="https://img.icons8.com/bubbles/100/000000/twitter.png"/></a>
</div>
<div class="social-item">
<a href="https://www.facebook.com/Care-For-All-101858671850233/"><img src="https://img.icons8.com/bubbles/100/000000/facebook-new.png"/></a>
</div>
</div>
<p>All rights reserved</p>
</div>
</section>
<!-- End Footer -->
<script src="{% static 'css/firstpage.js' %}"></script>
</body>
</html>
2.Views.py
from django.shortcuts import render
from careforallapp.forms import UserForm
from django.urls import reverse
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect, HttpResponse
from django.contrib.auth import authenticate, login, logout
from django.views.decorators.csrf import csrf_exempt,csrf_protect
# Create your views here.
def base(request):
return render(request,'careforallapp/base.html')
def thanks1(request):
return render(request,'careforallapp/thanks1.html')
def thanks2(request):
return render(request,'careforallapp/thanks2.html')
def thanks3(request):
return render(request,'careforallapp/thanks3.html')
@login_required
def special(request):
return HttpResponseRedirect("You are logged in, Nice!")
@csrf_protect
@login_required
def user_logout(request):
logout(request)
return HttpResponseRedirect('thanks2')
def register(request):
registered = False
if request.method == "POST":
user_form = UserForm(data=request.POST)
if user_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
registered = True
return HttpResponseRedirect('thanks3')
else:
print(user_form.errors)
else:
user_form = UserForm()
return render(request,'careforallapp/registration.html',
{'user_form':user_form,
'registered':registered})
@csrf_protect
def user_login(request):
if request.method == "POST":
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(username = username, password = password)
if user:
if user.is_active:
login(request, user)
return HttpResponseRedirect('thanks1')
else:
return HttpResponse("ACCOUNT NOT ACTIVE")
else:
print("Someone tried to login and failed!")
print("Username: {} and password: {}".format(username, password))
return HttpResponse("invalid login details")
else:
return render(request, 'careforallapp/login.html', {})
3.models.py
from django.db import models
from ckeditor.fields import RichTextField
from django.contrib.auth.models import User
# Create your models here.
class UserProfileInfo(models.Model):
user = models.OneToOneField(User,on_delete=models.DO_NOTHING)
def __str__(self):
return self.user.username
4.Forms.py
from django import forms
from django.contrib.auth.models import User
from careforallapp.models import UserProfileInfo
#LANGUAGE_CODE
class UserForm(forms.ModelForm):
password = forms.CharField(widget= forms.PasswordInput())
class Meta():
model = User
fields = ('username', 'email', 'password')
5.urls.py
from django.conf.urls import url
from . import views
app_name = 'careforallapp'
urlpatterns = [
url(r'^$', views.base, name='base'),
url(r'register/$', views.register, name='register'),
url(r'logout/$', views.user_logout, name='user_logout'),
url(r'special/$', views.special, name='special'),
url(r'user_login/$', views.user_login, name='user_login'),
url(r'thanks1/$', views.thanks1, name = 'thanks1'),
url(r'thanks2/$', views.thanks2, name = 'thanks2'),
url(r'thanks3/$', views.thanks3, name = 'thanks3'),
#URLs
]
在本地主机上它正在工作,但是当我在网站上应用它时..它向我显示了这个错误..有人可以帮我找到这个错误。
当我调试代码时,我得到了这个突出显示的错误
<li><a href="{% url 'careforallapp:user_logout' %}" data-after="Logout">Logout</a></li>
请有人帮助我...谢谢
【问题讨论】:
-
您能否在 PythonAnywhere 的日志中包含更多上下文?
-
您是否在顶级网址中包含“careforallapp”?
标签: django pythonanywhere