提问人:zahra shokrizadeh 提问时间:8/17/2023 最后编辑:zahra shokrizadeh 更新时间:8/17/2023 访问量:61
Django:没有这样的表:auctions_user_user_permissions
Django: no such table: auctions_user_user_permissions
问:
我编写了 Django 程序,并在管理面板上注册了一些产品。 在对代码进行一些更改后,我遇到了一些问题: 1-无法再进入管理面板,并给出此错误。 2-没有显示任何产品信息,并且网站上似乎没有数据。
问题是什么?
视图。PY:
# item detail page in views.py
def item_detail(request, bidid):
bid_desc = List.objects.get(pk = bidid, active_bool=True)
nowbids = Bidmodel.objects.filter(listb_id = bidid)
return render(request, "auctions/item_detail.html",{
"list": bid_desc,
"comments" : Comments.objects.filter(listc_id = bidid),
"now_bid": minbid(bid_desc.first_bid, nowbids),
})
# winner
def winner(request):
bid_id = request.GET["listid"]
nowbids = Bidmodel.objects.filter(listb_id = bid_id)
biddesc = List.objects.get(pk = bid_id)
maxbid = minbid(biddesc.first_bid, nowbids)
try:
winner_who = Bidmodel.objects.get(bid = maxbid, listb_id = bid_id)
winner_list = List.objects.get(id = bid_id)
win = Winner(win_list = winner_list, user = winner_who.user)
winners_name = winner_who.user
except:
winner_list = List.objects.get(first_bid = maxbid, id = bid_id)
win = Winner(win_list = winner_list, user = winner_list.user)
winners_name = winner_list.user
biddesc.active_bool = False
biddesc.save()
win.save()
messages.success(request, f"{winners_name} won {win.win_list.title}.")
return redirect("index")
# check winner
def winner_check(request):
try:
yourwin = Winner.objects.filter(user = request.user.username)
except:
yourwin = None
return render(request, "auctions/winner_check.html",{
"user_winlist" : yourwin,
})
index.html:
{% extends "auctions/layout.html" %}
{% block body %}
<h2>Active Listings</h2>
{% if messages %}
{% for message in messages %}
<div>{{ message }}</div>
{% endfor %}
{% endif %}
<div>
{% for item in items %}
<div>
<img src= {{ item.image.url }} alt = "{{item.title}}"><br>
<a>{{ item.title }}</a><br>
<a>{{ item.category }}</a><br>
<a><a>Frist Bid: </a> {{ item.first_bid }} $ </a><br>
<a href="{% url 'item_detail' item.id %}">View Product</a>
</div>
{% endfor %}
</div>
{% endblock %}
item_detail.html:
{% extends "auctions/layout.html" %}
{% block body %}
{% if messages %}
{% for message in messages %}
<div>{{ message }}</div>
{% endfor %}
{% endif %}
<img src= {{ list.image.url }} alt = "{{list.title}}"><br>
<a><a>Product:</a>{{ list.title }}</a><br>
<a><a>Category: </a>{{ list.category }}</a><br>
<a><a>Desc: </a>{{ list.description }}</a><br>
<a><a>Status: </a>{{ list.status }}</a><br>
<a><a>Frist Bid: </a> {{ list.first_bid }} $ </a><br>
<div><a><a>Current Bid: </a> {{ now_bid }} $ </div>
<div><a><a>Listed By: </a> {{ list.user }}</div>
<div>
<form method= "get" action = "{% url "addwatchlist" %}">
<button type = "submit" value = {{ list.id }} name = "listid" >Add to Watchlist</button>
</form>
</div>
<form method = "get" action = "{% url "bid_check" %}">
<input name = "bid_amnt" placeholder = "Bid Amount" type = "number">
<button type = "submit" name = "list_d" value = {{ list.id }}>accept</button>
</form>
<h3>Comments</h3>
<div>
<ul>
{% for comment in comments %}
<li><a><a>{{ comment.user }} : {{comment.comment}}</a></li>
{% endfor %}
</ul>
</div>
<form method = "get" action ="{% url "comments" %}">
<input required type = "text" placeholder = "Add Comment" name = "comment">
<button type = "submit" value = {{ list.id }} name = "listid"> Comment </button>
</form>
<div>
{% if list.user == user.username %}
<form method= "get" action = "{% url "winner" %}">
<button type = "submit" value = {{ list.id }} name = "listid" >Close Bid</button>
</form>
{% endif %}
</div>
{% endblock %}
winner_check.html:
{% extends "auctions/layout.html" %}
{% block body %}
<h2>Your Winnings</h2>
<div>
{% for list in user_winlist %}
<div>
<img src={{ list.win_list.image.url }}><br>
<a>Product:{{list.win_list.title}}</a><br>
<a>Category:{{list.win_list.category}}</a><br>
<a>Initial price:{{list.win_list.first_bid}}</a><br>
<div>This bid was listed by <a>{{ list.win_list.user }}</a>.</div>
</div>
{% endfor %}
</div>
{% endblock %}
错误:
回溯(最近一次调用最后一次): 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\backends\utils.py”,第 89 行,在_execute中 返回 self.cursor.execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\backends\sqlite3\base.py”,第 328 行,正在执行 返回 super().execute(query, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
上述异常(无此类表:auctions_user_user_permissions)是导致以下异常的直接原因: 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\core\handlers\exception.py”,第 55 行,在内部 响应 = get_response(请求) ^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\core\handlers\base.py”,第 197 行,_get_response 响应 = wrapped_callback(请求, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\utils\decorators.py”,第 46 行,在 _wrapper 中 返回bound_method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\views\decorators\cache.py”,第 62 行,_wrapper_view_func 响应 = view_func(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\admin\sites.py”,第 422 行,登录 **self.each_context(请求), ^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\admin\sites.py”,第 337 行,each_context “available_apps”: self.get_app_list(请求), ^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\admin\sites.py”,第 536 行,get_app_list app_dict = self._build_app_dict(请求,app_label) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\admin\sites.py”,第 478 行,_build_app_dict has_module_perms = model_admin.has_module_permission(请求) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\admin\options.py”,第 611 行,has_module_permission 返回request.user.has_module_perms(self.opts.app_label) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\auth\models.py”,第 331 行,has_module_perms 返回_user_has_module_perms(自己,app_label) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\auth\models.py”,第 235 行,_user_has_module_perms 如果 backend.has_module_perms(用户,app_label): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\auth\backends.py”,第 121 行,has_module_perms 用于self.get_all_permissions的烫发(user_obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\auth\backends.py”,第 109 行,get_all_permissions user_obj._perm_cache = super().get_all_permissions(user_obj) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\auth\backends.py”,第 27 行,在get_all_permissions *self.get_user_permissions(user_obj, obj=obj), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\auth\backends.py”,第 96 行,get_user_permissions 返回 self._get_permissions(user_obj, obj, “user”) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\contrib\auth\backends.py”,第 87 行,在_get_permissions user_obj,perm_cache_name, {“%s.%s” % (ct, name) for ct, name in perms} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\models\query.py”,第 398 行,在 iter self._fetch_all() 中 ^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\models\query.py”,第 1881 行,_fetch_all self._result_cache = list(self._iterable_class(自身)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\models\query.py”,第 246 行,在 iter 返回 compiler.results_iter(
文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\models\sql\compiler.py”,第 1511 行,results_iter 结果 = self.execute_sql(
文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\models\sql\compiler.py”,第 1560 行,execute_sql cursor.execute(sql, 参数) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\backends\utils.py”,第 102 行,正在执行中 返回 super().execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\backends\utils.py”,第 67 行,正在执行中 返回self._execute_with_wrappers(
文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\backends\utils.py”,第 80 行,_execute_with_wrappers 返回 executor(sql, params, many, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\backends\utils.py”,第 84 行,在_execute 使用 self.db.wrap_database_errors: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\utils.py”,第 91 行,在退出中引发 dj_exc_value.with_traceback(traceback) from exc_value ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\backends\utils.py”,第 89 行,在_execute中 返回 self.cursor.execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 文件“C:\Users\Nazi\AppData\Roaming\Python\Python311\site-packages\django\db\backends\sqlite3\base.py”,第 328 行,正在执行 返回 super().execute(query, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
异常类型:/admin/login/ 处的 OperationalError 异常值:无此类表:auctions_user_user_permissions
答: 暂无答案
评论