Questions tagged as 'django'

1
answer

What is the real use of the pass in this case?

I'm working on the adaptation of a django project already created. During the code analysis I came across the following excerpt: def objects_delete_action(modeladmin, request, queryset): for obj in queryset: try: obj.de...
asked by 27.09.2017 / 15:29
2
answers

Returning ZIP code data in form

I have the following problem: I am trying to fill in the fields public place, city and state with the informed zip. They are all input. I'm using link My project is in Django, but I think you can return the data directly on the html page (fron...
asked by 21.07.2014 / 04:41
1
answer

Methods __str__ and __unicode__

I have already seen class codes that implement Django models overriding both __str__ and __unicode__ , is there any difference between them? If so, is there a case that I should prefer one instead of another?     
asked by 25.05.2017 / 17:31
1
answer

Filter by date in list (Django)

Imagine that I have a list and a form to filter this list by date. Does anyone have an example of how to do this filter in form? I got this here in the shell, but I do not know how to implement it in the form, in the template. $ ./...
asked by 26.10.2015 / 01:15
2
answers

What's the difference between the MVC architecture and Django's MTV?

I would like to know if there is any difference in practice between these two architectures.     
asked by 17.10.2017 / 18:59
1
answer

Mounting table array in Django

I have two tables, in the example (any) of the figure below I have the Paises table and the Energia table SettingupathirdtableinDjangoIwouldhavesomethingwiththefieldspais,energia,valorÁustria,Carvão,3.6Áustria,Ciclocombinadodeg...
asked by 05.11.2015 / 16:07
1
answer

Total with pluralize in template Django

Personal I have the following code: <div> <h4>{{ combination|length }} combinação{{ combination|length|pluralize }}</h4> <h5><b>Total:</b> {{ combination.paginator.count }} combinação{{ combination.p...
asked by 06.07.2016 / 16:34
2
answers

How to know if request.FILES is empty?

I have a code in Django where I want to upload a file from a form. At any given moment, I need to check if the index "arquivo" exists within the variable request.FILES I did this using the has_key method as foll...
asked by 05.02.2015 / 18:48
2
answers

View in Django does not return HttpResponse object

I'm doing a simple CRUD in Django for learning purposes, but I'm having a problem. When creating a view to add data to a schedule, the server returns the following error:    The view agenda.views.add does not return an HttpResponse object....
asked by 17.03.2014 / 07:03
1
answer

How to save a model with FileField using a preexisting file?

I'm importing a set of pre-existing Django files, and I'd like to reference them in my templates (which use FileField or ImageField ). For example, one of my templates looks like this: class Imagem(models.Model): arquivo = Ima...
asked by 04.01.2018 / 15:02