Questions tagged as 'django'

1
answer

Sort DateTimeField only by date

I wanted to sort DateTimeField just by date, ignoring the time. Because in my ordering I need Person.objects.order_by('-date_joined', 'full_name') But sorting by name has no effect because the field has time, but I just...
asked by 30.06.2016 / 20:37
1
answer

Is there any risk in using the Django Token Generator in different services?

Assuming that I'm already using the django.contrib.auth.tokens.default_token_generator  generating tokens to reset a user's password, and  want to use the same method to activate the user, or for any other similar service, are there any o...
asked by 10.06.2016 / 01:44
1
answer

Rest API Django does not work

I have a problem with Python/Django . The school and school_application_info tables are related. However, there is no record with some school_id in school_application_info . So I added null=True, blank=True...
asked by 17.05.2016 / 22:22
1
answer

request.post () does not work correctly by generating a 301 redirect in Nginx

I'm having a problem when using request.post('url', data) , for some reason when the server receives this request, it redirects (301) the request to the same url by losing the POST data, ending as a GET method. Python: >>>...
asked by 01.04.2016 / 22:33
1
answer

Django Template Email

DJANGO: Could anyone help me put email template (pull some html or css to email content) through views.py? I tried everything but it did not work, grateful already. Views.py: - - coding: utf-8 - - from django.shortcuts import render f...
asked by 14.02.2016 / 22:55
1
answer

Performance in Queryset CBV

# models.py class Book(TimeStampedModel): name = models.CharField(_('nome'), max_length=50) authors = models.ManyToManyField('Author', verbose_name='autores') price = models.DecimalField(_(u'preço'), max_digits=5, decimal_places=2) #...
asked by 22.10.2015 / 04:35
1
answer

How to improve TestCase speed in Django?

I'm running a test in Django with just two querys and in the timer it's taking 1 min and 10 seconds to finalize the test. Is there a setting I can adjust to speed up testing? I'm currently using postgresql in the project database.     
asked by 04.09.2015 / 22:38
2
answers

(Django) How to implement a button in the template that triggers any method? [closed]

My question is regarding the implementation of buttons in any template. I want to click this button and do something, such as displaying a message on the screen. How can I do this? Here is an image of my application that I want to add an "exit"...
asked by 12.08.2015 / 17:31
2
answers

How to display Radio Button type fields in form using Django?

I created a file called const.py (where I have the choices I'll call in models) as follows: const.py FORENSIC_TRAFFIC_LIGHTING = ( (u'1', u'Boa'), (u'2', u'Ruim'), (u'3', u'Ausente'), ) models.py class ForensicTraffic(m...
asked by 18.10.2015 / 20:23
1
answer

Returning get_FIELD_display from a list transformed into a dictionary (Django)

I wanted to make the following list into a dictionary: lists.py status_list = ( ('c', 'cancelado'), ('elab', 'em elaboração'), ('p', 'pendente'), ('co', 'concluido'), ('a', 'aprovado') ) So I did the following:...
asked by 27.07.2015 / 06:50