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

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.

Related

Unable to create super user in django on my online server

Inside the cpanel -> python app i have tried several time to create super user. when I tried to execute this commad inside Execute python script
manage.py createsuperuser
then it will return this error
Superuser creation skipped due to not running in a TTY. You can run `manage.py createsuperuser` in your project to create one manually.
How to solve this problem, or any manuall solution, i found several solution but all the solution for local server.
There is no difference between creating superuser on local server and production server. You have to do next:
Enter your server via ssh.
Go to your project root folder (with manage.py file)
Type python manage.py createsuperuser (use your virtual environment or system interpreter, depends on).

unable to track migration in subfolders in django

in Django when I am running this command python 'manage.py makemigrations Planning' it is saying no change detect and it also not creating any pycache folder in that subfolder.
but when I am creating the model in another subfolder on which I had worked in past then it works properly, I am unable to understand what's going on. please healp

Django: Heroku deploy not migrating properly

I'm new to Heroku and I am trying to do my first deploy with a change in my models. Now I already have some important stuff in my app's database that I don't want to lose (I'm using PostgresSQL).
Anyway, I did those few improvement to my app's model and it works alright locally, but when I try to deploy it just gives me the
Internal Server Error: /lares/
ProgrammingError at /lares/
column lares_imovel.referencia does not exist
I am used to throwing makemigrations and migrate locally and than just git push heroku master
Anyway, I also tried the heroku run python manage.py migrate afterwards, but I get the same result every time.
I deleted all my migrations files and created them again for this particular app, still it works locally and the issue remains on production.
Do you guys have any idea why this is happening?
I don't know if any of my code is necessary, I'm pretty sure the problem is not there, but if requested I can post it here.
Thanks!

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,

heroku - DatabaseError: relation "south_migrationhistory" does not exist

i purchased an outsource service to develop a web site in django to be deployed in heroku and AWS S3 (boto package).
Unfortunately the developer did not comment the code, despite it was asked, and left the project uncompleted for following up with a bigger client.
I've hired another django 'expert' to fix a part which was not developed, and he want to (over)charge for deployment testing, which i think should be a normal matter for good practices! i am working on my own budject, and need to work it out myself.
I was able to make the project run locally and make myself the frontend templates which were not fully developed, but I am having issues in deploying the code on my own staging environment.
I set up a staging environment under my credential to check if everything is ok, before pushing to production.
I think I almost get there, though:
heroku run python manage.py migrate --all --noinput --app my-app-staging
generate in the console:
Running `python manage.py migrate --all --noinput` attached to terminal... up, run.4833
DatabaseError: relation "south_migrationhistory" does not exist
LINE 1: ...gration", "south_migrationhistory"."applied" FROM "south_mig...
In the browser:
DatabaseError at /
relation "django_site" does not exist
LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...
^
Request Method: GET
Request URL: http://my-app-staging.herokuapp.com/
Django Version: 1.5.6
Exception Type: DatabaseError
Exception Value:
relation "django_site" does not exist
LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...
^
Exception Location: /app/.heroku/python/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py in execute, line 5
I checked my settings and they look ok:
i check AWS S3 bucket and it is able to write there;
settings in heroku console display that the db has been created.
I followed:
Heroku created table but when I'll migrate, he says that doesn't created
but it looks my locals.py are ok too, and in my local git branch .gitignore will exclude db.sqlite
My git and heroku ssh keys have been generated and added, so i dont' think it is an issue of authentification.
How could i check that the db is properly connected to django project and I am not invalidated?
Could you please help in debriefing to understand what this error means and how to solve it?
So much thank you.
It sounds like you might not have created the initial South migration tables on your staging server. This is actually done using syncdb:
Once South is added in, you’ll need to run ./manage.py syncdb to make the South migration-tracking tables (South doesn’t use migrations for its own models, for various reasons).
To run this on Heroku, you'll probably want to use something like
heroku run python manage.py syncdb
Once this is done, you should be able to move forward with the South commands.