Questions tagged as 'django'

1
answer

Simple Django form

If I have in my model a class usuario , a phones and a class manager, which are one to one, like this: class Usuario(models.Model): login = models.CharField(max_length=50, unique=True) senha = models.CharField(max_length=50)...
asked by 03.05.2015 / 21:48
1
answer

It is a good practice to import modules in __init__.py

I noticed that in the Django framework modules are imported into __ init __ .py for convenience. """ Django validation and HTML form handling. """ from django.forms.forms import * # NOQA So this: from django.forms.forms import Form...
asked by 05.06.2014 / 15:46
2
answers

How do I make Django "see" CSS?

I'm writing a Django and Python application, and I'm having a problem     in the templates part, running locally Django found the template and     I was able to visualize it through localhost:8080/home , it happens that the     style sheet...
asked by 07.05.2014 / 18:07
2
answers

How do you calculate (with ease) total and subtotal in Django?

I'm using Django 1.7.8 I have models.py class SaleDetail(models.Model): quantity = models.PositiveSmallIntegerField(_('quantidade')) price_sale = models.DecimalField( def get_subtotal(self): return self.price_sale * sel...
asked by 29.05.2015 / 20:11
3
answers

Annotate: Returning the cheapest product and vendor name (Django)

Given the following table product;company;price AAAAA;forn1;395.69 BBBBB;forn1;939.45 CCCCC;forn1;480.33 DDDDD;forn1;590.59 EEEEE;forn1;847.69 AAAAA;forn2;227.31 BBBBB;forn2;375.90 CCCCC;forn2;602.18 DDDDD;forn2;615.02 EEEEE;forn2;84...
asked by 03.09.2015 / 18:32
1
answer

What is the best way to send HTML email in Django?

I am a beginner in Python and Django and in the project I am doing for study, I send an email, which has an HTML template. I was able to send an HTML email using EmailMessage : msg = EmailMessage(subject, template.render(variables), send...
asked by 30.01.2014 / 04:17
1
answer

How does Django create and verify tokens to reset password?

Given a template to reset password already implemented by Django, in the following views: django.contrib.auth.password_reset django.contrib.auth.password_reset_done django.contrib.auth.password_reset_confirm django.contrib.auth.passwor...
asked by 07.06.2016 / 13:42
1
answer

Django generating strange code

I'm using visual studio community and I created a web project with Django, but when I make the homepage, it's generating this code: AndthecodeIhaveisthis:{%loadstaticfiles%}<!DOCTYPEhtml><html><head><metacharset="utf-8"...
asked by 06.05.2016 / 04:07
1
answer

Filter using calculated value does not work in Django

I have a template in Django with fields largura and comprimento , and I would like to filter it by area: class Projeto(models.Model): largura = models.DecimalField(decimal_places=0, max_digits=4, default=0) comprimento = m...
asked by 07.04.2016 / 15:42
1
answer

Can not assign "'Maria'": "Student.name_mae" must be a "Student" instance. When I try to access a field from the student subclass

I have a system with multiple users, I decided to make inheritance from the standard Django User, I have two users: student and teacher, which has several characteristics in common, so I created a User base class and subclasses Student and...
asked by 11.06.2015 / 19:56