Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty models.py will make error on cause problems at the project level #1856

Open
mowbish opened this issue Jan 15, 2024 · 0 comments
Open

Comments

@mowbish
Copy link

mowbish commented Jan 15, 2024

Bug Report

Description

When we are developing and there is no class created in the models.py file yet; If we enter the admin_generator command; Because there is no class in models.py yet; ImportError occurs in admins.py, which is very boring. It is troublesome.

I used this command to create admin.py for each app.

for APP in financials orders products stockrooms users utils identifications;
do python manage.py admin_generator $APP > $APP/admin.py;
done

Is this a regression?

No, absolutely not

Stack trace / Error message

File "~/src/stockrooms/admin.py", line 4
  from .models import 
                        ^
SyntaxError: invalid syntax

Solution

you should just say if models.py is empty, don't import it;
or import *
or you can also use try/except for this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant