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
-
0
votes1
answer895
viewsUpload photo with model name in Django
I would like help for a task to save images with a custom name and a folder also with the current name, suppose the following Model: class ProdutoA(models.Model): nome_produto_a =…
-
0
votes1
answer205
viewsError accessing localhost:8000/profile
page profiles.html <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="utf-8"> <title>ConnectedIn</title> </head> <body> <h1>Detalhe…
-
0
votes1
answer356
viewsDjango login view only works with users created in createsuperuser
I’ve been racking my brain with this problem for a couple of days. I’m doing a project for college and created a custom user, I can add users normally in my registration template, they are committed…
-
0
votes1
answer1151
viewsHow to create a registration form with Django
I have been studying Django recently, but I came across a problem in creating forms, I tried to go in the official Framework documentation but I could not find the solution. Forms.py from django…
-
0
votes0
answers44
viewsGenerate histogram in Jango
I’m trying to generate a histogram in Django for a project I developed. The code usually generates the histogram without difficulties in the first attempt, however, when I try again, it returns me…
-
0
votes0
answers38
viewsidentation with Highlight.js
I’m having trouble indenting with Highlight.js, the code being generated by marked.js. Has anyone been through it or knows any solution? index.html: <!-- highlight.css --> <link…
-
0
votes1
answer682
viewsLogin 2.0 Django, authentication
I’m trying to make a login page, but I’m having some difficulties. For some reason that I can’t understand, every time I type the user and the password, whether right or not, gives the answer that…
-
0
votes1
answer302
viewsList_display in Django/Python
sXDw.png My Models class is like this class Produto(models.Model): NomeRazao = models.CharField('Nome',max_length=50,unique=False,blank=False) CpfCnpj = models.IntegerField('Quantidade',blank=False)…
-
0
votes1
answer11
viewsContext variable Processors does not work with render_to_string
In some places on my system, I rescan a page with render_to_string, because I want to render only a small content. In these cases I do not receive my variables that I created in context_processors.…
-
0
votes1
answer1126
viewsDjango datetimefield as text
I am creating an application on Jango where I will have a form to create scheduling queries, my model is like this: class Agenda(models.Model): """Criação da agenda de consultas da Clinica"""…
-
0
votes1
answer583
viewsImport CSV into Django database
I have a CSV database and wanted to import to my models from Django, CSV has this structure: NAME,CLUB,LEAGUE,POSITION,RATING,PACE,SHOOTING,PASSING,DRIBBLING,DEFENDING,PHYSICAL,LOADDATE Tore…
-
0
votes1
answer183
viewsExplain template location in Django
I’m using Django for a project, but I came across a question. In my file settings.py I have the following configuration of templates: TEMPLATES = [ { 'BACKEND':…
-
0
votes1
answer147
viewsDjango Rest Framework with Images
Well I’m still studying this framework, I researched a little tried some ways but did not work. Error: 'Unboundlocalerror at /api/servicos/1/ local variable 'Service' referenced before assignment'…
-
0
votes3
answers892
viewsRequired field modification if checkbox is selected in Django
I need to check if a "checkbox" button, called yes_no, was selected in my html page and modify the "name" field to mandatory when this checkbox is triggered. My code is this: In the models.py file:…
-
0
votes1
answer49
viewsI can’t access a url, either fully or by Slug
I’m taking a Django course that uses as a study a simplemooc platform, but I stopped in a class where when trying to access the course details that is in a separate url in a dynamic list, there is…
-
0
votes1
answer325
viewsDoubt with Django 2.0 views and urls
How best to do these functions in the views.py, or it has to be that way? from django.shortcuts import render def index(request): return render(request, 'contas/index.html') def cadastro(request):…
-
0
votes1
answer75
viewsSet a css class and render the form in Django
I created the following class: from django import forms class FormDefault(forms.Form): def __init__(self, *args, **kwargs): super(FormDefault, self).__init__(*args, **kwargs) for field_name, field…
-
0
votes2
answers1130
viewsProblems with using include in Django
I’m having trouble with the include function, according to the Django documentation, the syntax is include(module, namespace=None), include(pattern_list),include((pattern_list, app_namespace),…
-
0
votes1
answer455
viewsDjango Session, emite: Object of type '' is not JSON serializable
I am creating a student but when I try to save it within a session, returns me the following error: Object of type 'Student' is not JSON serializable In Settings.py: INSTALLED_APPS = […
-
0
votes1
answer70
viewsDjango + Postgresql Object has no attribute
I am trying to do a validation before submitting my form, but returns me the following error: 'Studentform' Object has no attribute 'termAccepted' models.py of the app: from django.db import models…
-
0
votes0
answers100
viewsDetect distinction between the model chosen by the user for registration
Hello, so, I created some models to register users in Django 2.0 and now I need to know which one the user chose to register. As you can see I have the individual model (Customusern), legal entity…
-
0
votes1
answer406
viewsDjango Forms.Checkboxselectmultiple emits: Select a Valid Choice. [''] is not one of the available Choices
I’m trying to use a checkbox to select items in a list, but returns me the following error: Select a valid choice. [''] is not one of the available choices. py.models app: from django.db import…
-
0
votes1
answer219
viewsCalculating a date inside the Model Django timedelta
I am declaring a function (data_prox_prog) to calculate a future date and store in the model, but it is not happening as expected. Follows code: class ProgressaoDocente(models.Model): servidor =…
-
0
votes2
answers408
viewsDjango + Python update and do not insert
I am using a filter to return some student and update their data, but when I try to save I get the following error: Student with this CPF already exists. and Student with this RA already exists. My…
-
0
votes1
answer97
viewsShow modal only if there is an active session
When someone registers their name and email I create a session and I rescan the page with the name of who signed up, but I’m not able to understand how I do so that the time I rescan the page…
-
0
votes1
answer101
viewsHow to capture multiple HTML values with Django Forms
So that the html send a field of the type select with several values selected it is necessary to put the notation [] in the name attribute of html: <select name="categories[]" multiple="multiple"…
-
0
votes1
answer668
viewsIntegrate Rdstation with Django + Python p/ lead submission
Good morning guys, I have a problem: I have an LP that has to save the lead in the Postgres database and automatically send that lead to the RD platform using their API. using the curl I do it this…
-
0
votes1
answer42
viewsShow list items filtering by date.Today()
I have a list that I order by position in my models.py, but I have the field start_date I want to use as a validator so that the item is visible or not. But it is not working: py views.: from…
-
0
votes1
answer227
viewsMap dynamically generated tables in Django by another application
I will develop an application with Django in which it will be necessary to query data in a database that is powered by an ERP (desktop). This ERP generates some drive tables by adding at the end of…
-
0
votes2
answers376
viewsDjango does not connect to mysql database
was doing this project on linux Mint and I had to switch to windows and I’m having some problems to configure the environment. when rotating the command $ python Manage.py migrate get the following…
-
0
votes0
answers70
viewsCalling HTML snippet in Javascript
I am using Django Framework for an application that searches videos on youtube. But there is an excerpt of JS, which calls an html where "embeds" the video searched. And I don’t know how to create…
-
0
votes0
answers60
viewsSearch with GET not working
I’m making a system that searches for items in the system’s internal database, and in Apis like Youtube. The search should return videos(youtube) and data (internal database). The Youtube API is in…
-
0
votes1
answer588
viewsJavascript variable in Django template
Hello guys, good afternoon, I need to use a JS variable, being it the type Boolean in the Django template but I don’t know how to do it. Example of what I want to do: <!DOCTYPE html>…
-
0
votes2
answers58
viewsRandom search doesn’t work
I want to do a random search in the database, but it’s not working. I want to take a sentence, and show it on the screen, it will be changed every time we update the screen. My view.py: def…
-
0
votes1
answer1773
viewsHow to pass data from one input to another with HTML and Python?
Guys, I have a problem in my application and I can’t find the solution on the internet. I’m making a web application in which I need to get some user information and to improve the experience, I’m…
-
0
votes1
answer96
viewsCreating Energy log table for several Django models
I have 30 models. Each of them contains information from a calculator and each record is information from sub-calculators. I need to create a log table of each calculation made by the user.…
-
0
votes2
answers77
viewsELIF using not in, inside a FOR
I would like to know if there is any way to refine the ELIF within a FOR, so that it does not enter into it whenever the date does not exist, but if that date specifies it does not exist. Follow the…
-
0
votes1
answer302
viewsImporting an HTML Table into a Database
Hello, I’m a beginner in Django and JS. I’m having a lot of trouble importing an HTML table into an SQL database. has how to do this? Would it be better to collect this data and import directly into…
-
0
votes1
answer1038
viewsRelationship Django Models
I have a model called Item and made a call Compra. I was able to relate several items with each purchase, but I don’t know how to relate the quantity of each item in each purchase. class…
-
0
votes1
answer314
viewsDjango 2.0.9 - Multiselectformfield - Parameter to make not mandatory
I want to take the field Multiselectfield not mandatory. When I do not choose any of the options the validation is charging mandatory field. I tried to use the parameters Blank=True and null=True,…
-
0
votes1
answer828
viewsHow to relate a model to another model in Django 2
I’m making a system in which I need to show data that is registered in another Model, which in this case is the Category field that is in the Model Items and when showing it, the user would select…
-
0
votes1
answer223
viewsError: Deploy Python Heroku - Runtime (python-3.4.0) is not available
Personal, all right. Someone can help me solve the following problem: I’m making an application in Django and now I’m in the process of uploading to the server. I’ll send it to Heroku. I performed…
-
0
votes1
answer351
viewsHow to Put Value in the Django Will HTML Field?
Hello, I’m starting with Django now and wanted to know how to pass the value of the database to a Djando field using HTML to save the edit. Na minha View: @login_required def editar_aluno(request,…
-
0
votes1
answer165
viewsToggle bootstrap menu is not expanding
My menu with toggle-icon, being used exactly like that of the bootstrap4 example documentation simply does not expand. I tried that solution but nothing has changed. Currently the code is like this:…
-
0
votes1
answer312
viewsfetch api GET method with Django
Talk guys good day, I’m with a form that the user enters Cpf and ra and receives its id_registration, I’m trying to do this with ajax, but always returns 500 Internal Server Error, follows my line…
-
0
votes1
answer61
viewsI need relationship one for many between 3 tables
Hello I have the table People, Vehicles and Messengers who are the users who pay per month the precise staging that each person can have more than one vehicle, but when registering in the monthly…
-
0
votes2
answers311
viewsDeploy Python project to Heroku with error
I’m trying to deploy a Python project using Django on Heroku. deploy is fine, but when trying to do heroku run python manage.py migrate the following error occurs. Traceback (most recent call last):…
-
0
votes0
answers274
viewsDjango form linked to registration
I have two tables in Django (Game and Goal) and I’m trying to create a form for them: class Jogo(models.Model): ativo = models.BooleanField(default = True) dataHoraInicio =…
-
0
votes1
answer543
viewsValueerror: Cannot assign "'1'": "User.campus" must be a "Campus" instance. Super User registration error in Django
I’m developing an application where the user needs to be on a campus. However when superuser is created in the terminal an instance error occurs. Note: The database is correctly pre-filled to fetch…
-
0
votes1
answer85
viewsWhat is the return order of the Javascript "find" function?
I have an application in Django that uses this widget: https://github.com/ExoticObjects/django-better-filter-widget/ In line 6 of the Better-filter-widget.js file the plugin executes the following:…