Questions tagged as 'django'

1
answer

How to show content in a select that depends on another select?

My question is the following one ... I have a select that is a foreign key, and at the same time it has another foreign key, and what I want to do is select a data of the first select and that the second select changes its content depending on t...
asked by 17.08.2018 / 00:31
2
answers

Update field OneToOneField - Djando rest framework

I have a model called worker class Worker(models.Model): name = models.CharField(max_length=300) code = models.CharField(max_length=100) user = models.OneToOneField(User, null=True, blank=True) def __str__(self): ret...
asked by 14.04.2018 / 18:40
1
answer

Django queryset, calculate subtraction of two numbers

I have the following model: class MyClass(models.model): usuario = models.Charfield(max_length=45) saldo_ini=models.DecimalField(decimal_places=1,max_digits=10, null=True) saldo_fin=models.DecimalField(decimal_places=1,max_digits=1...
asked by 25.07.2017 / 00:10
1
answer

Problems building a dictionary to return a Queryset

When I want to obtain a queryset filtering according to several parameters I use a dictionary, for example: queryset = Actividad.objects.filter(**my_filter) Where my_filter has been constructed in this way: if nombre: my_fi...
asked by 15.02.2018 / 15:10
2
answers

Display images from a database in Django

I have a model that has an image field, at the beginning the image was shown, but after I made a few changes but without changing the code that serves the image now it does not work, I have tried everything but it does not work, this is the code...
asked by 17.10.2017 / 15:53
1
answer

Is the server running on host "localhost" (127.0.0.1) and accepting TCP / IP connections on port 5432?

I have a DJANGO application on a server (digitalocean). Following a tutorial I have put the application in production with gunicorn, nginx, supervisor and postgres. It worked correctly, but then I restarted the server (reboot) and it no longer c...
asked by 20.10.2017 / 00:25
2
answers

Reverse Queryset on Django models

I'm trying to access a model in reverse. To access the Vale model by consulting the model DetailVale is as follows: val= DetalleVale.objects.filter(vale__usuarioVale=usuario).filter(vale__statusFinalizado=1) However I need to consult about...
asked by 06.02.2018 / 22:14
1
answer

RelatedObjectDoesNotExist User has not profile

I'm trying to create a profile model for the general user that Django has by default, but it seems that when creating a user from manage.py I get the error that the title has along with this one: django.db.utils.IntegrityError: NOT NULL...
asked by 25.08.2017 / 00:32
2
answers

Validations in Class Based View ... form_valid or form_invalid

There is something I do not understand when making validations in class-based views ( CreateView , UpdateView , etc), I understand that you can do with the method form_valid and then save it with a simple form.save()...
asked by 05.09.2017 / 14:35
1
answer

Can someone explain to me the differences between HttpResponse and HttpResponseRedirect?

I'm not understanding the differences between HttpResponse and HttpResponseRedirect . Could someone explain to me?     
asked by 07.08.2017 / 01:50