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
-
1
votes1
answer152
viewsReturn more than one Django data list
I made a homepage using Jango, I am loading my slides and menus dynamically and it was perfect. I put both the menu and the footer through include and it worked 100%. Now I came across a problem,…
-
1
votes2
answers114
viewsError creating a simple Django table?
class Produtos(models.Model): #id = models.AutoField(primary_key=True) nomeproduto = models.CharField(max_length=50, blank=True, null=True) quantproduto = models.CharField(max_length=30,…
-
1
votes1
answer104
views"Arraylist" in Django
I am developing an application for reporting optical fiber certifications, and such reports are produced by importing XML and TXT files. The question is as follows: A certification is made within a…
-
1
votes1
answer935
viewspylint E1101:Class 'User' has no 'Objects' Member
I am using vscode together with Djangorestframework and it is error in the following line: res = User.objects.filter(user_nome=value) However the code runs correctly, the error that the editor shows…
-
1
votes2
answers406
viewsPython calling super() in class that does not implement inheritance
I’m developing some middleware and as I delved into Django’s source code I came across the following: class MiddlewareMixin: def __init__(self, get_response=None): self.get_response = get_response…
-
1
votes1
answer24
viewsCapture a value using Select with Django
Good morning. I created a form and inserted the names of my clients in a select. When selecting one of them you would like to real Select a filter, but it is not working, it seems that the value of…
djangoasked 6 years, 2 months ago Vinicius Correa 11 -
1
votes0
answers84
viewsTemplate image does not upload
Hello, I’m developing an app that needs the user to upload their profile image, but the 'upload_to' mechanism of the Customuser ft field apparently isn’t working. The image simply does not go to the…
-
1
votes1
answer1396
viewsSort list with Python + Django
Good afternoon guys, I have a problem, register by the Django admin a video that should be sent to my template, however I need these videos to be ordered by the field position that I have in my…
-
1
votes2
answers1576
viewsUse {%for %} and {%if %} in Django template
I have 3 videos saved in the Postgres bank where I seventh a star_date and the video only appears on template when the start_date <= date.today() My problem is in template. I have 3 buttons, one…
-
1
votes1
answer216
viewsNotification system
I have the following model: from django.db import models from django.utils.timezone import now # Create your models here. class Event(models.Model): name = models.CharField('nombre',max_length =…
-
1
votes0
answers43
views'Useradmincreatinform' Object has no attribute 'get' Django
I was trying to send data from a user to the database and received the following error. from django import forms from django.contrib.auth.forms import UserCreationForm #from django.contrib.auth…
-
1
votes0
answers54
viewsProblem when making a GET on my site when it is entered via www (React + Django)
I have a Jango application that uses React on one of your pages (not two separate Servers). On my React pages, I make HTTP requests to Django for the api using Django Rest Framework. This…
django react http-request https django-rest-frameworkasked 6 years, 1 month ago Gabriel Cavalcanti 47 -
1
votes1
answer279
viewsERROR - DJANGO 2.0.9 - Typeerror: create_superuser() Missing 1 required positional argument: 'email'
You can help me with this problem, I’m new to Django: So, I’m taking an Internet course to create a distance learning platform to learn about Django. I am using the version Django 2.0.9, I have a…
-
1
votes1
answer124
viewsRabbitmq running on an external server
I have a Django web application that uses Celery for asynchronous tasks and Rabbitmq for Broker management. When both are running on the same machine, tasks are performed smoothly, but the…
-
1
votes2
answers661
viewsGet Python logged in user ID
I have a project in Python and Django. Where I have a REGISTRATION class, and in this table I would like to record in the column "Person" the ID of the user logged in the application, in the column…
-
1
votes0
answers2358
viewsDjango - CPF or CNPJ
Good afternoon Personal. As a way of learning I am creating a system in Django with Client Registration. Could someone help me in logic so that in the register I can choose CPF or CNPJ. My Models…
-
1
votes1
answer133
viewsAPÍ Django-storages Dropbox url error Pattern
I am using the following API: https://django-storages.readthedocs.io/en/latest/backends/dropbox.html I have exactly everything configured, from the lib installed to the settings of Settings.py. A…
-
1
votes0
answers162
viewsDjango project deploy on Heroku with errors
When trying to deploy my Python project using Django on Heroku, I am getting the following error. Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2),…
-
1
votes1
answer38
viewsReturn only the file name in the view
How do I display only the file name, example RET_PREF_ANAPOLIS..., removing the path arquivos/? py.models: def user_directory_path(instance, filename): if instance.tipo_arquivo.id == 1: tipo = 'RET'…
-
1
votes0
answers57
viewsDjango error - 'agenda' is not a Registered namespace
py apps. from __future__ import unicode_literals from django.apps import AppConfig class AgendaConfig(AppConfig): name = 'agenda' py. from django.conf.urls import url from . import views from…
-
1
votes1
answer283
viewsHow to add values after filtered in Django?
Here’s my loop (in my.html template): {% for item in filter.qs %} <tr> <th scope="row">{{ item.id }}</th> <td>{{ item.nome }}</td> <td>{{ item.data|date:"d, F"…
-
1
votes0
answers123
viewsInput HTML and Django Request.POST array
I’m trying to do a POST with Formdata for a view and I’m not getting the input array. Follow the example: HTML <input name="bonus" type="number" placeholder="ex.: 100.000,00"> {% for x in…
-
1
votes1
answer47
viewsInvalid block tag
I’m new in Django and I’m having a problem with the tags Template My code: {% load static %} {% block content %} <div> {{ questao.afirmativa }} </div> {% alternativas =…
-
1
votes1
answer133
viewsCreate dialog in Django
I am trying to create a dialog to remove a client in Django (I created the dialog with Materialize), but when trying to remove it does not execute the view function inside the html page. Could…
-
1
votes1
answer34
viewsDjango form for single key
Good afternoon, everyone. I have a model in Django with a field - phone - which is a unique key: phone = models.CharField(max_length=11, unique=True) I’m trying to generate a form in which the user…
-
1
votes1
answer98
viewsShow value, not form ID
I’m making a system using Python and Django. At one point, I’m showing a table with database information. Follow my html: <tbody> {% for oportunidade in all_oportunidades %} <tr…
-
1
votes1
answer36
viewsHow to leave Choices field with no default value
I currently have this class with a field Choice, tried to leave by default "deufault=None" can it remains bringing the field filled with Royal Flush, if I move to another existing City he accepts,…
-
1
votes1
answer671
viewsHow to create a user with Abstractbaseuser or Abstractuser. (Login errors)
I’m trying to use my class Pessoa as a user in models.py. Meanwhile I tried to use AbstractUser and AbstractBaseUser. Both return me errors in the part where I try to log in, I tried several ways…
-
1
votes1
answer48
viewsSaving relationships using the Django Rest Framework
When I try to save a new student informs the error NOT NULL Constraint failed: student_student.teacher_id Can someone help me? class Teacher(models.Model): name = models.CharField(max_length=128)…
-
1
votes0
answers110
viewsDoubt with API in Django and Python
I am developing an application with customer registrations, and my class View to register a client was like this: class AdicionarClienteView(CustomCreateView): form_class = OportunidadeForm…
-
1
votes1
answer523
viewsReturn to a page with completed form
I’m using Django and I have to implement the following flow: The user fills in the information of a new exam, clicks on attach an old exam, goes to the exam search screen, selects the desired exam…
-
1
votes1
answer355
viewsgenerate a pdf only with arguments passed by a Django form
Hello, I’m having a problem generating a pdf, I need to create filters for a more detailed report, my code consists of a simple view of Template where I set up the form with the "GET" method, and a…
-
1
votes1
answer515
viewsHow to assign the PK of the logged-in user in Django to an FK in the model?
Hello, what I am trying to do is basically the following, I have in my application a Model called 'Shopping', and one of the fields of this Model is the user who registered the purchase, I want each…
-
1
votes1
answer1442
viewsPick a select value in Django
The HTML code: <!doctype html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0,…
-
1
votes2
answers85
viewsLink tag on Html5 in the wrong place on bootstrap
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"…
-
1
votes1
answer593
viewsPass view arguments to Django form
Hello, good night! I’m doing a question and answer application on Jango and I have basically these models: Multiple choice app: class MCQuestao(Questao): def checar_correta(self, ans): answer =…
-
1
votes3
answers627
viewspass list of one method to another in python
I have two functions, I need the list of the first to be read by the second, the two are in a view of Django, that each generates a different template. class Tranfer: shared = [] #Essa proprieda…
-
1
votes1
answer297
viewsSave a file using a view function on Django
I have this following HTML, which is a form with an input for a file and Submit button: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document…
-
1
votes2
answers978
viewsHow to return a json to the same Django template?
I am trying to return a json to the same template without rendering it again (as in the case of render(request, 'dir/base.html, Response))) using Jsonresponse, but it is giving this error: Object of…
-
1
votes0
answers124
viewsHow do I access a POST endpoint from a Django view?
I need to provide a service that requests a Django view method using lib requests. The method is as follows:: def classify(request): print(request) if request.method == "POST": form =…
-
1
votes1
answer51
viewsI cannot delete the correct image by passing id through jQuery via Modal
I have a system that you click on the image and it opens it larger via modal, below has a Delete button, if you click Delete, opens another modal asking if you are sure you want to delete this…
-
1
votes1
answer593
viewsFormatting Django decimal number template
I’m having trouble displaying the results of a calculation. I have a Decimalfield and want to return it formatted this way: 1.000.000,00 If I order to display normally without tags, it looks like…
-
1
votes1
answer618
viewsHow to assign a css class in Django forms
Talk to the guys, all right? So today’s fat is the following, I want to add by default a css in my forms generated in Django, I searched some things but nothing solved my "problem". I was wondering…
-
1
votes1
answer106
viewsPlace the fields of a Django form on the same line
I have a form in Django and in the template I display the fields to be filled: <div id="interval" class="form-inline form-group"> <div class="two wide field"> {% for price in prices %}…
-
1
votes4
answers92
viewsField match, referenced in previous field
I started learning about Python from Jango and am trying to develop a simple vehicle management system. I am beating head to perform the following procedure: as soon as the registration plate is…
-
1
votes1
answer294
viewsGenerate PDF in Django admin
How do I get a PDF in the Django admin? I already have the views, I can generate in the frontend with HTML all right, but how do I put a button in the admin to generate or redirect to the pdf link?…
-
1
votes2
answers169
viewsLogin redirect Django does not work
I am trying to make a redirect of users based on functions, example: an admin after the login is sent to the admin, the attendant or common employee, be sent to a home, but the code placed does not…
-
1
votes1
answer806
viewsError including app urls in project.py urls
I’m at the beginning of a project with Django 2.2.1, creating the first apps and making the links between the pages. In the project’s urls.py, including the Accounts urls worked (with the…
-
1
votes1
answer444
viewsI wonder if it is possible to join two tables in the Django Framework
Hello friends, I’m having a slight difficulty in how to generate a third Model within Django, currently I have two tables Training and Entity would like to know if it would be possible to create…
-
1
votes0
answers26
viewsTimestamp in Django (Reference)
I need this: strtotime('+10 days'); = PHP in Django I tried: import time struct_time = time.strptime("+10 days") print "returned tuple: %s " % struct_time Well, in all the documentation it doesn’t…