[Answered ]-Is there a difference between (eg) 'ListView' and 'generic.ListView'?

1๐Ÿ‘

โœ…

Are the two interchangeable?

Yes, both will refer to the same class. The first one is sometimes used if you want to import a lot of items from the django.views.generic module, and thus do not want to list these.

Furthermore it is sometimes used to avoid "name clashes" where you import two different things with the same name. For example the django.forms.CharField and django.db.models.CharField are two different types, then it can help to import one through an alias, or import the module and thus reference to it with models.CharField or forms.CharField.

Leave a comment