可重复使用的django室外和室内地图应用程序

django-loci的Python项目详细描述


django位点图片::https://travis ci.org/openwisp/django locations.svg
:目标:https://travis ci.org/openwisp/django locations

…图片::https://coveralls.io/repos/openwisp/django locits/badge.svg
:目标:https://coveralls.io/r/openwisp/django locits

图片::https://requires.io/github/openwisp/django-locis/requirements.svg?branch=master
:目标:https://requires.io/github/openwisp/django-locis/requirements/?branch=master
:alt:需求状态

…图片::https://badge.fury.io/py/django locations.svg
:目标:http://badge.fury.io/py/django locations

----


>可重复使用的django应用程序,用于存储地理信息系统和对象的室内坐标。

-


。目录::**目录**:
:反向链接:无
:深度:3

——
——

——
——
——

*python 2.7或python>;=3.4
*`geodjango<;https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/requirements>;`
*geodjango支持的数据库之一


代码块::shell


install development version
----


首先,安装"geodjango<;https://docs.djangoproject.com/en/2.1/ref/contrib/gis/>;的依赖项:``uu:

-`geospatial libraries<;https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/geolibs/>;`
-`空间数据库<;https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/spatialite/>;` `,
对于开发,我们使用spatialite,一个空间扩展名为`sqlite<;https://www.sqlite.org/index.html>;`

安装tarball:

…代码块::shell

pip安装https://github.com/openwisp/django locis/tarball/master

代码块::shell

pip install-e git+git://github.com/openwisp/django-locations egg=django-locations

代码块::shell

git clone git@github.com:<;your撸fork>;/django locits.git
cd django撸locits
python set up.py develop

setup(集成到现有django项目中)
"Geodjango支持的空间数据库之一"的引擎<;https://docs.djangoproject.com/en/2.1/ref/contrib/gis/db-api/spatial backends>;` ` ` `.

代码块::python


"频道"

]


根据需要配置"频道层",示例配置可以是:

……代码块::python

channel棼layers={
"default":{
"backend":"asgiref.inmemory.channellayer",
"routing":"django棼locis.channels.routing.channel棼routing",
},
}

代码块::shell

./manage.py migrate

Troubleshooting
----


以下异常:

django.core.exceptions.impropertyconfigured:无法加载Spatialite库扩展名

您需要在"settings.py"中指定"Spatialite库路径",如"django文档"中有关如何安装和配置的说明
空间
<;https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/spatialite/>;` ` `.

https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/library environment settings>;` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ```|
+——+——+——————+————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————图像。

查看
`django_locations.storage.overwritestorage
<;的代码https://github.com/openwisp/django locations/blob/master/django_locations/storage.py>;`.

extending django locits
----

*django locits*提供了一组模型和管理类,可由第三方应用程序导入、扩展和重用。


但是您必须创建自己的应用程序(进入"settings.installed廑apps`)",
导入django轨迹的基类并添加自定义项。

扩展模型
~~~~~~~~~~~~~~~~~~~~

此示例提供了如何扩展
*django轨迹的基类模型的示例*通过将关系添加到另一个名为"organization"的django模型。

…代码块:应用程序的python

#为了简洁起见,省略了模型"organizations.organization"
查看django组织



class organizationmixin(models.model):
organization=models.foreignkey('organizations.organization')


class meta:
abstract=true


class location(organizationmixin,abstractlocation):
类meta(abstractLocation.meta):
abstract=false

def clean(self):
AbstractFloorplan):
location=models.foreignkey(location)

abstract=false

objectlocation(organizationmixin,abstractobjectlocation):
location=models.foreignkey(location,models.protect,
blank=true,null=true)
floorplan=models.foreignkey(floorplan,models.protect,
blank=true,null=true)

abstract=false

def clean(self):
在前面的"组织"示例中,通过导入基本管理类并在其中注册模型,可以避免复制管理代码。

`` settings.py``,这些是加载*django locits*的管理模板和静态文件所必需的,即使它没有在``settings.installed`apps``中列出。


将``django.forms``添加到``installed`apps``中,现在应该如下所示:

代码块::python

installed廑apps=[
廑…
"django.contrib.gis"、
"django廑u locits"、
"django.contrib.admin"、
"django.forms"、"廑<;--添加此项
"频道"
"…
]


