django-1.11

How to send file to response in Django?

How to send file to response in Django? Question: I have such php function which I try to rewrite in my Django project. What should be an analogue in python for php methods like header() and show_error()? Also how to send file to response? php: function waprfile($date=false) { if(!isset($date) || $date==false) $date = date(“d.m.y”); $timestmp …

Total answers: 3

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

Database indexes in Django 1.11: difference between db_true, indexes and index_together

Database indexes in Django 1.11: difference between db_true, indexes and index_together Question: Django 1.11 offers new ways to create database indexes. So far we had db_index=True in each field: # example 1 class Person(models.Model): name = models.CharField(db_index=True) age = models.IntegerField(db_index=True) Now we have models.Index and the possibility of declaring indexes within the class Meta block …

Total answers: 2