Having been run as an .exe, the django admin panel hides models except users and user groups

18 views
Skip to first unread message

Shi James

unread,
Mar 4, 2020, 11:02:19 AM3/4/20
to PyInstaller

I created the most simple Python/Django project following to the standard procedure: virtual environment => startproject, startapp, simple model with one Char field. Also I add my model to the admin.py file. Then I ran makemigrations, migrate, createsuperuser.

If I run like python manage.py runserver then everything is perfect: I can view and edit my model.

But I need to run my program as a single exe-file. For that purpose I use PyInstaller with default settings. The exe file is generated with no errors.

And here is the problem: there is no my model at the Admin Panel except User and User Groups.

My environment is Python 3.7, Django 2.2, Pyinstaller 3.4, Windows 7. Everything is under a virtual environment.

Have anyone run into that problem? Is there any workaround to it?

Thanks in advance.

Shi James

unread,
Mar 4, 2020, 11:02:26 AM3/4/20
to PyInstaller

Chris Barker

unread,
Mar 4, 2020, 1:59:50 PM3/4/20
to pyins...@googlegroups.com
I'm not very familiar with Django, but I recently did something similar with PYramid.

The trick *may* be that Django is doing a bunch of its configuration/ discovery dynamically, at run time. That was the case with Pyramid -- essentially is was scanning the code at run time looking for views to include.

So when PyInstaller ran, it didn't  know that those view files needed to be included, so at run time, they weren't found.

You may need to either:

change your config so that everything is explicitly imported / included statically.
or
add the extra modules to PyInstaller (via the spec file) by hand.

Sorry to not be more specific, but maybe this will give you some ideas.

-CHB



--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/6a3f4485-1a05-428e-9d25-7f482b534b50%40googlegroups.com.


--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov

Shi James

unread,
Mar 6, 2020, 11:56:30 AM3/6/20
to PyInstaller
Thanks Chris! 

I have tested it with a new project, but the problem is still the same. I have tried to write all the hiddenimports, and it runs without any errors, but it is strange that the functionality of the application is lost, Maybe PyInstaller not support for Django so well.

在 2020年3月5日星期四 UTC+8上午12:02:19,Shi James写道:
Reply all
Reply to author
Forward
0 new messages