简体   繁体   中英

Aldryn - how to add own Django apps and its dependencies

I have some apps that I would like to include statically into my djangoCMS templates on Aldryn. I don't think it's beneficial or necessary to register them as addons in the Aldryn Control Center because these apps are specific to the project.

What is the best way to include them and where should I specify their dependencies which I normally add to requirements.txt?

My current solution is adding /addons-dev/ to git and add my apps there (/addons-dev/django-app/django_app/)

Where to put project specific python code?

Project specific applications can be placed in the root of the project - that'll just work out of the box. If there are many such apps that might be a bit messy though. But it is easy to add an extra directory to the PYTHONPATH . In the Dockerfile add: ENV PYTHONPATH /app/src:$PYTHONPATH . The beginning of the Dockerfile should look something like this:

# <DOCKER_FROM>  # Warning: text inside the DOCKER_FROM tags is auto-generated. Manual changes will be overwritten.
FROM aldryn/base-project:3.1.0
# </DOCKER_FROM>

# add the "src" folder to the PYTHONPATH
ENV PYTHONPATH /app/src:$PYTHONPATH

# <DOCKER_BUILD>  # Warning: text inside the DOCKER_BUILD tags is auto-generated. Manual changes will be overwritten.

# node modules
[....]

After this change the docker image will need to be rebuilt: docker-compose build web

How to install external project dependencies?

External project specific requirements can be added to requirements.in . It is very similar to requirements.txt , but is preprocessed with the pip-compile command from pip-tools .

Make sure to place custom dependencies outside of the

# <INSTALLED_ADDONS>
...
# </INSTALLED_ADDONS>

tags, since that part of the file is maintained automatically and is overwritten automatically with the requirements that were chosen in the UI.

For changes in this file to be picked up, rebuild the docker image: docker-compose build web

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM