unable to install django restframework.auth_token - django

Trying to install from source
git clone https://github.com/tomchristie/django-rest-framework.git
cd django-rest-framework
setup.py install
settings.py
INSTALLED_APPS = (
...
'rest_framework.authtoken',
'rest_framework',
...
)
Trying to migrate
manage.py migrate
WindowsError: [Error 3] The system cannot find the path specified:
'C:\\Python27\\lib\\site-packages\\djangorestframework-3.0.0-py2.7.egg\\rest_framework\\authtoken\\migrations/*.*'
Whats the problem here ? Why is this a windows error ?
(rest_framework is migrating just fine ... )
Thanks.

I ended up copying the actual folder i cloned into c:\Python27\lin\sitepackages and renamed it to ...*.egg. It worked.

Related

No module named 'mysite.settings'

I know this question has been asked quite a lot but all the solutions given do not seem to fit for me.
I run this in a venv with python 3.6.8 and django 2.2.10
When I run django from cli it works and all functionality is working great so I know it is not django itself that is failing me.
Path to wsgi script is "/opt/sites/aws/okta/wsgi.py"
Actual wsgi.py:
import os, sys
sys.path.append('/opt/sites/aws')
#path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#sys.path.append(path)
print(sys.path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "okta.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
When running python to see what errors it gives I get
ModuleNotFoundError: No module named 'okta.settings'
I get the same error when running apache with debug logging.
I have quadruple checked the path and the environment variables and they are set right in the wsgi.py script.
Asked for the INSTALLED_APPS
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'okta_oauth2.apps.OktaOauth2Config',
'ops.apps.OpsConfig'
]
aws/
bin/
lib/
lib64/
logs/
okta/
__init__.py
urls.py
settings.py
wsgi.py
okta_oauth2/
ops/
share/
static/
manage.py
pyvenv.cfg
Although I did not figure out what was wrong. This is what I did to resolve.
Note for anyone reading this in the future, please DO NOT do this first. I tried other more common results like ImportError: No module named mysite.settings (Django) to fix the issue first and when none worked I tried this.
cd /opt/sites #Just outside the venv
sudo service httpd stop # stop web server
mv aws aws_broken_20201223 # move your broken env to a new name but do not delete
python3 -m venv aws #create new venv
cp -R aws_broken_20201223/(django dirs) aws/ #copy all the custom apps and project you have to the new folder
cd aws #go to the new install
bin/activate #activate your env
pip 3 install -r requirements.txt # I had a predefined requirements.txt for all mods I needed. I would suggest you do the same before doing this.
python3 okta/wsgi.py # Test to see if you are still getting the not found error
sudo service httpd start # start web server back up
voila it works without issue, no config change at all. Very strange but I'll take a working production site then a broken one.

ModuleNotFoundError: No module named 'rest_framework'

I'm trying to follow a tutorial on DRF, but when I'm about to run "migrate" for the database, i get
ModuleNotFoundError: No module named 'rest_framework'.
As PyCharm hints, the same also applies to django_summernote and djoser I have there.
I know there are some threads like this, but nothing from those seems to help - the Python console DOES recognize these modules, and they are added through INSTALLED_APPS
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'kursovik.apps.KursovikConfig',
'rest_framework',
'rest_framework.authtoken',
'django_summernote',
'djoser',
'kursovik']
I recently downloaded these through
pip install djangorestframework
pip install djoser
pip install django-summernote
do i need to reinstall them?
You have to ensure that your PyCharm console uses the correct Python Path where the packages are available basically so to say.
Go to File/Settings/YourProject and check for the following:
Set the correct path to make the packages available for interpretation procedures.
If you have already install restframework but still encounter this issue, try this method, this is to install rest in you venv
In your project folder (by sys.executable to find)
In command line:
1)source bin/activate
(then start to install rest framework)
2)pip install djangorestframework
3)deactive
then restart pycharm.

What causes "Unknown command: 'mkmigrations'" in Django?

