Questions tagged as 'django'

1
answer

Django: what's the difference between import / use include () and not use when configuring a URL?

from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^polls/', include('polls.urls')), url(r'^admin/', admin.site.urls), ] In this example I saw that there are two ways to call a URL, one wi...
asked by 30.12.2015 / 16:51
2
answers

How to format datetime in YYYY-MM-DDThh format: mm: ss.sTZD in Django / Python?

I'm having a difficulty in Django in returning the datetime at the local timezone. In Django I set USE_TZ=True and TIME_ZONE = 'America/Sao_Paulo' When calling timezone.now() , return the datetime with time in utc, I do no...
asked by 27.02.2015 / 02:56
1
answer

Static Variable in Python

I came from Java. I have a variable in a class that I need to change in more than one method. I tried to put it global, but it consumed a lot of resources. How to implement this? Would it be the same shape as a static variable in Java?...
asked by 17.04.2014 / 02:29
1
answer

In Django why is the is_authenticated method always returns True?

I saw that in the documentation it indicates the is_authenticated method as being responsible for telling the templates if there is a logged in user. I also saw in the method code that it contains only the following: def is_authenticate...
asked by 19.02.2015 / 01:09
1
answer

How can I use Firebase as a database in a Django application?

I just created a Django project and would like to use Firebase instead of sqlite as a database. I searched in several places but could not find anywhere how to do the integration. Could someone help me?     
asked by 07.12.2017 / 15:11
1
answer

What is wrong with this procedure when saving a form?

I have a registration form and I'm trying to save information on it. When trying to register, it returns a form error saying that the email already exists (even registering different types of e-mail). That is, it is saving before the checks i...
asked by 16.09.2016 / 19:08
2
answers

Problem connecting MySQL in Python 3.4

I just installed my virtual environment, I installed PyMysql and created a project, but when trying to start a python manage.py startapp nome APP, the following problem occurred: Error loading MySQLdb module: No module named 'MySQLdb'...
asked by 29.09.2015 / 04:37
1
answer

Many to many calls in template

I would like to know how to make a call in the template to a many to many field of models. Follow the code below: Models class Projeto(models.Model): professor_participante = models.ManyToManyField(Servidor, verbose_name=u'Professores...
asked by 19.03.2014 / 02:57
1
answer

How to sort a Django query ignoring accents?

I am returning the query Carro.objects.all().order_by(Lower('marca')) , but the order is not respecting names that start with an accent, causing these results to appear at the end of the sort order. Is there a function that can ignore acce...
asked by 04.05.2015 / 21:29
1
answer

Total and subtotal in Django template using predefined lists

How do I calculate the subtotal and the total per column? views.py def soma_tuplas(a, b): return (a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3], a[4]) def quotation_list(request): stores = Store.objects.all() products = Product....
asked by 07.12.2015 / 22:40