imagefield

django set image delete old reference and prevent delete default

django set image delete old reference and prevent delete default Question: despite of many mordern website employ an OSS for serving image, I still want to build a backend to manage small thumbnails locally. however, django image field is a bit tricky. there are three views I may change image reference: models.py views.py forms.py I …

Total answers: 1

How do I detect if my user has uploaded an ImageField or FileField?

How do I detect if my user has uploaded an ImageField or FileField? Question: I have the following model and function to set the upload paths for either image files or other files (which will be audio files). def upload_to(instance, filename): # Check for image or sound file and put in appropriate directory if isinstance(instance, …

Total answers: 1

Django 1.11 – How to use height_field and width_field with ImageField

Django 1.11 – How to use height_field and width_field with ImageField Question: I’ve the defined the following model which it’s used in my Django application for storing the images with different dimensions. class Image(models.Model): def _img_path(instance, filename): # file will be uploaded to MEDIA_ROOT/<instance.path>/<filename> return ‘{0}/{1}’.format(instance.path, filename) id = models.AutoField(primary_key=True) path = models.CharField(max_length=500) img = …

Total answers: 1

django.db.utils.IntegrityError: NOT NULL constraint failed: products_product.image ERROR WITH IMAGE FIELD

django.db.utils.IntegrityError: NOT NULL constraint failed: products_product.image ERROR WITH IMAGE FIELD Question: I wanna add ImageField to my Product model and upload it to my media_cdn directory but when I migrate my base to my model.py it returns the below error: django.db.utils.IntegrityError: NOT NULL constraint failed: products_product.image ERROR WITH IMAGE FIELD The exact output from cmd …

Total answers: 13