django-templated-email doen't works on heroku - python

I've installed succesfully https://github.com/bradwhittington/django-templated-email.git, and it works smoothly on my local server, but, when I upload my app to a heroku repo that I have, when it get's to the sending email, the browser shows internal server error.
I think this is because it tries to read code from where "pip" installed the package, and that data path doesn't exists on heroku.
What I need to know:
How can I make it to work in my heroku server?
Thanks a lot!

Have you specified the below in your requirements.txt file for pip to know where to install it from?
The below points to the latest commit. If the developer has packaged the file as a egg, you can use that too.
git+git://github.com/bradwhittington/django-templated-email.git/62a291004cb21e50409b276bcbd79ae9808aace9
So if the missing package is the reason for your error, adding the above to requirements.txt should fix it

Related

How can you change your python code after you deploy it to heroku using git , without downloading and reinstalling requirements everytime? [duplicate]

Im using django 3 and Python 3.7.4
I don't have any issues with the deployment and the project is working, it's just the first time I face this issue.
Normally when deploying to Heroku all packages in the requirements file get installed during the first deployment process, and any further deployment will only update or install the new packages the get added.
In my case, everytime I deploy, heroku is installing the whole packages again.
Please advise if there is a way to handle this issue.
thanks
This looks like a current issue with the Heroku python buildpack. As long as the issue persists the cache is cleared on every build, since the sqlite3 check is broken. Suggest upvoting the issue on GitHub.

Running move and delete commands on Heroku CLI

I've recently deployed an application to Heroku. Due to the constraints of the file system I'm looking to replace two css files within a Flask Package upon the application starting.
My main goal is to take a file from the app directory (the file is part of the git repo) and use it to replace a python package file located in the site packages directory.
I've tried to run the following from the Heroku CLI but nothing seems to happen.
heroku run mv ./bootstrap.css ./.heroku/python/lib/python3.6/site-packages/flask_bootstrap/static/css/bootstrap.css
I've also tried to remove the files from the site packages directory using RM but again nothing happens.
Could you please let me know if standard unix commands work on Heroku?
Fork and edit flask_bootstrap and add that to requirements.txt file like this.
Heroku using ephemeral filesystem. Whatever change you made to your filesystem only last until the dyno is restarted.
So my opinion is to change the file in your local repo and push to heroku again.
Source : https://help.heroku.com/K1PPS2WM/why-are-my-file-uploads-missing-deleted

heroku keeps installing django packages during each deployment

Im using django 3 and Python 3.7.4
I don't have any issues with the deployment and the project is working, it's just the first time I face this issue.
Normally when deploying to Heroku all packages in the requirements file get installed during the first deployment process, and any further deployment will only update or install the new packages the get added.
In my case, everytime I deploy, heroku is installing the whole packages again.
Please advise if there is a way to handle this issue.
thanks
This looks like a current issue with the Heroku python buildpack. As long as the issue persists the cache is cleared on every build, since the sqlite3 check is broken. Suggest upvoting the issue on GitHub.

"ModuleNotFoundError: No module named 'django'" when trying to deploy Django server on Azure

After I tried to deploy my Django website on Azure, I got an error saying:
ModuleNotFoundError: No module named 'django'
I added a requirements.txt in the root directory of my Django project, am I missing anything else? I've tried to install Django from Kudu BASH but it gets stuck on "Cleaning Up".
Here is the full error: https://pastebin.com/z5xxqM08
I built the site using Django-2.2 and Python 3.6.8.
Just summarized as an answer for other people. According to your error information, I can see that you tried to deploy your Django app to Azure WebApp on Linux based on Docker. So there are two offical documents will help as below.
Quickstart: Create a Python app in Azure App Service on Linux
Configure a Linux Python app for Azure App Service
The error ModuleNotFoundError: No module named 'django' indicated that there is not django package installed on the container of Azure Linux WebApp.
Due to the content of Container characteristics of #2 document above as below,
To install additional packages, such as Django, create a requirements.txt file in the root of your project using pip freeze > requirements.txt. Then, publish your project to App Service using Git deployment, which automatically runs pip install -r requirements.txt in the container to install your app's dependencies.
So the possible reason is the requirements.txt file not in the corrent path of your project or container after deployed, which path should be /home/site/wwwroot/requirements.txt on the container or the root of your project like the offical sample Azure-Samples/djangoapp on GitHub.
I had the same problem. requirements.txt was in my repository, but randomly I started getting the same error ModuleNotFoundError: No module named 'django' after changing a setting or restarting the service or something. Nothing I could do, change the setting, or reboot repeatedly fixed it. Finally what worked for me was this:
Make a small change to the code and commit it, and push it up to the app service.
This fixed it for me. It has happened a couple times now and every time this solution has worked for me. It seems like the App Service sometimes gets in this state and needs to be jostled with this trick?

Production server saying it is missing modules after database flush with Python

I have an application using Django1.9, and python2.7. I recently flushed my PostgreSQL database on my production server, and now whenever I try to use the application it is telling me there are missing modules. I never faced this issue before so I am curious, when you put your application on a production server, does your virtual environment go with it ? If so, does flushing your database have any effect on your virtual environment ?
I have been getting past the issues by downloading each module to a third parties directory in my application, and including them in my 'installed apps' list in my setting file, but I wouldn't want to continue doing that if there are 100+ modules I need to download.
I also tried to use pip install on my production server, and it said that the command was not found, although I have the latest version of pip installed on my mac ?
I am curious, when you put your application on a production server, does your virtual environment go with it ?
Not necessarily unless you copied the virtualenv folder with it which isn't really a good practice, you should create the virtualenv on the production server
If so, does flushing your database have any effect on your virtual environment ?
No, the database and virtualenv are completely separate
I wouldn't want to continue doing that if there are 100+ modules
Use a requirements.txt file and install them all at one go with pip install -r requirements.txt
I also tried to use pip install on my production server, and it said that the command was not found
You have to install pip first, on the production server

Categories