Earlier I was using default database sqlite3, but today i've changed it to postgresql.
I wants to save the image files in database not in project directory itself. How can I do that?
This is not a good idea to store an image in DB instead media
folder. But you can use BinaryField for this:
model.py
class MyModel(model.Model):
image = models.BinaryField(blank=True)
view.py
def image(request):
image_file = request.FILES['image_file'].file.read()
MyModel.objects.create(image=image_file)