Questions tagged as 'django-models'

1
answer

get the sum of an attribute django models

Good morning: I have a model Order and I need general a summary of all the orders that have been generated in the last 15 days, then I want to generate the total of all the orders and I do not know how to do it. for the moment I have this: ped...
asked by 18.01.2018 / 09:48
1
answer

Create an own User Model and authenticate the entry

Good morning, create my own user model in Django and the idea is to use it to validate the login to the system without using the model.user that Django has by default. How can I do so that users can login to my system?     
asked by 13.01.2017 / 15:33
1
answer

Django 1.10, make an update every time an item is searched

I am trying to make an attribute increment by 1 every time I search for an item in the database. For example: criterio = "Alberto" resultado = Personas.objects.filter(nombre = criterio) for persona in resultado: persona.coincidencias += 1...
asked by 03.01.2017 / 15:22
2
answers

Can not assign "'1'": "Customer.type_client" must be to "Customer_type" instance

I am trying to save the form I made in django which has a foreignkey from the client model to the client type model but at the time of saving this error comes out.    Can not assign "'1'": "Customer.type_client" must be to "Customer_type"   i...
asked by 30.10.2016 / 19:39
1
answer

TypeError: string indices must be integers - Saving data from a JSON to the database

I have the following situation: The model RehabilitationSession in addition to other data these fields of interest: class RehabilitationSession(models.Model): ... minimum = models.DecimalField( max_digits=5,d...
asked by 17.11.2016 / 03:13
1
answer

AttributeError (The 'NoneType' object has no 'name' attribute)

Here I have 2 tables the first one is for products and the 2nd one is for price, in the price table I call the product name but I get an error, please help models.py class Producto(models.Model): """Productos a la venta""" nombre...
asked by 20.11.2018 / 23:48
2
answers

Check in Django a model using ORM?

class Curso(models.Model): fecha = models.DateField() hora_inicio = models.TimeField() hora_fin = models.TimeField() capacidad_maxima = models.PositiveSmallIntegerField(default=6) sede = models.ForeignKey(Sede) profesor =...
asked by 09.03.2016 / 22:53
1
answer

Save file to directory, from the view - Django

I have an application with which I upload files, and subsequently those files are consulted; the files have the following nomenclature: EXAMPLE_7777_AAAA.pdf If the file belongs to group 7777, the file is saved in the path: upload_to = 'Files...
asked by 14.08.2018 / 21:08
1
answer

How to process CSV files with Django, after being imported? [closed]

I need an explanation or orientation of the steps of how to process a csv file, to import it with the FileField field of the Django models but I need the information of the CSV to replicate in the databases. I appreciate your collaboration.    ...
asked by 01.08.2018 / 06:42
1
answer

Query with dates using a range

I have the following query: query=Detalles.objects.filter(fecha_creacion__range=(fecha_inicio,fecha_final)) The expected result is to filter the results between date A and date B, that is: fechaA= 01-07-2018 FechaB=04-07-2018 However,...
asked by 04.07.2018 / 22:40