[DRF] API 호출 URL

[API 호출 URL]

urls.py

router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet, basename='user')
router.register(r'groups', views.GroupViewSet, basename='group')
router.register(r'obslogs', views.ObslogViewSet, basename='obslog')

url

http://localhost:8000/api/obslogs/ (GET - Note List)
http://localhost:8000/api/obslogs/ (POST - Create Note)
http://localhost:8000/api/obslogs/{id}/ (GET - Get Single Note by id)
http://localhost:8000/api/obslogs/{id}/ (PATCH - update partial)

http://localhost:8000/api/obslogs/{id}/ (DELETE - destroy a single note by id)

api url call

d = {
        'who_user':who_user, 
        'who_ip':who_ip, 
        'who_useragent':who_useragent,
        'who_device':who_device,
        'who_device_type':who_device_type,
        'who_device_family':who_device_family,
        'who_device_brand':who_device_brand,
        'who_device_model':who_device_model,
        'who_browser':who_browser,
        'who_browser_family':who_browser_family,
        'who_browser_version_string':who_browser_version_string,
        'who_os':who_os,
        'who_os_family':who_os_family,
        'who_os_version_string':who_os_version_string,
        'what_object_type':what_object_type, 
        'what_object_name':what_object_name,
        'what_object':what_object,
        'where_ip':where_ip, 
        'where_continent':where_continent,
        'where_country':where_country,  
        'where_city':where_city,     
        'where_zipcode':where_zipcode,  
        'where_latitude':where_latitude, 
        'where_longitude':where_longitude,
        'where_region':where_region,  
        'where_timezone':where_timezone, 
        'how_action':how_action, 
        'why':why
    }

    headers = {'Content-type': 'application/json'}
    data = requests.post('http://clear.prefity.com/api/obslogs/', data=json.dumps(d), headers=headers)

댓글

이 블로그의 인기 게시물

[Django Install] 9.1 sc제일은행 nginx-django 연결

[Django APP] django-widget-tweaks

[Django App] django-user-agents