小编Jon*_*edy的帖子

当columnDefs具有字段作为类型编号时,Angular ui网格按字符串过滤.为什么?

我正在使用django 1.8,angularjs 1.3.14和jquery 1.11.0.

这是在Controller/gridOptions/columnDefs中.

{ field: 'credit_amt',                
  displayName: 'Credit Amount',           
  type: 'number', 
  width: '8%',   
  enableFocusedCellEdit: true, 
  visible:true,
  //This 'filters' is the sort box to do the search.
  filters: [{   
            condition: uiGridConstants.filter.GREATER_THAN,
            placeholder: 'greater than'
          }
Run Code Online (Sandbox Code Playgroud)

请注意,'type'是一个数字.当我运行此程序时,程序将此字段视为字符串而不是数字.因此排序不能按照我需要的方式运行.
我试图省略'type'并让它自动检测数据类型. - 不行.

以下是使用前后的排序:

在添加搜索项之前

只需在搜索字段中添加6即可

如您所见,当没有数据小于6时,项目被过滤.请帮忙.谢谢.

django grid user-interface angularjs angular-ui-grid

8
推荐指数
1
解决办法
6616
查看次数

如何使用virtualenv和Django隐藏我的secret_key?

我正在使用Django,python,virtualenv,virtualenvwrapperVagrant.

到目前为止,我只是secret_keysettings.py文件留在文件内部.这适用于本地文件.但是我已经将我的文件放在Git中了.我知道这对于生产来说是不可接受的(Apache).

隐藏我的正确方法是什么secret_key

我应该virtualenv用来隐藏吗?

python django virtualenv

8
推荐指数
2
解决办法
5211
查看次数

我可以在django TemplateView中设置不同的'template_name吗?

使用Django视图我想根据用户的权限级别重定向用户.

我有一个有效的模板视图.

class theTableView(generic.TemplateView):
    template_name = 'adminTable.html'
Run Code Online (Sandbox Code Playgroud)

我想做的事情看起来像这样:

class TheTableView(generic.TemplateView):
    if self.request.user.is_superuser==True:
        tempTemplate = 'goodAdminTable.html'
    elseif self.request.user.is_authenticated==True:
        tempTemplate = 'goodUserTable.html'
    template_name = tempTemplate
Run Code Online (Sandbox Code Playgroud)

我能够在数据的rest_framework api返回中执行此操作.

我需要能够检查用户权限并根据结果将它们重定向到相应的template_name.

任何帮助表示赞赏.谢谢.

django django-templates django-views django-rest-framework

2
推荐指数
1
解决办法
929
查看次数

如何使用 PyPDF2 获取 Pdf 方向

我正在使用 Python/Django。
PyPDF2 来阅读我当前的 pdf。

我想阅读我保存的 pdf 并获取 pdf 中单个页面的方向。

我希望能够确定页面是横向还是纵向。

tempoutpdffilelocation =  settings.TEMPLATES_ROOT + nameOfFinalPdf
pageOrientation = pageToEdit.mediaBox
pdfOrientation = PdfFileReader(file(temppdffilelocation, "rb"))
# tempPdfOrientationPage = pdfOrientation.getPage(numberOfPageToEdit).mediaBox
print("existing pdf width: ")
# print(existing_pdf.getPage(numberOfPageToEdit).getWidth)
# print("get page size with rotation")
# print(tempPdfOrientationPage.getPageSizeWithRotation) 

existing_pdf = pdfOrientation.getPage(numberOfPageToEdit).mediaBox
# print(pageOrientation)
if pageOrientation.getUpperRight_x() - pageOrientation.getUpperLeft_x() > pageOrientation.getUpperRight_y() - pageOrientation.getLowerRight_y():
  print('Landscape')
  print(pageOrientation)
  # print(pdfOrientation.getWidth())
else:
  print('Portrait')
  print(pageOrientation)
  # print(pdfOrientation.getWidth())
# create a new PDF with Reportlab
can = canvas.Canvas(packet, pagesize=letter)
Run Code Online (Sandbox Code Playgroud)

最后一行设置 pagesize=letter 我想根据我当前的 pdf 确定什么。
这是我的进口: …

python pdf django reportlab pypdf2

1
推荐指数
1
解决办法
5745
查看次数