Questions tagged as 'django'

2
answers

Send objects to a template base.html Django

My situation is as follows, I have a file base.html where more than one page of a 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, that extend the page (base....
asked by 20.07.2015 / 20:57
2
answers

How to return a query in JSON format with extra values and custom keys?

I want to return the result in JSON following this format: {"cadastros": [ {"id": 1, "STATUS": true, "pessoas": [], "podeEscrever": true}, {"id": 2, "STATUS": false, "pessoas": ['Maria', 'Ana'], "podeEscrever": true}, ], 'princi...
asked by 29.07.2015 / 00:28
1
answer

Name parameter in Django's URLconfs

In the URLconf below: urlpatterns = [ url(r'^$', views.index, name='index'), ] What is the function of the name parameter? Is it possible to explain with a practical example?     
asked by 26.05.2017 / 01:58
1
answer

What is the purpose of. in form action="." method="post"?

I'm starting in Django and making some code changes already written by someone. I noticed that in form instead of the usual "/action page" where the data will be submitted, such as in this W3Schools example: <form action="/action...
asked by 16.02.2017 / 23:02
2
answers

What is the difference between .save () and .update () in Django?

I'm having trouble understanding the difference between them, since I realized that I was using the .save () method to change my values, but I noticed that .update () exists.     
asked by 04.12.2015 / 01:29
1
answer

POO using Django

I'm starting to work with Django, but I have some questions about how to organize my project, I'd like to know how best to structure my projects. I'm used to the languages in which I model each entity with its attributes and methods in a clas...
asked by 30.10.2015 / 16:38
1
answer

How to build a queryset that only returns the cars with the last approved revision?

I want to create a queryset that returns only the cars that had the last approved revision. It is known that there may be n cars, and each car has a history of revisions, so there may be no revisions for each car. class Carro(models.Model):...
asked by 26.02.2015 / 03:44
2
answers

How to call class method in another app?

I want to create a file called config.py and put some settings inside a dictionary for whenever you need to invoke these parameters. But how do I call this parameter in Python? For example, I'm going to create the class Config...
asked by 29.12.2017 / 17:02
1
answer

Reading csv with django

Well, I'm working with an open database, and it's in CSV, I'm using DJANGO to read the CSV and thus inserting into the database ... But it's failing to insert the first year, I'm trying to insert 8 years of data, the first year it inserts only 1...
asked by 01.09.2016 / 00:43
1
answer

Refactoring Python code

How do I improve this code? import random import string import requests from django.core.management.base import BaseCommand, CommandError from django.core.exceptions import ValidationError from optparse import make_option from core.models impo...
asked by 23.11.2015 / 08:05