Search code examples
pythondjangomodels

Django: Importing app named admin from another app


Our application has an "admin" app within it. django.contrib.admin isn't in our installed apps, so I don't think there's any conflict, but I can't import admin.models for whatever reason. Here's the stacktrace:

No module named models
Request Method: GET
Request URL:    http://localhost:8001/jobs/
Django Version: 1.8.4
Exception Type: ImportError
Exception Value:    
No module named models

Here's how I'm calling it: from admin.models import JobPosting.

Strangely enough, I discovered it does work if I change the name of the app to admin2 instead of admin, but it looks bad and I'm hoping there's a better solution. I've globally searched through the project and the only references to admin are the ones that are pointing at the app we've built. It might also be worth noting that I'm able to import admin.urls just fine from within the base urls.py file and it always works from the shell.

Is there any trick to this that I'm missing? Thank you!


Solution

  • Fixed this.

    Anyone running into trouble in the future, make sure you delete your pyc files whenever you're losing your mind over changes that should work but aren't. I had an admin.py file and even though I had deleted it, admin.pyc remained to give me trouble.