Hi guys. we are on week 4 of trying to get our Dja...
# general
i
Hi guys. we are on week 4 of trying to get our Django app to working pants. We are now trying to figure out how to get local development to work. At the moment, none of the
admin.py
files are getting pulled in (as well as other magic dependencies). Does anybody have any tips on how to solve this?
s
you’ll have to manually mark dependencies for all the “magic” files so Pants knows to include them in the various sandboxes. in our repo we wrote a macro that creates dependencies from
apps.py
to
admin.py
etc.
as part of ^^^ we internally enforce that each app has an
apps.py
and that our
INSTALLED_APPS
settings refer to the fully-qualified
AppConfig
subclasses within each of those files, so dependency inference can find them. if you use the short-hand references for
INSTALLED_APPS
then Pants won’t know to pull in the
apps.py
files
i
Thanks Dan. I took a look at your macro, how are you guys including
/admin
folders?
s
we don’t have any of those at the moment - if it came up I’d handle it the ~same way as we handle
models.py
vs.
models/
i
got it. thank you
h
Yeah, if there is no
import
, or at least a setting.py-style “string import” then you have to manually add the relevant deps, since there is nothing to infer them from
i
yup. After manually adding each django app to dependencies, things seem to be working
(minus Jupiter notebooks which seems to throw a
psutil module not found
error even when we add it to the dependencies
s
@happy-kitchen-89482 even string imports don’t save you on this one - the magic is all tucked away inside of 3rd-party packages installed via Django settings 🤢
i
yup. it is the worst
Migrating a large existing Django app isn't the easiest thing
1
s
I have been meaning to submit some PRs to the example django repo to make it a little more gnarly / realistic
❤️ 1
might prioritize that this week 🤔
i
That would be amazing
h
A pants plugin for django that understood django layout and applied dep inference appropriately would be awesome
💯 2
h
agreed. I don't think we have a tracking issue for better first-class Django support, if anyone wants to open an issue -- it's fine to not know everything it should do yet. We can start adding new ideas to it