Created
July 17, 2024 21:25
-
-
Save gabigab117/f434f8de756cbcfb635a2ed044df9003 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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