代码块::python


已安装的应用程序=[
代码块::python

staticfiles\u finders=[
'django.contrib.staticfiles.finders.filesystemfinder',
'django.contrib.staticfiles.finders.appdirectoriesfinder',
'openwisp\u utils.staticfiles.dependencyfinder',
]

代码块::python

templates=[
{
'backend':'django.template.backends.django.djangotemplates',
'dirs':[],
'options':{
'loaders':[
'django.template.loaders.filesystem.loader',
django.template.loaders.app_directories.loader',
添加以下行
"openwisp实用程序.loaders.dependencyloader"

"上下文处理器":[
"django.template.context廑processors.debug",
"django.template.context廑processors.request",
"django.contrib.auth.context廑processors.auth",
"django.contrib.messages.context_processors.messages"、
]、
}、
}
]


>最后一步,添加"表单呈现器"`:

……代码块::python

form\renderer='django.forms.renderers.templatesseting'

,然后可以按照下面的示例创建您的"admin.py"文件:

。代码块:python

AbstractLocationForm,AbstractObjectLocationForm,
AbstractObjectLocationInline)
来自Django_座位。模型导入楼层平面、位置、对象位置




类楼层平面(AbstractFloorPlanForm):
类meta(abstractfloorplanform.meta):
model=floorplan



class floorplanadmin(abstractfloorplanadmin):
form=floorplanform



class locationform(abstractlocationform):
class meta(abstractlocationform.meta):
模型=位置



Class Floorplan inline(AbstractFloorplan inline):
form=Floorplan form
model=Floorplan




Class LocationAdmin(AbstractLocationAdmin):
form=LocationForm
inline=[Floorplan inline]



类objectlocation form(abstractobjectlocationform):
class meta(abstractobjectlocationform.meta):
model=objectlocation



class objectlocationinline(abstractobjectlocationinline):
model=objectlocation
form=对象位置窗体



admin.site.register(floorplan,floorplanadmin)
admin.site.register(位置,位置管理)

代码块::python

from django_locations.channels.base import base locationbroadcast
from..models import location\your own location model



class locationbroadcast(baselocationbroadcast):
model=location

appconfig
~~~~~~~~~~~~~~~~~~~~~~~~~


您可能也希望重用*django位点*的"appconfig"类:

……代码块::python

from django_locations.apps导入lociconfigself.location_model=location


为开发而安装代码块::shell

sudo apt get install sqlite3 libsqlite3 dev libsqlite3 mod spatialite

install your forked repo:

……代码块::shell

git clone git://github.com/<;your撸fork>;/django locits
cd django locits/
python setup.py develop

安装测试要求:

代码块::shell

pip install-r requirements test.txt


>创建数据库:

…代码块::shell

cd tests/
./manage.py migrate
./manage.py createsuperuser

代码块::shell

./manage.py runserver

代码块::shell

./runtests.py

contribution
----

>1。在"openwisp邮件列表"https://groups.google.com/d/forum/openwisp>;中宣布您的意图。分叉此repo并安装它
3。遵循"pep8,python代码的样式指南"4。编写代码
5。为代码编写测试
6。确保所有测试均通过
7。确保测试覆盖率不会降低
8。记录您的更改
9。发送拉取请求

…_ pep8,python代码的样式指南:http://www.python.org/dev/peps/pep-0008/

https://github.com/openwisp/django-locis/blob/master/license>;`.



欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
图像处理Java 8 ImageIO在Linux中无法正确读取JPEG   spring如何用Java 1.4兼容版本替换@Resource注释   java Http请求参数类型传播   在web浏览器中看不到Java Maven Tomcatplugin web应用程序   jvm在Java中使用直接内存的目的是什么?   如何从列表转换为字符串java   java setAdapter gridview发送上下文   SwingJava。方法上的lang.NullPointerException   java什么是shell脚本、makefile和ant文件   当使用getGraphics()方法时,java JPanel图形会闪烁   java如何将迭代转换为递归?   java为什么我的抽屉菜单在同一个XML上有ConstraintLayout时没有响应?   java如何在图像上画一个圆?   Android studio:Rabbitmq:Error:java。lang.ClassNotFoundException:类io。千分尺。果心仪器找不到仪表注册表