Questions tagged as 'django'

2
answers

MultipleObjectsReturned Django

I want to return the 2 or n records matches that appear but shows me the following exception    Exception Value:       get () returned more than one File - it returned 2! The Query that returns the exception queryModeloArchivo= Archivo...
asked by 27.03.2018 / 19:46
3
answers

I can not connect mysql to my Django project

In my settings.py file I put the following: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'djangoproject', 'USER': 'root', 'PASSWORD': '', 'HOST': 'localhost', 'POR...
asked by 09.04.2018 / 03:57
2
answers

.py file does not exist in django's cmd (Windows), how do I add it?

I just installed what bitnami 2.0.4 is in its latest version and I have a problem wanting to create a new project, by doing the command django-admin.py startproject myproyect At first I got an error that the django-admin file did not exist...
asked by 08.04.2018 / 03:01
1
answer

Modify template name Django

I am generating a view to search for products and I want to modify it to also search for users when the name starts with '@'. Right now I have this view: class BusquedaView(FilterView): model = Producto filterset_class = BusquedaFil...
asked by 16.03.2018 / 17:16
1
answer

Filter by weekend in a certain range of hours. Django

I am trying to make a query that I return the number of orders that your delivery date is during the weekend between 7 am - 11 am and I have been trying this way: Order.objects.filter(delivery__range=[breakfast_start_date, datetime.now()], sta...
asked by 13.03.2018 / 23:07
1
answer

get elapsed time in django

I am creating a task in Django where I need to take all the orders and check the creation date to see how much time has elapsed, in case 2 days have passed to execute a code and in case 4 have passed, execute a different one. Right now my mod...
asked by 14.03.2018 / 08:48
1
answer

Assign a foreign key from one form to another in django and redirect with reverse_lazy

I have 2 test models, Model1 and Model2. Model2 has the OneToOneField key to Model1, but I can not assign the Model1_id to Model2_id to keep the relationship of the models, I do not know how to access that data from the views.py to assign it in...
asked by 05.03.2018 / 20:33
1
answer

Django forms does not display the form fields when using {% include%}

I have been trying for several days to find the answer to this problem. I have tried with the solutions suggested in the threads that I found in which other users had something similar, but none has worked so far. I created a contact form fol...
asked by 25.02.2018 / 12:18
1
answer

Change attributes of html tags from a template that inherits the content from a base.html file

I have a template base.html of which the rest of my templates expand it by means of the label extends , an example of the code of the file base.html is the following: {% load static %} <!DOCTYPE html> <html> <...
asked by 26.02.2018 / 20:45
1
answer

How to save image in django in a folder whose name is the id of the saved object?

I am working on a system where there are real estate companies, which publish real estate and these have cover photos. I need to save the cover images of the properties in a route similar to this: /media/id_de_inmobiliaria/id_inmueble/portada...
asked by 13.02.2018 / 20:06