When attempting to view my Django app while being served locally I am encountering this error:
A server error occurred. Please contact the administrator.
It remains that way even when debug is false. The console shows:
django.core.exceptions.ImproperlyConfigured: Module "django.contrib.auth.
are" does not define a "SessionAuthenticationMiddleware" attribute/class
and searching around I came across the suggestion to comment out
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
# 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
This does indeed fix the problem, in that the app does display, however when I go to the admin panel I get the message:
Site administration
You don't have permission to edit anything.
I figured I would just try and roll back to the last commit before I pushed the app to heroku and ran:
git reset --hard 'appropriate commit'
This did not seem to do anything at all. I still have the same situation as previously. Furthermore running:
python manage.py makemigrations
or
python manage.py migrate
results in
Unknown command: 'makemigrations'
Type 'manage.py help' for usage.
and
Unknown command: 'migrate'
Type 'manage.py help' for usage.
Previously both of these commands worked just fine.
If it helps, I was trying to install addthis to the app when things started breaking. Also after the git reset when I type git status I get:
Untracked files:
blog/migrations/0005_join_ip_address.py
blog/migrations/0006_auto_20150318_1716.py
blog/migrations/0007_remove_join_ip_address.py
no changes added to commit (use "git add" and/or "git commit -a")
Other details:
Django 1.6.5
Python 3.4.1 |Anaconda 2.1.0
Using a Virtualenv
Any help would be massively appreciated.
As others have noticed, your Django version should be 1.7; this is caused by your installation of django-addthis.
The current version of django-addthis explicitly states Django<=1.6.5 as a dependency. For some reason, this prompts pip to downgrade your installation:
$ pip install django-addthis
Downloading/unpacking django-addthis
Downloading django-addthis-2.0.0.tar.gz
Running setup.py (path:...) egg_info for package django-addthis
Downloading/unpacking Django>=1.4,<=1.6.5 (from django-addthis)
Downloading Django-1.6.5-py2.py3-none-any.whl (6.7MB): 6.7MB downloaded
Installing collected packages: django-addthis, Django
Running setup.py install for django-addthis
Found existing installation: Django 1.7.5
Uninstalling Django:
Successfully uninstalled Django
Successfully installed django-addthis Django
The last four lines show what happened when I tried this on one of my own Django 1.7 projects. pip happily downgrades your Django app. And since virtualenv dependencies are usually not stored in Git, you won't see this when you do a git status.
The only solution is to uninstall django-addthis and reinstall the correct Django version:
$ pip uninstall django-addthis && pip install --upgrade -r requirements.txt
You are running a Django 1.7 project against an installed version of 1.6. Upgrade your Django installation.

django.core.exceptions.ImproperlyConfigured:constance.backends.database app isn't installed correctly

Hi I am setting up my django with virtualenv
When I run python manage.py migrate, I got this error.
File "/Users/anh/testRadicards/env/lib/python2.7/site- packages/constance/backends/database/init.py", line 27, in init
"The constance.backends.database app isn't installed "
django.core.exceptions.ImproperlyConfigured: The constance.backends.database app isn't installed correctly. Make sure it's in your INSTALLED_APPS setting.
This is my setup, running with Mac OSX 10.5, on Python 2.7:
1. cd into my project dir
2. run virtualenv --no-site-packages env
3. activate my virtualenv with source/env/bin/activate
4. pip install django (currently 1.7.1)
5. git clone a django project repo called radicards
6. cd into radicards
7. run python.manage.py runserver
(The repo radicards already have a sqlite db setup, so there's no need for migration).
I followed the error code and open settings.py and it include this:
INSTALLED_APPS = (
'constance',
'constance.backends.database',
'rd_suit',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'paintstore',
'cards',
)
'Contance.backends.database' is included. I heard django 1.7 has some issues with unique name error.
What should I do? To set this up.
Try adding this setting to your settings.py file:
CONSTANCE_BACKEND = 'constance.backends.database.DatabaseBackend'

Problems with django-extensions

I install django-extensions like that:
git clone git://github.com/django-extensions/django-extensions.git
cd django-extensions
python setup.py install
Then I go to my project folder and use:
./manage.py graph_models -a -g -o my_project_visualized.png
Whats returns:
Unknown command: 'graph_models'
Type 'manage.py help' for usage.
I try "help" - all of that commands I know, but how can I fix the problem with graph_models?
Since you haven't mention it. I assume you're missing the INSTALLED_APPS step:
settings.py:
INSTALLED_APPS = (
...
'django_extensions',
)
Is's not mentioned on the GitHub site, but it is mentioned on the documentation.
And of course:
pip install django_extensions
And add it to the requirements if you have any
For me, it still didn't work then. I found out that I had to re-activate the environment (workon env_name). Then it worked.