mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
feat: Précablage du formulaire dynamique [N3WTS-17]
This commit is contained in:
@ -35,6 +35,18 @@ def build_payload_from_request(request):
|
||||
- supporte application/json ou form-data simple
|
||||
Retour: (payload_dict, None) ou (None, Response erreur)
|
||||
"""
|
||||
# Si c'est du JSON pur (Content-Type: application/json)
|
||||
if hasattr(request, 'content_type') and 'application/json' in request.content_type:
|
||||
try:
|
||||
# request.data contient déjà le JSON parsé par Django REST
|
||||
payload = dict(request.data) if hasattr(request.data, 'items') else request.data
|
||||
logger.info(f"JSON payload extracted: {payload}")
|
||||
return payload, None
|
||||
except Exception as e:
|
||||
logger.error(f'Error processing JSON: {e}')
|
||||
return None, Response({'error': "Invalid JSON", 'detail': str(e)}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
# Cas multipart/form-data avec champ 'data'
|
||||
data_field = request.data.get('data') if hasattr(request.data, 'get') else None
|
||||
if data_field:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user