Django - AttributeError: 'module' object has no attribute 'admin'
I'm in trouble. Python version: 3.4.4 Django version: 1.10 DB type/version: SqlLite3 Installed apps: accounting, registry, ... Models (accounting): Bank, Fee, ... Models (registry): Company, ... Generic relations: Company-Bank, Fee-Company, ... Admin site inline (accounting): class FeeAdmin(Admin): list_display = ['date', 'content_object'] inlines = [registry.admin.CompanyInline] ... Admin site inline (registry): class CompanyAdmin(Admin): list_display = ['__str__', 'contact_telephone', 'contact_cellphone', 'contact_email'] list_filter = Admin.list_filter + ['residence_city'] search_fields = ['company_name'] inlines = [accounting.admin.BankInline] ... Problem: the second installed app gives me the error in the title, if I switch the order in settings.py, the error is raised by the other app. The first one always run smoothly: inlines = [registry.admin.CompanyInline] AttributeError: 'module' object has no attribute 'admin' if registry is installed after accounting, or inlines = [accounting.admin.BankInline] AttributeError: 'module' object has no attribute 'admin' if the order is switched. Headers: accounting.admin: from django.contrib import admin from django.contrib.contenttypes import admin as ctadmin from django.contrib.contenttypes.models import ContentType import registry from .models import Bank from .models import Fee ... registry.admin: from django.contrib import admin from django.contrib.contenttypes import admin as ctadmin from django.contrib.contenttypes.models import ContentType import accounting from .models import Company ...
This is a question about Python imports. When you import a package, you don't automatically get access to all the modules underneath it; you need to import those specifically. So instead of doing import accounting and then trying to access accounting.admin, you need to explicitly do from accounting import admin and then accessing admin.BankInline etc.
How to create list of all parts of elements in NumPy array (Python list)
Encoding issue for Python tool Unidecode on CL
Accept only numbers on a python string [closed]
scrapy spider pass parameters
sending data to particular client from twisted server
Type Error, object cannot be interpreted as an index with tk message box bind commands
What is this condition testing? [duplicate]
Testing Flask login and authentication?
Pyjnius import jar file
Regex - Combining an 'or' with a 'look-behind'
Command fails in python, but not in terminal
Does ndb.toplevel break transactions?
Unique variables names for results in a nested loop
Get unique set of adjacent vertices in python bulbs or gremlin?
Django admin project distribution and management
Increase event handling speed in Twisted?