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
-
4
votes1
answer2809
viewsPOST via Ajax with Django
Based on https://godjango.com/18-basic-ajax/ I am trying to make a post via Ajax using Django. Then I created a project on Github https://github.com/rg3915/front-dj-test #urls.py…
-
4
votes1
answer626
viewsTotal and subtotal in Django template using predefined lists
How do I calculate subtotal and total per column? py views. 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 =…
-
4
votes2
answers2633
viewsWhat is the difference between the MVC architecture and Django’s MTV?
I wonder if there is any difference in practice between these two architectures.
-
4
votes1
answer1158
viewsDropdown dependent on each other
I’m using a function taken from this site: https://github.com/nodet07/Django-Related-DropDowns The function works perfectly, when I select an option in a dropdown, in the 2nd Dropdown already brings…
-
4
votes2
answers1159
viewsHow to make a "LIKE" in a DJANGO ORM query?
To make a query to get the data accurately in Django, I use the filter, thus: usuarios = Usuarios.objects.filter(nome='Jonh') This will generate an SQL similar to: SELECT * FROM usuarios wHERE nome…
-
4
votes2
answers2185
viewsHow popular select from another select using python and Django?
Good evening, everyone! I’m new to the forum and started doing a little project with python and Django, where I am trying to fill a select according to the option selected in another. However, as a…
-
4
votes3
answers858
viewsHow to make a Union of two queries using Django Filter
I was racking my brain to do union of two darlings using Django Filter and I ended up doing it on hand (Model.objects.raw("SELECT....")). How could I union with Django’s ORM? Note: I have 2…
-
4
votes1
answer199
viewsHow to save a Filefield template using a preexisting file?
I am importing a set of preexisting files to Django, and would like to refer them to my templates (which they use FileField or ImageField). For example, one of my models is like this: class…
-
4
votes2
answers987
viewsHow to use one Model Class values in another in Django?
Talk guys, I haven’t found a north or how to research on, so I’m going to go to the O.R.. I have the following in my models.py, Ingredient and Product: class Ingrediente(models.Model): produtor =…
-
4
votes1
answer888
viewsRegister different types of users in Django admin
I have three types of users: Manager, Teacher and Student. All of them need to log into the system, but the teacher and student have some more information. The manager who creates access for the…
-
3
votes1
answer173
viewsHow to organize my models in the construction of a photo album in Django?
I’m building a photo album, but I don’t know how I should organize it. How my models should be? Class Foto(models.Model): foto = models.ImageField(upload_to='img') Class Album(models.Model): nome =…
-
3
votes1
answer802
viewsHow to link the Forms created in Django to the forms already created in the HTML template?
I started to see about forms in Django, only I had already created in templates of my project the forms with all inputs necessary. With the creation of forms in Django there is a way for me to link…
-
3
votes2
answers2033
viewsReturning ZIP Code data in form
I have the following problem: I am trying to fill in the fields street, city and state with the post informed. They’re all input. I’m using https://github.com/jbochi/cep My project is in Django, but…
-
3
votes1
answer694
viewsHow to build a url in Django?
I am learning Django, but one thing I have not understood so far is, how to build a url, I know it uses regular expression, but someone there has how to explain to me, or indicate me a material that…
-
3
votes1
answer495
viewsDjango - How to treat Exception returned when I try to access a view protected by Developer @login_required?
When Exception occurs I want to redirect to a denied access template! The project in Github py views. # -*- coding: utf-8 -*- ## --------------------------- IMPORTS from django.shortcuts import…
-
3
votes1
answer146
viewsDjango - How does Developer @login_required work in views from another app?
I have a project in Django and only an application where I do registration, searches, login to the system, etc. I was reading an article about the creation of projects and saw that for the sake of…
-
3
votes1
answer778
viewsDjango - How to distinguish which button was clicked?
In my application’s search template I have 3 tags <button>, one to search, the other to edit and the other to delete: <button class="btn btn-lg btn-primary" type="submit" id="buscar"…
-
3
votes1
answer156
viewsReplace text Beautifulsoup
I have the following html: <p>Um acidente no cruzamento da rua ... </p> <div id="marca"></div> <p>Um acidente no cruzamento ......</p> <div…
-
3
votes2
answers833
viewsHow do I know if request.FILES is empty?
I have a code on Django where I want to upload a file from a form. At a given precise moment check if the index exists "arquivo" within the variable request.FILES I did it using the method has_key…
-
3
votes3
answers1207
viewsWhat’s the difference when calling a function with parentheses and without in.py urls with Django 1.7?
In mapping my.py urls I use from common functions to class-based views. I want to know the difference between calling the view with or without parentheses, given that if I have the input url(r'^$',…
-
3
votes2
answers1428
viewsSend objects to a base.html Django template
My situation is this, I have a file base.html where more than one page extend in it. My question is, how do I send two objects to this file, so that these objects are shown in all other views, which…
-
3
votes1
answer535
viewsSingle CPF but with Blank=True
If I define cpf = models.CharField(max_length=11, unique=True, null=True, blank=True) It turns out that if I leave a record with the null value, when I try to save a second record, it accuses…
djangoasked 9 years, 3 months ago Regis Santos 1,574 -
3
votes1
answer916
viewsUnderstanding the Django 1.7 permissions system
I have an app called forms_and_models which I use for study. In documentation of Django 1.7 says that: Assuming you have an application whose app_label is foo and a model called Bar, to test basic…
-
3
votes2
answers2875
viewsHow to allow a Decimalfield with the BR currency format in Django?
I have the following class: class Carro(models.Model): valor = models.DecimalField(max_digits=8, decimal_places=2, default=0) And its respective form: class CarroForm(forms.ModelForm): class Meta():…
-
3
votes2
answers1020
viewsDoes Netbeans support Django?
I installed the Netbeans and the plugins for python. Everything worked out, but I found what did not happen.This plugin alone would already support Django. I saw on this blog the author saying that…
-
3
votes0
answers70
viewsWhich python web service to use in an application using knockoutjs?
I need to create a python web service for my Django application. My application was built using Django and knockoutjs, but I don’t use models or Forms, knockout ko.observable. I thought about using…
-
3
votes3
answers1652
viewsHow to start a Django project using virtualenv?
I have searched and found several different ways and conventions to create a project in Django using virtual environment (virtualenv). Is there a pattern to this? Someone helps me with a correct…
-
3
votes1
answer616
viewsQueryset on Django without case-sensitive
I have a question about Querysets in Django. I need to search a field that’s a Charfield, only the research I’m doing appears to be case sensitive. And I wanted that when searching for 'Stack' the…
-
3
votes2
answers841
viewsBlock source code Django
I am developing some projects where I will use Django, but I will have to host the server on the client’s machine. Where it will be installed there is no internet, so I have to make the system work…
-
3
votes1
answer1820
viewsHow to make a Join with Django?
I’m trying to run this SQL, using Django’s ORM SELECT * FROM test JOIN questionnaire q ON (q.id = test.questionnaire) WHERE q.discipline = 4; Models: Test, Questionnaire, Discipline…
-
3
votes1
answer353
viewsHow to count people by age
I have class Person(TimeStampedModel, Address): name = models.CharField(_('nome'), max_length=100) birthday = models.DateField(_('data de nascimento')) and the function import datetime from datetime…
-
3
votes2
answers1004
viewsWhat is the difference between Forms. Form and Forms.Modelform?
Hello, dear people. With the help of a tutorial, I was able to create a template with form and use Forms.Modelform to save in the database, but I saw in the Django documentation that there is also…
-
3
votes1
answer121
viewsEdit widgets Django
Hello! I’m developing a Django app. On the project registration page appears a Selectmultiple pro user select the participating teachers. But on the details page I just wanted to appear the names of…
-
3
votes1
answer1765
viewsDjango validate Cpf and treat error
I’m using Brcpffield from the localflavors package to validate the CPF in a form, it’s working, the problem is that in the template when I type in an invalid CPF that Django error page appears, I…
-
3
votes1
answer1642
viewsImport: cannot import name Patterns on Django
The application on Django was working normally until I went to put Django-comments, first I installed it with the setup.py that came along, I believe that is what is causing the problem, then I put…
-
3
votes1
answer276
viewsTotal with plurality in Django template
Guys I have the following code: <div> <h4>{{ combination|length }} combinação{{ combination|length|pluralize }}</h4> <h5><b>Total:</b> {{…
-
3
votes2
answers147
viewsFilter with first item of a Manytomany Django
I have it in my template: {% for j in jobs %} <tbody> {% if j.background.all.0.active == False %} ... Hence I need to filter the view similar to this. I tried to jobs =…
djangoasked 8 years, 3 months ago Regis Santos 1,574 -
3
votes1
answer1636
viewsDjango - Getting form information
I have a template called listaarquivos.html where a table with information of an object of the models.py called JOB. However, now I need to filter this table by date. I then inserted two inputs in…
-
3
votes1
answer1550
viewsList date filter (Django)
Imagine I have a list and a form to filter this list by date. Does anyone have any example of how to make this filter in the form? I got this here in the shell, but I don’t know how to implement in…
-
3
votes2
answers403
viewsTDD in existing function (Django)
I need to learn more about TDD. What a test it should be to pass? The function already works, just wanted to know what would be a test? @login_required def create_contract(request, proposal_id): if…
-
3
votes1
answer3129
viewsUninstall the Django
I tried to install the Django in Lubuntu, but I made a mistake. I want to first uninstall and then install in the correct way. So there are two questions: How to properly uninstall the Django…
-
3
votes1
answer533
viewsSetting matrix table in Django
I have two tables, in the example (any) of the figure below i have the table Paises and the table Energia Setting a third table in Django I would have something with the fields pais, energia, valor…
-
3
votes1
answer155
viewsReturning the minimum value for comparison in Django template
Following a reply on /a/96503/761 def quotation_list(request): stores = list(Store.objects.all()) products = list(Product.objects.all()) # indice index_store = {store.id: index for index, store in…
-
3
votes2
answers1210
viewsPython Shell and Django
I know that to open the interactive Python shell, we simply run on the operating system terminal: python But with Django installed, you can also open the shell using the command: python manage.py…
-
3
votes1
answer842
views__str__ and __unicode__methods
I’ve seen class codes that implement Django models overwriting both the method __str__ like the __unicode__, there is difference between them? If yes, there is some case that I should prefer one…
-
3
votes1
answer169
viewsHow to change the width of columns in the Admin listing in Django?
How do I specify the width for the columns that are displayed in the Admin listing, more precisely the ones I specify in list_display in admin.py. Researching I found similar question here, where I…
django python-3.x python-2.7 django-templates django-1.8asked 8 years, 10 months ago Marcio Luís 1,061 -
3
votes1
answer49
viewsError running tests with proxy models in Django
I have a table Seller. https://github.com/rg3915/django-experience/blob/master/djexperience/crm/models.py#L109-L118 class Seller(Employee): objects = SellerManager() class Meta: proxy = True…
-
3
votes1
answer254
viewsWhat is the real use of the pass in this case?
I am working on the adaptation of a Jango project already created. During the analysis of the code I came across the following excerpt: def objects_delete_action(modeladmin, request, queryset): for…
-
3
votes1
answer999
viewsPython, Django with multiple databases
To work with multiple databases in the Laravel framework, once configured all the connections in the configuration files, just define in the model which connection to the database that model will…
-
3
votes3
answers102
viewsValueobjects Django
Good morning guys, I’m starting now with Python and Django and I came up with a question in the creation of my models. I’d like to create something like: Person(models. Model) Name ... Address…