我在我的项目中实现搜索我想要的是在where子句中连接到列以从表中获取结果.
这是我在做的事情:
from django.db.models import Q
if 'search[value]' in request.POST and len(request.POST['search[value]']) >= 3:
search_value = request.POST['search[value]'].strip()
q.extend([
Q(id__icontains=request.POST['search[value]']) |
(Q(created_by__first_name=request.POST['search[value]']) & Q(created_for=None)) |
Q(created_for__first_name=request.POST['search[value]']) |
(Q(created_by__last_name=request.POST['search[value]']) & Q(created_for=None)) |
Q(created_for__last_name=request.POST['search[value]']) |
(Q(created_by__email__icontains=search_value) & Q(created_for=None)) |
Q(created_for__email__icontains=search_value) |
Q(ticket_category=request.POST['search[value]']) |
Q(status__icontains=request.POST['search[value]']) |
Q(issue_type__icontains=request.POST['search[value]']) |
Q(title__icontains=request.POST['search[value]']) |
Q(assigned_to__first_name__icontains=request.POST['search[value]']) |
])
Run Code Online (Sandbox Code Playgroud)
现在我想添加另一个OR条件,如:
CONCAT(' ', created_by__first_name, created_by__last_name) like '%'search_value'%"
但是当我将这个条件添加到查询集时,它变为AND
where = ["CONCAT_WS(' ', profiles_userprofile.first_name, profiles_userprofile.last_name) like '"+request.POST['search[value]']+"' "]
tickets = Ticket.objects.get_active(u, page_type).filter(*q).extra(where=where).exclude(*exq).order_by(*order_dash)[cur:cur_length]
Run Code Online (Sandbox Code Playgroud)
如何将其转换为OR条件?
我想在添加/删除按钮的同时从父DOM元素添加/删除类,例如,如果我单击添加类按钮,则它将新的类名称“单击”添加到父div,并在单击删除类按钮时删除该类:
index.html
<div class="main-div">
<div class="second-div" id="config">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
config.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import Main from 'Main';
ReactDOM.render(
<Main/>,
document.getElementById('config')
);
Run Code Online (Sandbox Code Playgroud)
Main.jsx
import ReactDOM from 'react-dom'
import React from "react";
import createReactClass from "create-react-class";
export default createReactClass({
getInitialState() {
return {
show-main-div: false
};
},
addClass() {
// want to add new class on parent DOM element i.e <div class="main-div">
},
render: function () {
return (
<div>
<button className="add-class" onClick={() => {this.addClass()}}>
Add Class …Run Code Online (Sandbox Code Playgroud) 当特定 URL 匹配时,我想跳过所有重写 URL。我想打开这个页面:
https://www.example.com/.well-known/pki-validation/godaddy.html
Run Code Online (Sandbox Code Playgroud)
如果godaddy.html匹配 URL。这是我在做什么:
RewriteCond "%{REQUEST_URI}" "==/godaddy.html"
RewriteRule ^(.*)$ https://www.example.com/.well-known/pki-validation/godaddy.html [L]
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ https://www.example.com/index.php
Run Code Online (Sandbox Code Playgroud)
但它不起作用。我也试过这个[END]标志,但是当我写标志时,[END]它给了我 500 个内部服务器错误。
我正在使用数据表,并且要在单击该行时删除选定的行。
这是datatabe的代码
$('.data-table').dataTable({
"aaSorting": [],
"oLanguage": {"sSearch": ""},
"fnDrawCallback": function (oSettings) {}
});
Run Code Online (Sandbox Code Playgroud)
这是删除功能...
<input type="button" class="btndel btn-primary btn btn-primary" onclick=" $(this).closest('tr').addClass('selected');
if ($('.tab1').hasClass('active')) {
var rows = $('.data-table').dataTable().row('.selected').remove().draw();
var xSum = 0;
var items = document.getElementsByClassName('pp');
var itemCount = items.length;
var total = 0;
$('.pp').each(function () {
var che = isNaN($(this).text());
if (che == false) {
xSum += parseFloat($(this).text());
}
});
var value1 = xSum / parseInt(itemCount);
$('#avgsold').text(value1.toFixed(2));
}
if ($('.tab2').hasClass('active')) {}" value="Delete" />
Run Code Online (Sandbox Code Playgroud)
但这给了错误
未捕获的TypeError:$(...)。dataTable(...)。row不是函数
提前致谢
.htaccess ×1
apache ×1
datatables ×1
django ×1
jquery ×1
mod-rewrite ×1
mysql ×1
python ×1
reactjs ×1