api
This commit is contained in:
parent
fbd2b76e0d
commit
56d0c52d42
8 changed files with 56 additions and 20 deletions
12
api/serializers/event.py
Normal file
12
api/serializers/event.py
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
from rest_framework import serializers
|
||||||
|
from web.models.event import Event
|
||||||
|
|
||||||
|
|
||||||
|
class EventSerializer(serializers.ModelSerializer):
|
||||||
|
# to_representation(self, instance) if needed
|
||||||
|
# fk = Serializer()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Event
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
0
api/services/event.py
Normal file
0
api/services/event.py
Normal file
|
|
@ -1,3 +0,0 @@
|
||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
|
|
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
|
"rest_framework",
|
||||||
"web",
|
"web",
|
||||||
"api",
|
"api",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,10 @@
|
||||||
"""
|
|
||||||
URL configuration for localist project.
|
|
||||||
|
|
||||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
|
||||||
https://docs.djangoproject.com/en/6.0/topics/http/urls/
|
|
||||||
Examples:
|
|
||||||
Function views
|
|
||||||
1. Add an import: from my_app import views
|
|
||||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
|
||||||
Class-based views
|
|
||||||
1. Add an import: from other_app.views import Home
|
|
||||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
|
||||||
Including another URLconf
|
|
||||||
1. Import the include() function: from django.urls import include, path
|
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
||||||
"""
|
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
|
from api.views.event import EventView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
|
path("api/event/<int:event_id>", EventView.as_view(), name="event"),
|
||||||
|
path("api/event", EventView.as_view(), name="event")
|
||||||
]
|
]
|
||||||
|
|
|
||||||
10
requirements.txt
Normal file
10
requirements.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
asgiref==3.11.1
|
||||||
|
certifi==2026.5.20
|
||||||
|
charset-normalizer==3.4.7
|
||||||
|
Django==6.0.6
|
||||||
|
django-rest-framework==0.1.0
|
||||||
|
djangorestframework==3.17.1
|
||||||
|
idna==3.18
|
||||||
|
requests==2.34.2
|
||||||
|
sqlparse==0.5.5
|
||||||
|
urllib3==2.7.0
|
||||||
20
test_requests/create_event.py
Normal file
20
test_requests/create_event.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import requests
|
||||||
|
|
||||||
|
url = "http://127.0.0.1:8000/api/event"
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"name": "Test Event 2",
|
||||||
|
"description": "this is a test",
|
||||||
|
"url": "https://www.domdit.com",
|
||||||
|
"address": "31 Fleetwood Dr Hazlet Nj",
|
||||||
|
"status": "scheduled",
|
||||||
|
"price": "10.00",
|
||||||
|
"require_rsvp": False,
|
||||||
|
"start_time": "2026-06-14T01:34:39Z",
|
||||||
|
"end_time": "2026-08-14T01:34:38Z",
|
||||||
|
"rain_date": "2026-06-15T01:34:42Z",
|
||||||
|
"email": "me@domdit.com",
|
||||||
|
"phone_number": ""
|
||||||
|
}
|
||||||
|
|
||||||
|
requests.post(url, data=data)
|
||||||
9
test_requests/update_event.py
Normal file
9
test_requests/update_event.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import requests
|
||||||
|
|
||||||
|
url = "http://127.0.0.1:8000/api/event/1"
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"name": "diddy freakoff",
|
||||||
|
}
|
||||||
|
|
||||||
|
requests.put(url, data=data)
|
||||||
Loading…
Reference in a new issue