Skip to content

Break api.py file into several for readability #471

Answered by SmileyChris
ihelmer07 asked this question in Q&A
Discussion options

You must be logged in to vote

That should work fine, as long as each module actually gets imported before api.urls is called. Otherwise the decorators adding your functions to the api will never be executed!

You could either do these imports on the urlconf (import .api.api_class_b)

Or you could import every split module class from api/__init__.py. If you do that though, you'll want to put the actual api = NinjaAPI() in a child module rather than in the init root itself to avoid a circular import.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ihelmer07
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants