Most voted "django" questions
Django is an open source Web 2.0 application framework written in Python. Its main objective is to facilitate the creation of complex database websites.
Learn more…1,067 questions
Sort by count of
-
24
votes2
answers517
viewsFielderror: Relation Fields do not support nested lookups
I’m trying to make a query in Django with several joins, and I came across this mistake that I don’t know what it means: Tag.objects.filter(dset__descendant__entities__entity=e) Fielderror: Relation…
-
12
votes3
answers278
viewsHow to prevent Django from finding Ids in the template?
I’m using Django 1.4 with path (L10N) enabled, which causes the numeric values in the template to be formatted: 1.234,56. The problem is that every time I put one ID in the template, for example:…
-
12
votes3
answers611
viewsHow to ensure that a service is always running on Centos?
I created a startup script for my application in Centos, so I can use the commands below to initialize/stop the application: service django_app start service django_app stop How do I ensure this…
-
12
votes6
answers16210
viewsHow do I return a value in the Brazilian currency format in the Django view?
How to return the value 1768 in BRL currency format 1.768,00 in the Django view? def moeda(request): valor = 1768 # formata o valor return HttpResponse('Valor: %s' % valor)…
-
8
votes1
answer2502
viewsWhat are the differences between Flask and Django?
I recently started in the Python language and am currently working on a project using Flask, MariaDB and WebSockets. I see people talk a lot about Django and would like to know the differences…
-
8
votes3
answers429
viewsHow to use Form in Listview Django?
I am trying to create an action for a Listview, the action would be Delete or change a parameter in the table, for example disable user, using checkbox. If I select all and click on this button the…
-
8
votes2
answers196
viewsWhy do I need to use an application server with Django?
Why it is necessary and what is the advantage of using an application server, such as Gunicorn, in a production environment? It would be possible to use only Django talking directly to the server,…
-
7
votes1
answer315
viewsDjango 'bool' Object has no attribute '_Committed'
I have a field of sorts FileField and when I try to delete the contents of it, returns me this error message: bool' Object has no attribute '_Committed' To make the upload works normally, the…
-
7
votes1
answer161
viewsIs it a good idea to map Urls that delete GET entries?
I’m studying Django and wondered if it’s really good practice to set up removals URL via GET, for example: http://meusite.com.br/usuario/deletar?id=10. Is this really good practice? Since some HTTP…
-
7
votes2
answers666
viewsCheck file extension in template - Django
I have a Django application where in the template I need to validate a file extension coming from filefield. <div class="row"> <p class="anexos"> {% trans 'Anexos' %} </p> #if .jpg…
-
7
votes1
answer2048
viewsSimple form by Django
If I have in mine model a class usuario, a phones and a class manager, who are one to one, so: class Usuario(models.Model): login = models.CharField(max_length=50, unique=True) senha =…
-
7
votes2
answers521
viewsHow to serve files with access control in Django?
When studying Django, the typical way to handle uploading files was to create a folder media on the server - establishing a MEDIA_ROOT and a MEDIA_URL in the settings.py - where any uploaded file…
-
7
votes2
answers1186
viewsProblem connecting Mysql in Python 3.4
I just installed my virtual environment, installed Pymysql and created a project, however, when trying to start an APP python manage.py startapp nome, the following problem arose: Error loading…
-
7
votes2
answers772
viewsDjango and Template
Good night! Guys, I’ve been in trouble for four days and unfortunately I haven’t been able to fix it yet! I’m working with tamplates in Django, but I’m having problems, because nothing appears in…
-
7
votes1
answer364
viewsProblems with CORS in Django using AWS S3
My application uses a Bucket on AWS to host the static and MEDIA files, here’s the link: http://memoriasclubeturismoenv.us-east-2.elasticbeanstalk.com/gilson-rolim-02-12-2019 or…
-
6
votes2
answers1434
viewsWhat are the best practices for working with Legacy Database in Django?
I have a legacy database and would like to know what good practices for table names, or tips on how to use inflections (like in Rails) for Django in the latest version.
-
6
votes1
answer2008
viewsWhat is the best way to email with HTML in Django?
I’m a beginner in Python and Django and in the project I’m doing for study, I send an email, which has an HTML template. I was able to send an HTML email using EmailMessage: msg =…
-
6
votes2
answers7033
views -
6
votes3
answers450
viewsAnnotate: Returning the cheapest product and supplier name (Django)
Given the table below product;company;price AAAAA;forn1;395.69 BBBBB;forn1;939.45 CCCCC;forn1;480.33 DDDDD;forn1;590.59 EEEEE;forn1;847.69 AAAAA;forn2;227.31 BBBBB;forn2;375.90 CCCCC;forn2;602.18…
-
5
votes1
answer1073
viewsIt is good practice to import modules into __init__.py
I noticed that in Django framework modules are imported into __init__.py for convenience. """ Django validation and HTML form handling. """ from django.forms.forms import * # NOQA That way it: from…
-
5
votes1
answer1327
viewsHow to set date formats in Django 1.7 for the whole system
Is there any way to change the display settings and/or date formatting at system level?
-
5
votes1
answer376
viewsIn Django why does the is_authenticated method always return True?
I saw that the documentation indicates the method is_authenticated as being responsible for telling templates if there is a logged-in user. I also saw in the method code that it contains only the…
-
5
votes2
answers707
viewsMysql to Python 3 connector
I’m doing a project with Django and Python 3 but I can’t find the appropriate Mysql connector. The django.db.backends.mysql works, but only for Python 2, and I wanted to avoid using this version. On…
-
5
votes2
answers804
viewsHow do you calculate (easily) total and subtotal in Django?
I’m wearing Django 1.7.8 I have the models.py class SaleDetail(models.Model): quantity = models.PositiveSmallIntegerField(_('quantidade')) price_sale = models.DecimalField( def get_subtotal(self):…
djangoasked 9 years, 5 months ago Regis Santos 1,574 -
5
votes1
answer225
viewsCannot assign "'Maria'": "Student.name_mae" must be a "Student" instance. When I try to access a student subclass field
I have a system with multiple users, I decided to make inheritance of Django’s default user, I have two users: student and teacher, which has several characteristics in common, so I created a base…
-
5
votes1
answer181
viewsPython ORM similar to Django
I studied the framework for a long time Django and I thought the ORM of the same was excellent. I had the idea, at some point, to build an application with another framework called Flask, using a…
-
5
votes1
answer21967
viewsWhat is . in <form action="." method="post">?
I’m starting in Django and making some changes in code already written by someone. I realized that in form instead of the usual "/action page" to which the data will be submitted, such as in this…
-
5
votes1
answer118
viewsFilter using calculated value does not work in Django
I have a model in Django with fields largura and comprimento, and would like to filter it by area: class Projeto(models.Model): largura = models.DecimalField(decimal_places=0, max_digits=4,…
-
5
votes1
answer139
viewsDjango generating strange code
I am using the visual studio community and created a web project with Django, but when making the homepage, is generating me this code: And the code I have is this: {% load staticfiles %}…
-
5
votes1
answer821
viewsHow does Django create and verify tokens to reset password?
Considering a model to reset password already implemented by Django, in the following views: Django.contrib.auth.password_reset Django.contrib.auth.password_reset_done…
-
5
votes1
answer190
viewsWhat 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 the email already exists (even if registering different types of email).…
-
5
votes1
answer216
viewsAmazon Elastic Beanstalk + Django + Sentry returning Raven.exceptions.Invalidgitrepository
I’m trying to deploy to AWS Elastic Beanstalk. My project has a structure where Django’s Settings is in the Settings folder: |projeto |--settings |----settings.py It contains the configuration as:…
-
5
votes1
answer178
viewsWhat is Lazy, Laziness in Python/Django?
I’m starting to program and reading the documentation from Django, I saw some references about lazyObject, about Django being Lazy and that Querysets sane Lazy. I’ve done some research but I haven’t…
-
5
votes2
answers2562
viewsStatic files on Django
Whoa, guys, I’m having trouble uploading static files. Static folder is in the core application, also tested with it at the root of the project and also did not take I made a test index file: {%…
-
5
votes1
answer6199
viewsHow to use Objects.filter in Django?
Good afternoon, I have a model here in my Django Subject, and I want to list it in html, but every subject has as a foreign key the model id category, how I make a variable to receive Objects.filter…
-
4
votes1
answer207
viewsCalls Many to Many in template
I would like to know how to make a template call to a field Many to Many of the models. Follows code: Models class Projeto(models.Model): professor_participante = models.ManyToManyField(Servidor,…
djangoasked 10 years, 7 months ago user2701678 41 -
4
votes2
answers666
viewsView in Django does not return Httpresponse object
I am doing a simple CRUD in Django for learning purposes. However, I am having a problem. When creating a view to add data to a schedule, the server returns the following error: The view…
-
4
votes1
answer3300
viewsStatic 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 consumes a lot of resource. How to implement this? It would be the same…
-
4
votes2
answers1011
viewsProblems with saving data in form-model Django
Gentlemen, good afternoon to you! I’m facing a small problem, I made some changes in an application I’m developing for studies. I come across the following, fill the form all right and when I go to…
-
4
votes0
answers462
viewsDjango Session timer Countdown
I have it on my login screen: SESSION_COOKIE_AGE = 1200 # 20 minutos and would like to show the remaining time on my template. Someone knows a good middleware or package for Django that adds a time…
-
4
votes1
answer1309
viewsDjango - Editing tables (Update)
In my application I have a function to search a person by name and edit data of a registered person... When I search and there is more than one person registered with that name (or even when there…
-
4
votes1
answer907
viewsWhat is the best way to fragment a Django project into apps?
I’m doing a study project to apply what I’ve learned so far with Django. My question is: what is the best way to segment the project in apps? If you want to give an example so that something…
-
4
votes1
answer130
viewsHow to resolve the conflict between Angularjs and Django?
What is the most efficient way to solve the conflict problem between Django and Angularjs when using {{ }} in the templates?
-
4
votes1
answer606
viewsSingle email field on Django User model
I have a system that has a user register and I’m using the lib django.contrib.auth.models to make this registration. However I I need this model’s email field to be unique. from django.db import…
-
4
votes1
answer470
viewsHow to sort a query in Django by ignoring accents?
I’m returning the query Carro.objects.all().order_by(Lower('marca')), but the order is not respecting names that begin with accent, causing these results to appear at the end of the ordination. Is…
-
4
votes2
answers1301
viewsHow to format datetime in YYYY-MM-Ddthh:mm:ss.sTZD format in Django/Python?
I’m having a hard time in Django returning the datetime in the local Timezone. No Django configurei USE_TZ=True and TIME_ZONE = 'America/Sao_Paulo' By calling timezone.now(), returns the datetime…
-
4
votes1
answer273
viewsDjango: What’s the difference between importing/using include() and not using 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…
-
4
votes2
answers1225
viewsHow to read and render a.txt file in the Django template?
How do I render the data of a arquivo.txt in a Django template? contents of the archive: 1;'one';'foo' 2;'two';'bar' I return in the template 1 - one - foo 2 - two - bar Any hint where I start?…
-
4
votes2
answers138
viewsDoubt with Python+Django
I’m starting with Python and Django, following a tutorial I found: https://docs.djangoproject.com/en/1.9/intro/tutorial01/ When I execute the command django-admin With startproject, it doesn’t…
-
4
votes2
answers577
viewsInstance in Django model with problem
I’m working on a multi-app project. The department app model is as follows:: from emails.models import GerenciarEmails class Departamento(models.Model): #modelo de grupos de disciplinas class Meta:…