# Uploading Image to database - advice

**URL:** <https://forum.djangoproject.com/t/uploading-image-to-database-advice/24382>\
**Category:** Getting Started\
**Created:** [October 7, 2023, 2:56pm UTC](https://forum.djangoproject.com/t/uploading-image-to-database-advice/24382 "2023-10-07T14:56:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jslovern391](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jslovern391/32/16283_2.png) [@jslovern391](https://forum.djangoproject.com/u/jslovern391)\
**Post date:** [October 7, 2023, 2:56pm UTC](https://forum.djangoproject.com/t/uploading-image-to-database-advice/24382/1 "2023-10-07T14:56:55Z")

</div>

When I create a new user, a QR code is created and stored in a file path. I would like to upload the image to the customuser model and also display the QR code as a URL.

Any advice to get started would be appreciated.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [October 7, 2023, 4:05pm UTC](https://forum.djangoproject.com/t/uploading-image-to-database-advice/24382/2 "2023-10-07T16:05:09Z")

</div>

See:

- [FileField](https://docs.djangoproject.com/en/4.2/ref/models/fields/#filefield)
- [ImageField](https://docs.djangoproject.com/en/4.2/ref/models/fields/#imagefield)
- [Managing files | Django documentation | Django](https://docs.djangoproject.com/en/4.2/topics/files/#managing-files)
- [File Uploads | Django documentation | Django](https://docs.djangoproject.com/en/4.2/topics/http/file-uploads/#file-uploads)  
and possibly:
- [Uploaded Files and Upload Handlers | Django documentation | Django](https://docs.djangoproject.com/en/4.2/ref/files/uploads/#module-django.core.files.uploadedfile)

There are also numerous posts here discussing this topic in various degrees of detail, along with numerous blog posts and videos that can be found by searching the internet.

---

<div class="post-metadata">

**Author:** ![jslovern391](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jslovern391/32/16283_2.png) [@jslovern391](https://forum.djangoproject.com/u/jslovern391)\
**Post date:** [October 7, 2023, 8:30pm UTC](https://forum.djangoproject.com/t/uploading-image-to-database-advice/24382/3 "2023-10-07T20:30:03Z")

</div>

Have done research and most of what I find is uploading through the URL. I want to save to media/qrcodes/ as part of the view functions.

```auto
def fisher_accept(username):
        fish = CustomUser.objects.get(username=username)
        fish_qr = qrcode.make(f'{get_current_site}/accounts/signup/' + fish.alias_name)
        fish_qr.save(f'{FileSystemStorage(location='media/qrcodes/')}{fish.alias_name}.png')
fisher_accept(username='testuser')

```

Error  
OSError: [Errno 22] Invalid argument: ‘\<django.core.files.storage.filesystem.FileSystemStorage object at 0x0000028588ADAFC0\>testuser.png’

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [October 8, 2023, 12:21am UTC](https://forum.djangoproject.com/t/uploading-image-to-database-advice/24382/4 "2023-10-08T00:21:37Z")

</div>

> [@jslovern391](#):
>
> `FileSystemStorage(location='media/qrcodes/')`

This expression creates an instance of a FileSystemStorage class - and as you can see, the string representation is: `<django.core.files.storage.filesystem.FileSystemStorage object at 0x0000028588ADAFC0>`, which is what the error message is showing you - that’s obviously not what you want in that string.

What is the information that you’re looking to get from that object? That is what you want represented in the `save` method.
