Skip to content

Instantly share code, notes, and snippets.

@gabigab117
Created July 17, 2024 21:25
Show Gist options
  • Save gabigab117/f434f8de756cbcfb635a2ed044df9003 to your computer and use it in GitHub Desktop.
Save gabigab117/f434f8de756cbcfb635a2ed044df9003 to your computer and use it in GitHub Desktop.
@account_api.post("/official-document", url_name="add-document")
def add_official_document(request, file: UploadedFile = File(...)):
# create an instance of the OfficialDocument model with an user and a file
official_document = OfficialDocument.objects.create(user=User.objects.get(username="gab_test"))
# save the file in the media folder
official_document.document.save(file.name, ContentFile(file.read()))
return {"message": "Document enregistré"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment