我拿了一些在django版本1.8.4中制作的示例代码,和Python 2.7一样,当转移到3 python时都飞走了并产生了这样的错误,如何修复它?
\lib\site-packages\config.py", line 91, in <module>
from types import StringType, UnicodeType
ImportError: cannot import name 'StringType'
Run Code Online (Sandbox Code Playgroud)
使用stringtype(config.py)的一段代码(在site-packages中)
def writeValue(self, value, stream, indent):
if isinstance(self, Mapping):
indstr = ' '
else:
indstr = indent * ' '
if isinstance(value, Reference) or isinstance(value, Expression):
stream.write('%s%r%s' % (indstr, value, NEWLINE))
else:
if (type(value) is StringType): # and not isWord(value):
value = repr(value)
stream.write('%s%s%s' % (indstr, value, NEWLINE))
Run Code Online (Sandbox Code Playgroud) 如何更改背景颜色,并删除此行,以及如何更改一些 tex,
例如:点的文本,当您将鼠标悬停在某个点上时,您将获得该点的标题和值。
我的js
function creating_chart(get_wrapper,type_of_chart, labels_of_chart, data_of_charts, title_of_chart){
var ctx = document.getElementById(get_wrapper).getContext('2d');
var myChart = new Chart(ctx, {
type: type_of_chart,
data: {
labels: labels_of_chart,
datasets: [{
label: title_of_chart,
data: [2220, 19998, 55547, 55784, 999985], //data_of_charts
backgroundColor: [
'rgba(47, 152, 208, 0.2)',
],
borderColor: [
'rgba(19, 247, 228,1)',
],
borderWidth: 2,
pointBackgroundColor: 'rgba(19, 247, 228,1)',
pointBorderColor: 'rgba(19, 247, 228,1)',
pointBorderWidth: 5,
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});
};
Run Code Online (Sandbox Code Playgroud) 我已经缓存了所有内容,如果我登录到我的帐户,您将无法再注销了)退出后如何退出?我需要知道如何删除cookie和会话!当我要退出!
PS如果我将在nginx级别禁用缓存,一切正常,nginx中的问题
nginx conf
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
proxy_connect_timeout 5;
proxy_send_timeout 10;
proxy_read_timeout 10;
proxy_buffering on;
proxy_buffer_size 16k;
proxy_buffers 24 16k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_temp_path /tmp/nginx/proxy_temp;
add_header X-Cache-Status $upstream_cache_status;
proxy_cache_path /tmp/nginx/cache levels=1:2 keys_zone=first_zone:100m;
proxy_cache one;
proxy_cache_valid any 30d;
proxy_cache_key $scheme$proxy_host$request_uri$cookie_US;
Run Code Online (Sandbox Code Playgroud)
服务器conf
upstream some site {
server unix:/webapps/some/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name server name;
expires 7d;
client_max_body_size …Run Code Online (Sandbox Code Playgroud) 当我点击按钮时,这个错误就会爆炸!帮助请点击按钮时,此错误会爆炸!帮帮忙
TypeError:$ .ajax不是函数
$(document).on('click', '.item_add', function(e){
e.preventDefault();
product_id = $(".product_id").html();
product_name = $(".product_name").html();
product_price = parseFloat($(".item_price").html())
product_size = $(".bann-size").val();
url = '/basket_adding/'
var data = {};
data.product_id = product_id
data.product_name = product_name
data.product_price = product_price
data.product_size = product_size
$.ajax({
url: url,
type: 'POST',
data: data,
cache: true,
success: function(data){
console.log("OK");
},
error: function(data){
console.log(data + "ERROR")
alert("Something wrong, try again!")
location.reload();
}
});
});
Run Code Online (Sandbox Code Playgroud) 在服务器上发送此数据:
Object { categoryes: Array[2], brands: Array[2], discount_list: "all", category_slug: "accessories", category_of_relationsheep: "m" }
Run Code Online (Sandbox Code Playgroud)
如果我在服务器端打印 request.POST 我得到了这个:
<QueryDict: {'categoryes[]': ['Accessories', 'Bands'], 'brands[]': ['Nike', 'HBO'], 'discount_list': ['all'], 'csrfmiddlewaretoken': ['S7MXVEdQLd6u0fr4FugEwlupa45oChmw3TeItB4BEUHUHSsxrmVRuAcAhFxYQfpk'], 'category_slug': ['accessories'], 'category_of_relationsheep': ['m']}>
Run Code Online (Sandbox Code Playgroud)
我可以得到一个列表,例如“categoryes[]”(但为什么它用括号这样称呼?)
好的,如果我这样做: print(request.POST.get("categoryes[]")) 它将给出唯一的最后一个对象,
如何获得完整列表?具体像cotegoryes?如果让喜欢
for keys, values in request.POST.items():
print(values)
Run Code Online (Sandbox Code Playgroud)
它打印了这个字典中的所有值,但我不知道这些值来自哪里?如果我这样做:
for keys, values in request.POST.items():
if 'categoryes[]' == keys:
print(values)
Run Code Online (Sandbox Code Playgroud)
它只给出一个与类别相关的对象,但在这个列表中超过 1 个对象
当我提交时,这个错误被炸毁,谁能帮忙,欢迎,兄弟)!
堆栈问我添加更多文本,但要添加什么?如果一切都被告知?
但是要添加什么?如果一切都被告知?
该错误与日期有关
全追溯
> Internal Server Error: /accounts/reset_activation_key/ Traceback (most
> recent call last): File
> "C:\Users\P.A.N.D.E.M.I.C\Desktop\td11\lib\site-packages\django\core\handlers\exception.py",
> line 41, in inner
> response = get_response(request) File "C:\Users\P.A.N.D.E.M.I.C\Desktop\td11\lib\site-packages\django\core\handlers\base.py",
> line 187, in _get_response
> response = self.process_exception_by_middleware(e, request) File "C:\Users\P.A.N.D.E.M.I.C\Desktop\td11\lib\site-packages\django\core\handlers\base.py",
> line 185, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\P.A.N.D.E.M.I.C\Desktop\td11\newstudio\accounts\views.py",
> line 140, in reset_activation_key
> profile.save() File "C:\Users\P.A.N.D.E.M.I.C\Desktop\td11\lib\site-packages\django\db\models\base.py",
> line 806, in save
> force_update=force_update, update_fields=update_fields) File "C:\Users\P.A.N.D.E.M.I.C\Desktop\td11\lib\site-packages\django\db\models\base.py",
> line 836, in save_base
> …Run Code Online (Sandbox Code Playgroud) django ×3
python ×2
ajax ×1
caching ×1
chart.js ×1
django-views ×1
javascript ×1
jquery ×1
nginx ×1