Deployment - Heroku

Hi All (Ken more likely),

I followed Heroku’s deployment guide, and I’m getting the following error:

-----> $ python collectstatic --noinput
       Traceback (most recent call last):
         File "/tmp/build_e076db66/", line 22, in <module>
         File "/tmp/build_e076db66/", line 18, in main
         File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/", line 419, in execute_from_command_line
         File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/", line 395, in execute
         File "/app/.heroku/python/lib/python3.9/site-packages/django/", line 24, in setup
         File "/app/.heroku/python/lib/python3.9/site-packages/django/apps/", line 122, in populate
         File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/admin/", line 27, in ready
         File "/app/.heroku/python/lib/python3.9/site-packages/django/contrib/admin/", line 24, in autodiscover
           autodiscover_modules('admin', register_to=site)
         File "/app/.heroku/python/lib/python3.9/site-packages/django/utils/", line 47, in autodiscover_modules
           import_module('%s.%s' % (, module_to_search))
         File "/app/.heroku/python/lib/python3.9/importlib/", line 127, in import_module
           return _bootstrap._gcd_import(name[level:], package, level)
         File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
         File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
         File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
         File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
         File "<frozen importlib._bootstrap_external>", line 850, in exec_module
         File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
         File "/tmp/build_e076db66/account/", line 2, in <module>
           from .models import Profile,Leads,Company,Client,CallReport,Deal,LeadEntry
       ModuleNotFoundError: No module named 'account.models'
 !     Error while running '$ python collectstatic --noinput'.
       See traceback above for details.
       You may need to update application code to resolve this error.
       Or, you can disable collectstatic for this application:
          $ heroku config:set DISABLE_COLLECTSTATIC=1

I’m not sure why is failing on that line in

from django.contrib import admin
from .models import Profile,Leads,Company,Client,CallReport,Deal,LeadEntry

# Register your models here.
class ProfileAdmin(admin.ModelAdmin):
    list_display = ['user','id','photo','role','location']

class LeadAdmin(admin.ModelAdmin):
    list_display = ['estimated_closing_date',
                    'expected_revenue', 'country', 'status',

class CompanyAdmin(admin.ModelAdmin):
    list_display = ['company','category']

class CallReportAdmin(admin.ModelAdmin):
    list_display = ['minutes_of_meeting','client_POC','location',

class ClientReport(admin.ModelAdmin):
    list_display = ['firstname','lastname','company','position','country','email','phone',

class DealReport(admin.ModelAdmin):
    list_display = ['id','project_id', 'sales_order','agent', 'service',

class LeadEntryForm(admin.ModelAdmin):
    list_display = ['id','lead_id','revenue','date','probability','stage']

What does your project’s file structure look like? And are you using any buildpacks that would change the file structure? It seems like the parent directory may be missing an file, but I don’t see how that would work locally though. Hence the question if you’re doing anything funky with Heroku.


Thanks, there was an error with the repository, so we finally managed to get the app working, however, as part of the CD/CI, I’m continuing working on the app, and I have made some changes just to see if I can update my project, and well is not working.

I made some changes to the database on my local project → push to github and then on to Heroku, and since I made some changes to the DB, I ran the correspondent migrations:

C:\Users\fcolina>heroku run python makemigrations
 »   Warning: heroku update available from 7.53.0 to 7.59.2.
Running python makemigrations on ⬢ acteq-crm... up, run.6883 (Free)
Migrations for 'account':
    - Add field installation_date to deal
    - Add field license_term to deal
    - Add field installation_date to leads
    - Add field license_term to leads
    - Alter field location on callreport
    - Alter field country on client
    - Alter field email on client
    - Alter field firstname on client
    - Alter field lastname on client
    - Alter field tesserACT_status on client
    - Alter field id on deal

C:\Users\fcolina>heroku run python migrate
 »   Warning: heroku update available from 7.53.0 to 7.59.2.
Running python migrate on ⬢ acteq-crm... up, run.3358 (Free)
Operations to perform:
  Apply all migrations: account, admin, auth, contenttypes, sessions, taggit
Running migrations:
  No migrations to apply.
  Your models in app(s): 'account' have changes that are not yet reflected in a migration, and so won't be applied.
  Run ' makemigrations' to make new migrations, and then re-run ' migrate' to apply them.

I have done it several times and is still not working.

Any ideas on how to fix this error?

When you run heroku run ... makemigrations it spins up a new dyno, it doesn’t re-use an existing one (that’s a different heroku command). So what’s happening is that you’re spinning up a dyno, it creates a migration file in the local file system, then the whole dyno disappears. When you run heroku run ... migrate it’s working against the migrations that were committed to your git repo and doesn’t see the migration file created in the other dyno’s command.

You should run makemigrations locally, commit that to your repo, and push it to heroku where you can then use heroku run ... migrate to modify your database.


Thanks, everything is working now, you are completely correct, and I just found this guide:

As a plug for a repo I help maintain, there’s django-safemigrate which has been built specifically for Heroku and adding the safemigrate command to Heroku’s release phase tasks.