models

Django --- ORM

冷暖自知 提交于 2019-12-05 20:37:17
目录 使用数据库之前的配置工作 单表操作常用的方法 使用数据库之前的配置工作 settings.py中的配置 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'day53', 'USER':'root', 'PASSWORD':'123qwe', 'HOST':'127.0.0.1', 'PORT':3306, 'CHARSET':'utf8' }} LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console':{ 'level':'DEBUG', 'class':'logging.StreamHandler', }, }, 'loggers': { 'django.db.backends': { 'handlers': ['console'], 'propagate': True, 'level':'DEBUG', }, } } init.py中的配置 import pymysql pymysql.install_as_MySQLdb() test.py中配置 import os if __name__ == "__main__": os.environ.setdefault(

How to run multiple graphs in a Session - Tensorflow API

大兔子大兔子 提交于 2019-12-05 16:03:55
问题 Tensorflow API has provided few pre-trained models and allowed us to trained them with any dataset. I would like to know how to initialize and use multiple graphs in one tensorflow session. I want to import two trained models in two graphs and utilize them for object detection, but I am lost in trying to run multiple graphs in one session. Is there any particular method to work with multiple graphs in one session?. Another issue is, even if I create two different sessions for 2 different

django-filter的基本使用

半腔热情 提交于 2019-12-05 15:43:46
django-filter 查询 创建model和视图 from django.db import models # Create your models here. class Student(models.Model): SEX_CHOICES = ( (0, '女'), (1, '男') ) name = models.CharField(max_length=10) sex = models.SmallIntegerField(choices=SEX_CHOICES) courses = models.ManyToManyField('Course') teacher = models.ForeignKey('Teacher', on_delete=models.SET_NULL, null=True) def __str__(self): return self.name class Teacher(models.Model): name = models.CharField(max_length=10) def __str__(self): return self.name class Course(models.Model): name = models.CharField(max_length=10) def __str__(self): return self

django自定義權限組件

纵饮孤独 提交于 2019-12-05 13:56:16
一個網站如果沒有權限控管,就等於是沒有保安的辦公大樓,所有人都可以任意進出任何地點使用任何資料。 但我們也希望能夠製作一個可以插拔的權限控管,可以先把主要業務邏輯做好以後,再把權限控管加入,不用做太大的更動。 目前這個組件的目錄結構是長這樣子: rbac ├─service │ ├─middlewares.py │ └─rbac.py├─template│ └─menu.html ├─tempaletags │ └─myilters.py └─models.py 我學習的是rbac(Role Based Access Control)權限控制模型,也就是依照使用者角色來區分權限。 這個方式的好處就是,不必在同一個權限上重複添加使用者,而是藉由角色來套用權限,減少儲存空間的浪費。 表結構: from django.db import models #用戶表 class User(models.Model): name = models.CharField(max_length=32) # password = models.CharField(max_length=32) roles = models.ManyToManyField("Role") def __str__(self): return self.name #角色表 class Role(models.Model):

extjs treestore with proxy

三世轮回 提交于 2019-12-05 13:14:25
I'm creating a MVC extjs application. I've got a treepanel with a store, which is loading the data from a php source. I get the following json-formatted response: [ { "text": "Home", "leaf": true, "dbName": "NULL", "children": [] }, { "text": "Moje Firma s.r.o.", "leaf": false, "expanded": false, "children": [ { "text": "Vydane", "leaf": true, "dbName": "demo" }, { "text": "Prijate", "leaf": true, "dbName": "demo" } ] }, { "text": "Já Živnostník", "leaf": false, "expanded": false, "children": [ { "text": "Vydane", "leaf": true, "dbName": "demo_de" }, { "text": "Prijate", "leaf": true, "dbName"

目标检测_1

早过忘川 提交于 2019-12-05 12:14:54
Keywords :Ubuntu,VOC,Object_detection 1,环境搭建 ​ 使用anaconda3, 先安装 ​ 换源,若不然会非常慢 方式参考 https://www.cnblogs.com/Dean0731/p/11560371.html ​ export PATH="/usr/local/anaconda3/bin:$PATH" ​ 新建虚拟环境 本例python=3.5 ​ 进入环境本例安装的tensorflow=1.14.0 ​ 安装其他依赖包,pillow,lxml 等,亦可以等待报错时安装相应模块 2,下载数据 models: https://github.com/tensorflow/models.git 使用git下载 或直接下载zip VOC2012:链接: https://pan.baidu.com/s/12IP4iyL9hN5Dohzkm8wi7A 提取码: q31q 也可到官网下载,比较慢 visual object classes 2012 一共20类别,一共5个文件夹 JPEGImages存放图片; Annotation存放对图片的标注信息(XML文件),即外包边框bounding box的位置信息; SegmentationClass和SegmentationObject存放了图片的分割前景。 ImageSets是对图片集合的描述

Django class overrides fails System check

烈酒焚心 提交于 2019-12-05 10:05:27
I am trying to upgrade from Django 1.7.1 to 1.8 on my dev env. I seem to be having an issue with one of my models, I think a core file got upgraded and its messing with my model. I cant seem to figure out what's causing it to die. This is the only error I get when I attempt to run a manage.py test CommandError: System check identified some issues: ERRORS: graphite_alerts.CheckResults: (models.E020) The 'CheckResults.check()' class method is currently overridden by <django.db.models.fields.related.ReverseSingleRelatedObjectDescriptor object at 0x3a76310>. I tried changing the class name and

Zend: How to use a custom function from a view helper in the controller?

谁说胖子不能爱 提交于 2019-12-05 09:45:58
Ive got a view helper in library/my/view/helper/gravatar and so in any view I can call $this->gravatar($email) . But how can I access this function in the models (or controllers)? Sorry if its already been asked but Im new and the documentation is bloody awful in parts. Thanks everyone In your controller, you can access ViewHelpers through $this->view->gravatar($email) Your model should not call methods from the View, as it would tie the model to the presentation layer. The View may know about the model, but the model should not know about the View. For Gravatars, there is also a Service and

How to have two models reference each other Django

十年热恋 提交于 2019-12-05 09:20:23
问题 I have the following code: class Game(models.Model): title = models.CharField(max_length=50) summery = models.CharField(max_length=500) key = models.IntegerField() pin = models.CharField(max_length=12) complete = models.BooleanField() invite_sent = models.DateTimeField() on = models.ForeignKey(Member, blank = True) #<---- class Member(models.Model): email = models.CharField(max_length=100) color = models.CharField(max_length=11) game = models.ForeignKey(Game) #<---- The "on" foreign key links

Split queryset or get multiple querysets by field instead of just ordering by field

孤街醉人 提交于 2019-12-05 09:14:26
I want to query a database in a way such that rather than just ordering by some field, I get a separate QuerySet (or dictionary, list, whatever) for each unique value of that field. Hopefully the below example will help: Suppose a model like Class Person(models.Model): first_name = models.CharField() last_name = models.CharField Calling Person.objects.all().order_by('last_name') gives me a single long QuerySet. I want instead to have a separate list for each unique last_name. So one list for every Person with last_name="Smith" and another list for every Person with last_name="Nguyen" etc.