# add mosq app

This commit is contained in:
xianfuxing 2018-07-11 20:30:23 +08:00
parent 3675cb16ac
commit e978890785
9 changed files with 60 additions and 3 deletions

0
apps/__init__.py Normal file
View File

View File

3
apps/mosquito/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
apps/mosquito/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class MosquitoConfig(AppConfig):
name = 'apps.mosquito'

36
apps/mosquito/models.py Normal file
View File

@ -0,0 +1,36 @@
from django.db import models
class Mosquito(models.Model):
device_id = models.CharField(max_length=100, verbose_name='设备ID')
region = models.CharField(max_length=50, verbose_name='区域')
class Meta:
verbose_name = '灭蚊灯'
verbose_name_plural = verbose_name
def __str__(self):
return self.device_id
def get_absolute_url(self):
pass
def get_api_url(self):
pass
class MosqPost(models.Model):
mosq = models.ForeignKey(Mosquito, verbose_name='灭蚊灯', on_delete='PROTECT')
led = models.PositiveIntegerField(max_length=30, verbose_name='灭蚊数')
energy = models.PositiveIntegerField(max_length=10, verbose_name='电量')
times = models.DateTimeField(auto_now=False, auto_now_add=True)
class Meta:
verbose_name = '灭蚊数据'
verbose_name_plural = verbose_name
def __str__(self):
return self.mosq
def get_api_url(self):
pass

3
apps/mosquito/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
apps/mosquito/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View File

@ -11,9 +11,11 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
"""
import os
import sys
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
# Quick-start development settings - unsuitable for production
@ -37,6 +39,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mosquito',
]
MIDDLEWARE = [
@ -76,8 +79,12 @@ WSGI_APPLICATION = 'mosqkiller.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mosqkiller',
'USER': 'mosq_admin',
'PASSWORD': 'Q5BkPk62mqeBxI_lHh2',
'HOST': '47.106.73.20',
'PORT': 3326
}
}

View File

@ -17,5 +17,5 @@ from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
path('mosq_admin/', admin.site.urls),
]