Django - Built project broken - python

So basically, I have a DJANGO project that can be executed and work well. And I don't know why (maybe I upgrade my django or sth) that this is no longer working.
First I try "python3 manage.py runserver" I get this from console:
So I try to collect the static file with "python3 manage.py collectstatic"
And I do have "ckeditor" in my static folder
And I'm sure that my project is work because it still online somewhere.
And notice 1 thing that in the project that my "manage.py" is not turning red. like this
I know its just UI behavior but it seems that the project is broken. Anyone has idea bout it?

It seems to me that you've got a python dependency problem. You've probably added django ckeditor in your INSTALLED_APPS settings, but it's not installed in your (virtual) env.
So have you installed django ckeditor using pip ? It's not related to the static folders or anything, they're not compile time errors. They are 404s.

Related

Pycharm can't find Django app 'users' when running tests

I was handed a project which uses Django and Docker, but when I run Django tests Pycharm always seems to have problem finding the users application. Other people in the project have it running without problems but even though we tried to copy their settings, it wouldn't work. I also downgraded to their exact Pycharm version without success. What could be wrong?
I have Docker desktop running without any problem. It's able to create containers and all that. I've also included it in Pycharm with success.
I've also created an interpreter through Docker-compose with a valid .yml file. This file is my colleagues.
I've of course added it as my project interpreter.
I've set up a Django test configuration with appropriate interpreter and with an empty target field so that all applications in INSTALLED_APPS are run, as per documentation.
Still, the module 'users' cannot be found. Passing in DJANGO_SETTINGS_MODULE=config.settings.local to the test configuration yields the same error.
However, when I run from the terminal, all works as expected.
What might be the problem here?
I was using the modern django setup (generated from cookiecutter-django) which Pycharm seems to have trouble with. By right-clicking the folder and choosing "Mark directory as" and marking my project directory as "Sources Root" (i.e. the project/project folder), Pycharm was able to run it properly.
Did you try unchecking options related to PYTHONPATH in your run configuration?
It may override your modules path and cause such mess with finding them.

PyCharm 4.5.3 Django manage.py task not working after update

After upgrading 4.5.3 my Tools->Run manage.py task no longer works. Clicking on the link does nothing. No window pops up. Going to "Python Console" does not work, same thing, nothing happens.
Going to Django in "Languages and Frameworks" and deselecting django allows the "python console" to properly work as a python interpreter. Reselecting Django reproduces the above results.
Settings for Django:
Django Project Root is the same folder which contains manage.py
Settings is my settings file
Manage script is manage.py
Settings for Django Console:
proper python interpreter
working directory is the same directory where manage.py is.
Project runs fine
Again, it all worked fine, updated to 4.5.3, and it stopped working. Any ideas?
Other issues, caused by the same thing, is that my test configuration doesn't run.
Edit: youtrack.jetbrains.com/issue/PY-16434 - Added
Edit: It's a bug, being fixed
For version 4.5.3 only. The issue is with the Django Settings file, in TEMPLATES. It's a bug with the DIRS of TEMPLATES. See bug report. I commented out the TEMPLATES and it worked for me.

Django South Error: "there is no enabled application matching 'myapp'"

