How to add Procfile in pycharm for Heroku deplyment? - django

Trying to add a Procfile to my pycharm django project but it just asking me for the file extention. Any idea??

Go to file > new file > type in Procfile > enter > select the type: file containing setting for the editor

Give it the extension .txt, edit it and then refactor the file to be without an extension again.

To my knowledge, you first have to install the Heroku CLI.
Go to Deploy on your Heroku app page then go to "Download and install the Heroku CLI".
After downloading, restart Pycharm and it should work.

Make sure your venv is activated before you create a Procfile. You should be free to create it without an extension if the venv is activated.

Related

How to start a django project on one that is already created?

I already have a django project and all files created, but I am trying to deploy to a server. I moved files over to server using FileZilla and I am in putty now trying to django-admin startproject practice ~/practice but I get a command error stating that this already exists which obviously it does but then if I want to manage.py makemigrations I get a -bash: Permission denied and I am guessing that is because I have not started django project here on putty??? I hope there is enough info here to explain my issue. Any help is appreciated
You need run python manage.py runserver in the correct folder with admin permisions.

django-admin command error while project creation

After upgrading to django 1.9 and tried creating new project.Getting following error
How should i solve this?
After upgrading to django 1.9 and creating new project following error occurred
CommandError: /home/shaastr/ehgg/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files
I think you have 2 versions of django installed, and both are being called when trying to start the project.
Try running pip uninstall django twice, if it runs both time then this was what was going on. Obviously, pip install django afterwards to get it working again
I had the same problem after using pip to install django 1.10 over an older version.
I used pip to uninstall and manually deleted the leftover django folder in the site-packages folder.
re-installed using pip, and now it is working with no problem.
I am also working with docker containers. I had this problem where it said that manage.py already exists in the workdirectory (that I made through the Dockerfile file) when I tried to restart the process of making a container after deleting the old one.
It did not show me where the workdirectory was made and hence could not delete the manage.py as pointed out in the error.
The solution that worked was I changed the service name in my yml file and gave the command with new servicenm
docker-compose run servicenm django-admin.py startproject projectnm directory
remove manage.py then re-run your django-admin startproject command, it will work
Make sure that if you have deleted (rm -r) "your Django project_name" to also delete (rm) the manage.py corresponding deleted project python file in the same repository.
sudo pip uninstall django
sudo rm /usr/local/lib/python2.7/dist-packages/django/ -rf
sudo pip install django==1.10
This resolved my problem.
You need to define another directory for your new project. Not /ehgg directory.
It seems though you are creating a new project inside your old project.
And this error clearly state that, there is old setting i.e "manage.py" for your old project. Since every time a new settings manage.py created for your new project.
I hope it's clear to you.
Thank you.
Check whether the project name is correct or not. Django avoids
hypens (-) in project names.
It can happen due to two reasons:
You are trying to create a new folder with the exiting folder name.
You have previously deleted a folder with this name. Deleted it for some reason. But again trying to create package with this name.
To resolve this follow
Rename the manage.py from your project folder.
Go to <%System Path%>/PycharmProjects/<%Your Project Name%>/.idea/workspace.xml
edit this file "workspace.xml" and then search with the package name you are trying to create.
delete that line and save the file.
Now try to run the command again.
I hope this helps.
Regards,

How to overcome 'Coudn't find that formation' error when adding web dynos to Heroku django app?

I'm trying to get deploy a simple django app, and have successfully pushed my git repository to Heroku. However, when I attempt to run:
heroku ps:scale web=1
I get the following error
Scaling dynos... failed
! Couldn't find that formation.
Any thoughts as to what the problem might be? The contents of the Procfile (below) are correct to the best of my knowledge.
web: gunicorn my_app_name.wsgi
To state the obvious: another way to encounter this issue is if you're working on a new app, and you try running heroku ps:scale web=1 before you've actually done a git push heroku master. There is no Procfile on the Heroku server in that case, because there aren't any files at all. :D
Ensure that your Procfile has no extension.
To create a file with no extension on Windows, you can use the command notepad Procfile. from the command line.
To add yet another reason this can happen, my Procfile contained
web:gunicorn
but it should be:
web: gunicorn
As far as I can tell from all of these answers, if you run into this problem, it is very likely related to Procfile.
for those interested, I had the same problem to add a worker. to do so you need to add this line to your procfile : worker: python worker.py
For others experiencing this same issue, make sure Procfile is not ignored in git.
Delete your Procfile. Then git status. If don't see anything mentioning Procfile, you need to find remove the entry from local or global .gitignore.
I faced a similar issue while working on windows(haven't tested on other operating systems)and this worked fine for me.
Initially, I have created a file name procfile and pushed it to heroku. But, heroku expects the Procfile declaration. It is case sensitive. Hence, we should be careful while typing the filename also.
Even after changing the name to Procfile git didnt notice changes(maybe git is case-insensitive just like windows). Hence, I had to delete the file completly and had to create a new one with Procfile as the name of the file.
I had the same problem because I missed git add and git commit the file named Procfile .
You should try to use the command git status and review whether the Procfile is included.
When pushing to Heroku you must come up with something like shown in the Picture. If not your procfile has an Error.
The Procfile looks like this for my Flask app
web: gunicorn app:app
In my php project I can use
$ heroku ps:scale web=1
at the heroku directory "php-getting-started" (https://devcenter.heroku.com/articles/getting-started-with-php#prepare-the-app).
So I'm try to do this in my original application, so I tried to do again in Heroku Repository and it's work.
(sorry about the english, hehe)
I got the same problme,
1) I also configured ProcFile
but the problem still available
So used this
Remove the existing buildpacks with heroku buildpacks:clear and add them again in the right order using the heroku buildpacks:add with the --index option, making sure that the language buildpack is the last in the list
git commit --allow-empty -m "Adjust buildpacks on Heroku"
git push heroku master
Problem solved
I had a similar problem and tried the following:
Made sure Procfile does not have any extension
Procfile is spelled exactly as 'Procfile'
At the end of the day just realized that my Procfile was in my app directory. It should be on the root/project directory.

need to edit template of sitepackages on heroku

I am new to django and i just deployed my first django site on heroku.
Now my problem is that i have to change one line of code in a template installed through requirements.txt in pythons site-packages. Is there a way to upload that one file from my local environment to herokus environment and how could i find the folder structure of my site to upload the edited file?
I thought about making a pypi package but this seems to be too complicated for one line of codeā€¦
just run heroku run bash
cd /app/.heroku/python/lib/python2.7/site-packages
just one line but vi is not working on heroku so better follow this post and do ...

heroku django tutorial not working?

I'm trying to work through the "Getting Started with Django" heroku tutorial. Things are working when I run the framework locally with foreman, but when I try to run it on Heroku, it is failing when trying to find the settings module.
In a nutshell, I've done...
chris#xi:~: mkdir hero
chris#xi:~: cd hero
chris#xi:~/hero: django-startproject ku .
and then I create and edit the files per the instructions. Perhaps I have gotten something wrong?
in ~/hero, I created my Procfile and requirements.txt, as well as the ku directory that was created by django-admin
in ~/hero/ku I have settings.py and wsgi.py (created by django-admin and edited by me)
any idea what I'm not doing correctly?
found it after much trial end error. It turns out that I had an old .gitignore file in my home directory that ignored settings.py. Once I added settings.py to the project and re-pushed, everything started working.
I don't like putting settings.py into git because it contains machine-specific information, as well as security information. But I guess I will leave it for now, and when I have to do it for real, I can use the heroku config:set command to set up things like database users and passwords, or paths to DJANGO_SETTINGS_FILE, etc.