当我想登录或注册时,我为registration AdvUser添加了用户类,或者当我收到错误时,我为createsuperuser添加了用户类:
异常值:没有这样的表:vacancy_list_advuser
文件“/home/alex/dev/python/django/junjob/myvenv/lib/python3.5/site packages/django/db/backends/sqlite3/base.py”,第305行,在execute return Database.Cursor.execute(self,query,params)django.db.utils.OperationalError:没有这样的表:空缺列表\u advuser
我所做的
AUTH_USER_MODEL='vacancy_list。AdvUser'#
我应该怎么做才能解决问题?
我的代码:
models.py
from django.conf import settings
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.dispatch import Signal
from .utilities import send_activation_notification
class Company(models.Model):
name = models.CharField(max_length=200)
about = models.TextField()
def __str__(self):
return self.name
class Vacancy(models.Model):
company_key = models.ForeignKey(Company, on_delete=models.CASCADE)
title = models.CharField(max_length=200)
salary = models.CharField(max_length=200, default='40.000')
text = models.TextField(default="The text about vacancy")
city = models.CharField(max_length=200, default='Москва')
date_str = models.CharField(max_length=50, default='12 сентября')
created_date = models.DateTimeField(default=timezone.now)
published_date = models.DateTimeField(blank=True, null=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
class AdvUser(AbstractUser):
""" Model of user for registration """
is_activated = models.BooleanField(default=True, db_index=True, verbose_name='Прошёл активацию?')
send_messages = models.BooleanField(default=True, verbose_name='Слать оповещёния о новых комментариях?')
class Meta(AbstractUser.Meta):
pass
user_registrated = Signal(providing_args=['instance'])
def user_registrated_dispatcher(sender, **kwargs):
send_activation_notification(kwargs['instance'])
user_registrated.connect(user_registrated_dispatcher)
urls.py
urlpatterns = [
path('', HomePageView.as_view(), name='vacancy_list'),
path('search/', SearchResultsView.as_view(), name='search_results'),
path('vacancy/<int:pk>/', views.vacancy_detail, name='vacancy_detail'),
path('accounts/login/', BBLoginView.as_view(), name='login'),
path('accounts/profile/', profile, name='profile'),
path('accounts/logout/', BBLogoutView.as_view(), name='logout'),
path('accounts/register/done', RegisterDoneView.as_view(), name='register_done'),
path('accounts/register/', RegisterUserView.as_view(), name='register'),
path('accounts/register/activate/<str:sign>/', user_activate, name='register_activate'),
# path('', views.post_list, name='post_list'),
]
views.py
''' Registration views '''
class BBLoginView(LoginView):
template_name = 'vacancy_list/login.html'
class BBLogoutView(LoginRequiredMixin, LogoutView):
template_name = 'vacancy_list/logout.html'
@login_required
def profile(request):
return render(request, 'vacancy_list/profile.html')
class RegisterUserView(CreateView):
model = AdvUser
template_name = 'vacancy_list/register_user.html'
form_class = RegisterUserForm
success_url = reverse_lazy('register_done')
class RegisterDoneView(TemplateView):
template_name = "vacancy_list/register_done.html"
def user_activate(request, sign):
try:
username = signer.unsign(sign)
except:
return render(request, 'vacancy_list/bad_signature.html')
user = get_object_or_404(AdvUser, username=username)
if user.is_activated:
template = 'vacancy_list/user_is_activated.html'
else:
template = 'vacancy_list/activation_done.html'
user.is_active = True
user.is_activated = True
user.save()
return render(request, template)
base.html--
{% load static %}
<html>
<head>
<title>My blog</title>
<!-- Add Bootstrap4 -->
<link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
<style>
html,
body {
height: 100%;
}
#page-content {
flex: 1 0 auto;
}
#sticky-footer {
flex-shrink: none;
}
</style>
</head>
<body class="d-flex flex-column">
<div id="page-content">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">
<div class="container">
<a class="navbar-brand" href="/">JunJob</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home
<span class="sr-only">(current)</span>
</a>
</li>
{% if user.is_authenticated %}
<li class="nav-item active">
<a class="nav-link" href=""><font color="red">{{ user }}</font>
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="{% url 'logout' %}">Logout
<span class="sr-only">(current)</span>
</a>
</li>
{% else %}
<li class="nav-item active">
<a class="nav-link" href="{% url 'login' %}">Login
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="{% url 'register' %}">Register
<span class="sr-only">(current)</span>
</a>
</li>
{% endif %}
</ul>
</div>
</div>
</nav>
{% block content %}
{% endblock %}
</div>
<footer class="py-5 bg-dark">
<div class="container">
<p class="m-0 text-center text-white">Copyright © Your Website 2019</p>
</div>
</footer>
<!-- Bootstrap core JavaScript -->
<script src="{% static 'vendor/jquery/jquery.slim.min.js' %}"></script>
<script src="{% static 'vendor/bootstrap/js/bootstrap.bundle.min.js' %}"></script>
</body>
</html>
根据这个答案。您可能需要降级您的SQLite版本。我遇到的一个常见问题。
python manage.py migrate --fake APPNAME zero
然后运行迁移脚本
python manage.py migrate
希望这有帮助!
问题内容: 所以这是我的代码: 由于某种原因,我收到了No Such Element Exception 我不确定为什么。基本上我的程序正在搜索两个文本文件-armour.txt和TreasureClassEx.txt。getTreasureClass从怪物那里获得一个宝藏类,并在txt中搜索,直到到达基础装甲项目(不以tc:开头的字符串。)然后,它在getArmor中搜索与所获得的基础装甲名称相
问题内容: 我正在使用Django-CMS的Django项目中构建一个相当简单的应用程序,即研究项目。(这是我对项目/应用程序的首次尝试。)它的主要目的是存储各种知识资产(例如,研究人员撰写的文章,书籍等)。 问题是,当我将浏览器指向/ research /时,出现一条错误,提示表’research_journal’不存在(“ no such table”)。 我正在使用带有sqlite3数据库的
问题内容: 我遵循的是官方Django文档中的第一个应用程序教程,尝试保存通过管理页面进行的某些更改时出现此错误。我对此进行了一些研究,但是我能够找到的可能解决方案(例如迁移数据库)根本行不通。如果您想查看我的代码的某些特定部分,请告诉我。 以下是错误: and the traceback: 问题答案: 我自己碰到了这个问题,它似乎与https://code.djangoproject.com/t
我试图使用struts2上传文件,但没有成功。我一直在关注Struts2Showcase指南,并浏览了许多论坛。 这是我的JSP 这是我的动作课 当我试图上传文件时,我得到异常 我还经历了Struts 2文件上传空指针异常和struts2-cant-上传-文件-无效-字段值。但仍然没有成功 请建议一下,我哪里出了问题
DOM结构 线程“main”组织中出现异常。openqa。硒。NoSuchElementException:没有这样的元素:无法定位元素:{“method”:“tag name”,“selector”:“li”