So, I finally gave in and grabbed South. The problem is, every time I try to follow the tutorial and run
"python manage.py schemamigration myapp --initial"
I get an error
"There is no enabled application matching 'myapp'"
--Things I have tried--
I have tripple checked my settings file, running Import South from the django shell returns no errors, and I have added manage.py containing folder to PYTHONPATH, as well as wsgi.py and settings.py.
I have run python manage.py and python C:\path\to\manage.py variants, even went into my python directory and verified that south was in the site-packages folder. syncdb runs fine, ending with "not synced (use migrations)". python manage.py migrate runs without returning errors but otherwise seems to have no effect. I have tried running the said command both before and after running syncdb, which has no effect on the outcome.
--Other potentially pertinent info--
Django 1.5.1, Python 2.7, no other external apps used, Windows 7 64 bit, python is added to the windows path, South installed via python setup.py install command. Installation completed successfully. I do not use a virtualenv, and would really prefer to avoid this as it would mean alot of refactoring of this current project's setup and wasted time. I plan to move to a virtualenv setup in the future, but not now.
What's going on? How do I fix this? Net searches revealed no good info at all, I am completely at a loss...
This error can be misleading: it is thrown not when South tries to import the app, but when it tries to get the app's models module.
perhaps it cannot import the application (because you didn't add its name to INSTALLED_APPS)
perhaps it cannot import the models module, because the file models.py does not exist, or because the directory models/ does not contain an __init__.py.
South doesn't import the models module itself. Instead, it leaves that job to django.db.models.get_app('app_of_interest'), which according to its docstring "Returns the module containing the models for the given app_label." The error message raised by get_app is, in fact, different depending on whether it failed to import the app or the model, but both exceptions are ImproperlyConfigured, and the schemamigrations script doesn't look any deeper than that.
Because South says it is accepting security updates only (it entered end-of-life with Django 1.7's migration feature), I'm not submitting a fix to its codebase, but instead documenting the problem here.
migrations exist on a per-app basis. each app may or may not have its own migrations, but you need to create them for each app where you want to use them. (often all apps)
./manage.py migrate is a shortcut that runs migrations for all apps
Check once whether you have included the app name in INSTALLED_APPS in settings.py

Django Error: Could not import settings 'interfaces.settings'

So, I'm fairly new to programming. I have relatively little background in django and don't understand much of its implementation. However I have read through django tutorials and have a basic understanding of the underlying structure.
So currently I am not actually modifying the django project being used by the server (lets call it /main), I think my coworker copied over the project to a new directory called /test. When I try to do anything with manage.py located in the /test directory by running
python2.4 manage.py runserver
I get an error saying
Django Error: Could not import settings 'interfaces.settings'
(Is it on sys.path? Does it have syntax errors?): No module named settings.
I've looked through the settings file and have tried changing main to test, but it hasn't changed anything.
Any guidance as to where I should look for a solution would be great.
Also?
It sounds like there is something hard-coded somewhere which expects the project to be in a directory called "interfaces", rather than "test". Try running manage.py shell --settings=settings, and see if that helps.
Actually, "also", you should not be editing code on the server, even if it's in a different directory to the production deployment. Install Django and the code on your local machine, and edit there.
The manage.py shell --settings=settings worked for me. I figured out from running django-admin.py runserver that settings could not be imported, because environment variable DJANGO_SETTINGS_MODULE was undefined.
Fix: export DJANGO_SETTINGS_MODULE=settings
I ran the command from the root of the project (same directory that had manage.py -- not sure if it matters). Then, running manage.py shell worked without the --settings=settings bit.
Cheers!
Try to undestand which versions of python you have installed.
Type python2 and press tab button in console.
It looks, that you are trying to run version of python, which has not django installed in libs.
Also try to run python2.4 in interactive mode from test folder and import settings.

Why is django giving error: no module named django.core?

I get the error in question when I attempt to create a project. I followed the instructions found at how to install python an django in windows vista.
Also make sure that you have permission to access all of django's files. I've seen these kinds of errors happen because of permissions issues before.
EDIT: I haven't tried it out, but there's a link on that page to Instant Django, which looks like a pretty easy to set up.
You can get around this problem by providing the full path to your django-admin.py file
python c:\python25\scripts\django-admin.py startproject mysite
Most likely you don't have Django on your Python path. To test, quickly fire up Python and run:
>>> import django
If that fails, it's just a matter of getting Django onto your Python path. Either you set the environment variable, or you move django into your python2x/Lib/site-packages directory. If it does work, try importing core. If that fails there, then something is probably wrong with your Django install.
From your command line (cmd) run "ftype Python.File" and make sure that your .py files are being executed by the correct version/installation of Python.
It's possible another application has surreptitiously changed this under the hood.

Categories

Resources