How do i fix this issue with django start project? - python

After I installed django i wrote the start project command to verify django is working or not.
i.e,
django-admin startproject mysite
cd mysite
python manage.py runserver
After that I got an IP address(http://127.0.0.1:8000/)
but when i link to this http://127.0.0.1:8000/, it is showing unable to connect. what should i do now?

Don't worry this is not a big issue!
As per your comment mentioned above, Run the python manage.py runserver then go to new instance of powershell and do other stuff what you want to try.
Let that runserver window isolated.

Related

Problems with manage.py in django

I am attempting to run a site from my localhost. What I did is I first cloned the repo and pull it into my local directory. Then, I changed the DB part to my DB settings. I have tried python manage.py runserver, python manage.py migrate and python manage.py makemigrations, but it still shows the same error.
error
I have tried different solutions found online, but they don't seem to work. I think the main problem is that I'm not sure where the problem is. I have tried creating a superuser, but it still shows the same error.

Why do I get "CommandError: App 'app_name' does not have migrations." when using Heroku?

So I have deployed my Django project to Heroku, and now trying to migrate the database. I have everything working fine in my local sever. Then I tried to run the commands in heroku, as below.
heroku run python manage.py makemigrations app_name'.
This worked fine.
Migrations for 'app_name':
contents\migrations\0001_initial.py
- Create model Book
- Create model Category
- Create model Content
Then of course, I tried : heroku run python manage.py migrate app_name.
But then I got this error CommandError: App 'app_name' does not have migrations.
I've done some research for possible issues, none of which were relevant to mine.
For example I do have __init__.py in the migrations folder inside app_name directory. Also, I've tried heroku run python manage.py migrate as well as heroku run python manage.py migrate app_name. I'm very confused. What do you think is the problem? Thanks in advance. :)
I had the same problem, I don't know why, but the following works for me (two commands in one line):
python manage.py makemigrations && python manage.py migrate app_name
As explained in heroku's help article Why are my file uploads missing/deleted?:
The Heroku filesystem is ephemeral - that means that any changes to
the filesystem whilst the dyno is running only last until that dyno is
shut down or restarted.
That is you do generate the migration files but they cease to exist shortly after when the app is reloaded.
In general the strategy you take is not a good approach to migrations as this can cause various issues, let's say you have multiple production servers each generates their own migrations this causes a conflict! In your situation suppose you do migrate this way and then later you want to add some new models this again will cause you problems.
One should always add their migrations to the version control (git, etc.) commit them and push them to production (here your heroku dyno). That is run python manage.py makemigrations locally, commit the generated migrations, push them and then run heroku run python manage.py migrate.

Terminal is stuck on python manage.py makemigrations and runserver

I am using Pycharm for django development, after adding some models to the models.py the terminal is stuck at python manage.py makemigrations command, runserver doesn't work also.
The terminal is freezing.
It was working perfectly, it did not work after the modification in models.py, I tried to delete the migration files but it didn't work, restart the computer didn't help.
Look at the pictures please.
Any ideas?
Thanks a lot
makemigrations
runserver
The same situation happened to me and I looked deeper at the models I had changed.
I just commented the fields i didn't want anymore, not removed, that was the problem. Try removing.
Maybe the command "python manage.py makemigrations" already ran and you just need to do a "python manage.py migrate".

How to run a Django project without a manage.py file?

I'm not experienced with Django. I just want to get this project running on a localhost (on Mac). Normally I run python manage.py runserver inside a virtualenv but I can't do that without a manage.py file! I must be doing something obviously wrong if this project has 264 GitHub stars.
https://github.com/shacker/django-todo
How can I make this work?
First, it's almost impossible to get a project running without manage.py not just because of the server but also the migrations..
Second, the django codes in the github link especially the todo folder is an app of a django project and you need to add that on your INSTALLED_APPS in your settings.py file
setup script is used to install whole project with required dependency packages, once you done with setup script installation then you can import that project into your local project
Goto Project directory and run below commands:
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
Finally u can see the project in the browser http://127.0.0.1:8000

Django: OperationalError at /admin/

So I ran my program based on from here and It worked without any error. I go to to /admin. I login. So far everything is good. Then when it loads I get this:
I checked the traceback (which is really long) and none of includes my code. It doesn't tell me what part of the code this error is occurring in so I don't know how to approach this. Please explain what this is, why this is happening, and how I can fix it.
If you need any part of my code, just ask in comments because I don't know where this is happening.
You need to run migrate command in-order to force django to create auth tables.
python manage.py migrate
Then for any change you made on models, don't forget to run these two commands.
python manage.py makemigrations
python manage.py migrate
Use pip install django==2.1.5
If the problem persists,
Use python manage.py migrate --run-syncdb
by default, the auth table is not created in the database
so first we need to create the table and reload the page
to achieve the same
make the migrations by typing the following command
1. python3 manage.py makemigrations
2. python3 manage.py migrate
Till the time they don't debug this issue with Django and Sqlite3 use the older versions of Django
You may consider using version 1.10.5(using command pip install --upgrade django==1.10.5)
yes, that was fault of django version ,when i installed django==2.1.5 that problem was solved.
Install latest django version
$ pip3 install django==2.2.8
$ python3 manage.py makemigrations
$ python manage.py migrate
then reload page in browser
this is the problem with migration just type the following command:-
python manage.py migrate
If you still get error after you lunched
python manage.py migrate
and for every change you made on models
python manage.py makemigrations
python manage.py migrate
Then check if you have Django version older than 2.1.5, because this latter version fixes a bug returning "OperationalError>no such table" when adding an object to your database as superuser.
So try to
pip install Django==2.1.5
However, you will have to re-write your project anew.
user permission
Hi
In Django Administration :check if the user has the right permission, it should work
use these commands
python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py runserver

Categories

Resources