Updated migrations, added swagger
This commit is contained in:
parent
a6fb473f09
commit
180b71c0f0
3
.env.example
Normal file
3
.env.example
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
SECRET_KEY=
|
||||||
|
ENVIRONMENT=
|
||||||
|
MIKRO_SECRET_KEY=
|
||||||
@ -40,9 +40,17 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
|
||||||
|
'corsheaders',
|
||||||
|
'rest_framework',
|
||||||
|
'django_filters',
|
||||||
|
'drf_spectacular',
|
||||||
|
|
||||||
|
'weather.apps.WeatherConfig'
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
'corsheaders.middleware.CorsMiddleware',
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
@ -54,6 +62,25 @@ MIDDLEWARE = [
|
|||||||
|
|
||||||
ROOT_URLCONF = 'project.urls'
|
ROOT_URLCONF = 'project.urls'
|
||||||
|
|
||||||
|
SPECTACULAR_SETTINGS = {
|
||||||
|
'TITLE': 'Weather Mikro API',
|
||||||
|
'DESCRIPTION': 'Weather stats by weather',
|
||||||
|
'VERSION': '1.0.0',
|
||||||
|
'COMPONENT_SPLIT_REQUEST': True
|
||||||
|
}
|
||||||
|
|
||||||
|
CORS_ALLOW_ALL_ORIGINS = True
|
||||||
|
|
||||||
|
REST_FRAMEWORK = {
|
||||||
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||||
|
'PAGE_SIZE': 20,
|
||||||
|
'DEFAULT_AUTHENTICATION_CLASSES': [
|
||||||
|
|
||||||
|
],
|
||||||
|
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
|
||||||
|
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
|
||||||
|
}
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
|||||||
@ -14,9 +14,16 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
|
||||||
|
path('swagger/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
|
||||||
|
path('api/', include([
|
||||||
|
# path('', include('weather.urls')),
|
||||||
|
])),
|
||||||
]
|
]
|
||||||
|
|||||||
16
requirements.txt
Normal file
16
requirements.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
asgiref==3.11.0
|
||||||
|
attrs==25.4.0
|
||||||
|
Django==5.2.8
|
||||||
|
django-filter==25.2
|
||||||
|
django-rest-framework==0.1.0
|
||||||
|
djangorestframework==3.16.1
|
||||||
|
drf-spectacular==0.29.0
|
||||||
|
inflection==0.5.1
|
||||||
|
jsonschema==4.25.1
|
||||||
|
jsonschema-specifications==2025.9.1
|
||||||
|
python-dotenv==1.2.1
|
||||||
|
PyYAML==6.0.3
|
||||||
|
referencing==0.37.0
|
||||||
|
rpds-py==0.29.0
|
||||||
|
sqlparse==0.5.3
|
||||||
|
uritemplate==4.2.0
|
||||||
25
weather/migrations/0001_initial.py
Normal file
25
weather/migrations/0001_initial.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Generated by Django 5.2.8 on 2025-11-21 10:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='WeatherStats',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('humidityAir', models.FloatField(default=0)),
|
||||||
|
('humidityGround', models.FloatField(default=0)),
|
||||||
|
('temperature', models.FloatField(default=0)),
|
||||||
|
('light', models.FloatField(default=0)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
@ -2,7 +2,11 @@ from django.db import models
|
|||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
class WeatherStats(models.Model):
|
class WeatherStats(models.Model):
|
||||||
|
humidityAir = models.FloatField(default=0)
|
||||||
humidity = models.FloatField(default=0)
|
humidityGround = models.FloatField(default=0)
|
||||||
temperature = models.FloatField(default=0)
|
temperature = models.FloatField(default=0)
|
||||||
|
light = models.FloatField(default=0)
|
||||||
created_at = models.DateTimeField(auto_now_add=True)
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return 'Weather data by ' + self.created_at
|
||||||
0
weather/urls.py
Normal file
0
weather/urls.py
Normal file
Loading…
x
Reference in New Issue
Block a user