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

class Foo(Model):
    bar =CharField(max_length=100)

because each imported class is used many times in a typical models file. 
The same apples to forms.

On the other hand the generic views documentation tends to do things like:

from django.views.generic.detail import DetailView


I have increasingly tended to do the same with forms, but not for models, 
except for things like Q which would be verbose to do otherwise

Which is better style (and why)?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f644ac2f-098a-4bdb-a67e-d17e762a4ce7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to