Django / Anaconda - Can not start server - python

I made a new django project on a different machine (PC) in a conda enviroment. Now I copied the django project folder and created a new enviroment on the new PC with conda. I installed everything like on the "old" machine but however if I type python manage.py runserver it throws a message:
Image
Does someone know if something is missing or what can I do to run the django project on the new pc?
I have latest conda version 4.8.4, django version 3.0.3

As you make and migrate your migrations they have dependencies on other on other migration files. So, a migration with a dependency to the file in your error message cannot find that migrations file. This has likely happened while copying the project, maybe the file did not copy. If this is a development environment a quick fix would be to delete your local db file, as well as the migrations folder and then re-run makemigrations and migrate.
This could also be a multi app problem where you have a migration dependency to another app, and have not ran the migrations for said app.
django.db.migrations.exceptions.NodeNotFoundError
Django NodeNotFoundError during migration

Related

What to do with unapplied migrations in Django?

Currently I have converted my python 2 project into python 3 project & earlier I was using Django version 1.9.13 & now I have updated it to 2.2.6.
Now I am able to run my project in latest version of python and django but when I run my project in cmd I have found that It showing message like You have 253 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s)... so I have checked my migrations folder and able to find all migrations files there.
Any idea why I am getting such kind of message here & if it is bug then what should I do to get rid of such problem ?
Thanks.
You need to migrate those migrations to your database. This means you have changes in your model classes but they are not applied to the database you are using. To migrate to the database: in CMD
python manage.py makemigrations
python manage.py migrate
In both cases, make sure you are inside your virtualenv (if you have one) and using the right python. For instance, in most cases if you have multiple pythons installed (2 and 3); you might have to use 'python3' in the above commands.

Django 2.1 created migration with makemigrations did not show up in migrations folder

The migration process runs within a docker environment.
After running docker-compose run web python manage.py makemigrations terminal showed
Migrations for 'api_app':
api_app/migrations/0004_analysis_error.py
But the file didn't show up in the local directory. I ran docker-compose run web python manage.py migrate and it even showed:
Applying api_app.0004_analysis_error... OK
But still no api_app.0004_analysis_error.py in the local directory.
I also tried making an empty migration, the same behavior occurred.
I also tried removing the changes and resetting the migrations, no changes were detected (even though there were).
The application name has been included in the [INSTALLED_APP] module in settings.py.
The issue is similar to this:
Why am I unable to run django migrations via the 'docker-compose run web' command?
When running docker-compose run it created the migration file in the new container but not copied to local.
To grab the file out of the container:
Copying files from Docker container to host

Django admin site lost all its formatting

I change my computer and I migrated my django project just by copying the directory created by django-admin create project from the old computer to the new one. I installed all required modules in the new computer (including django) under a new Python virtual environment, and everything worked perfectly, but the admin site of the project, that shows in plain html with no styling at all.
I don't know how to fix it
This happened to me when I transferred the project to the production server for the first time. I don't know if you are using runserver or is your new computer hosting the project with Apache or Nginx. If it is the latter try the following command on the project root directory.
python manage.py collectstatic
Beware that you also need to specify the STATIC_ROOT and STATICFILES_DIRS in the settings.py file in order for the above command to work.
Refer to the django docs in order to learn more about working with static files in Django.

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

Running old django app in new virtual environment

I have a django app i was running in python 2.7 and django 1.7.10.However am trying to transition it to django 1.8. I have created a new virtualenv,installed python2.7 and django 1.8 in it and moved the app there.However when i run the server it still reads django 1.7.10.What could be the problem ?
console
enter image description here
You do not need to move application for new virtual environment you just need to activate it probably you did not activate new one. Actually also you do not need a new virtual environment for upgrade. Just pip install -U django==1.8 it will upgrade your django and then make necessary edits.

Categories

Resources