Re: Better style: from django.db import models vs from django.db.models import ...

2016-08-03 Thread graeme
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

Re: Better style: from django.db import models vs from django.db.models import ...

2016-08-01 Thread Michal Petrucha
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. >

Re: Better style: from django.db import models vs from django.db.models import ...

2016-08-01 Thread ludovic coues
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

Better style: from django.db import models vs from django.db.models import ...

2016-08-01 Thread graeme
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