On Monday, August 1, 2016 at 5:59:17 PM UTC+5:30, Michal Petrucha wrote:
>
> On Mon, Aug 01, 2016 at 05:09:37AM -0700, graeme wrote:
> Either way is fine, using models.IntegerField
> and forms.IntegerField just makes it more obvious what kind of
> IntegerField it is you're referring to.
>
I
On Mon, Aug 01, 2016 at 05:09:37AM -0700, graeme wrote:
> I have always imported models, and then:
>
> class Foo(models.Model):
> bar = models.CharField(max_length=100)
>
>
> which is what the examples in the django docs do - I copied it when I
> started using Django and the habit stuck.
>
A models file might use a lot of class from the django.db.models
module and importing each class lead to lengthy import line. That's
might be one reason.
The better reason might be that a lot of these class are named the
same in django.forms and django.db.models. When you type
models.CharField, you
I have always imported models, and then:
class Foo(models.Model):
bar = models.CharField(max_length=100)
which is what the examples in the django docs do - I copied it when I
started using Django and the habit stuck.
It is a lot less verbose to do:
from models import Model, CharField
cla
4 matches
Mail list logo