I'm trying to customize Django admin site. I ran the command "pip install django-suit", everything installed correctly according to CMD, then I made a new .py file called with apps.py in the main folder(same folder that contains settings.py) and here is the code
from suit.apps import DjangoSuitConfig
class SuitConfig(DjangoSuitConfig):
layout = 'horizontal'
and added 'database.apps.SuitConfig',in the settings.py. When I type the command "python manage.py makemigrations database" or "python manage.py runserver" the CMD gives me this error
Does anyone know what am I missing?
My Django version = 2.0.7
If you installed django-suit using pip install django-suit, you installed v0.2.26, and then this whole installation you're doing is wrong. This is how to install in your Django project: Getting started docs. Note that v0.2.26 does introduce support for Django 2.0 so it should work.
If you want to use the v2 (which is not stable and currently still just a development branch), you should use a different source for pip install:
pip uninstall django-suit
pip install https://github.com/darklow/django-suit/tarball/v2
Then you can do as you mention in your question, by subclassing DjangoSuitConfig and adding the new class to your INSTALLED_APPS.
Related
I want to see the django version in my Pycharm terminal, but I don't get the correct method.
I tried bellow methods in pycharm terminal:
1) django --version and django version
2) import django, and print the version by:
import django
print django.VERSION
But I still can not get it.
If you cannot print the Django version from the python console in Pycharm, go to settings>Project:project_name>project Interpreter and from the list of installed packages see the installed Django and it's version for that project.
You can run pip freeze too. Just filtering the results with grep...
pip freeze | grep Django
You're trying to access a version attribute, but you can find out Django's version using the get_version method:
import django
django.get_version()
In the terminal you can use bellow command to check the version of django:
python -m django --version
If you want to use your second method, just like this bellow command:
python -c "import django; print(django.VERSION)"
(1, 11, 2, u'final', 0)
go to setting > project > project Interpreter and install Django package
then run the code
import django
print(django.get_version())
Run pip freeze > requirements.txt
A .txt file with that name will be created automatically, open the file and check for the django version and other previously installed libraries.
I do not know about pychram but the most efficient way to query the django version without importing django globally would be this:
from django import VERSION as DJANGO_VERSION
if DJANGO_VERSION >= (2, 0):
pass
What was not proposed in this question which is something similar:
How to check Django version
I had the same question. The solution is simple.
Just create a project, open settings.py file and observe the first comment lines. You will see the version info in there as displayed below:
Image of settings.py that shows the Django version
I found the solution here.
Simplest is
import django
print(django.get_version())
Using the following command on terminal will give you django version
python -m django --version
Or
You can go to the interactive python prompt and use the command
import django
print(django.get_version())
or using pip freeze and grep you can also get the django version
pip freeze | grep Django
I am currently setting up Django on my Windows 10 system and after having installed it successfully, I am now facing an error message when trying to start a new Django project.
I have created a new directory for my project, gone to the command line and changed the directory to this new folder path and then typed the command:
django-admin.py startproject mysite
but I get a pop up window with the error message:
"Still can't get my hands on win32ui"
As I understand it, win32ui is a module contained within pywin32 - so I have gone and checked that pywin32 is correctly installed on my laptop - which it is as:
pip install pywin32
results in:
Requirement already satisfied (use --upgrade to upgrade): pywin32 in c:\python27\lib\site-packages
I've searched Google and StackOverflow but there isn't a single hit for this error message in relation to new Django projects.
Could anyone shed some light on how I can successfully get a new Django project set up?
According to here, to install pywin32 system files, run python.exe Scripts\pywin32_postinstall.py -install from an elevated command prompt.
For example, this works for me: "C:\Programs\Python\Python3\CPython\x64\Python35\python.exe" "C:\Programs\Python\Python3\CPython\x64\Python35\Scripts\pywin32_postinstall.py" -install.
It looks like Python can't properly locate the libraries you're trying to import. Doing a clean python install may solve the issue. However, instead of doing that, you could try the following:
I've seen this problem happen before when a python installation failed to copy pywintypes27.dll and pythoncom27.dll to the win32 folder, please try doing this:
Go to C:\Python27\Lib\site-packages\pywin32_system32
Copy pywintypes27.dll and pythoncom27.dll
Paste them in C:\Python27\Lib\site-packages\win32
For future reference, if this works, how did you install Python?
I've just started looking into python and django.. Im pretty sure ive successfull installed both python and the django framework and i managed to add python and django-admin.py to my system path but now when i run the command django-admin.py startproject My_Test_Site, in the folder i want to create a new project directory in (just following the tutorials), i get the following error:
What am i doing wrong?
This is not a Django error. It appears it cannot find the Python module unicodedata which is part of the Python Standard Library (docs). I see that there is also a bug report about this issue (Python 2.7 on Windows, see here). On the other hand, some people there report that reinstalling their Python installation fixed the problem. You could give that a try.
notice the last line, it says import unicodedata, importError
im guessing you probably didnt install your django properly.
so reinstall it and check that django is in your "path", i believe django does this automatically when it installs but doesnt hurt to double check.
if reinstalling django still doesn't work, i suggest you uninstall python and django related stuff.
then install python, install pip, then use pip install django.
I am using Ubuntu with Python and Django already installed.
I installed django-userena by pip.
The docs at django-userena.org say to add 'userena', 'guardian', 'easy_thumbnails' to the INSTALLED_APPS in the setting files, but, after doing so, when I try to run the server it gives an import error, "no module named userena"
I also tried importing userena in the Python shell, but it gives an error too.
INSTALLATION : http://docs.django-userena.org/en/latest/installation.html#required-settings
Super simple question: I went through the "getting start" doc for haystack (using whoosh; I installed both python-whoosh and haystack using pip (first time using it)), and I simply cannot run python manage.py rebuild_index. I get this error:
python manage.py rebuild_index
Unknown command: 'rebuild_index'
Type 'manage.py help' for usage
I do have 'haystack' listed in my INSTALLED_APPS in settings.py, so this solution doesn't seem to work for me. I also don't get import errors when I run "import haystack" so it does exist. I tried this on my existing project as well as a brand new object made just for this and I just can't get it to work.
However, when I import haystack after python manage.py shell and try haystack.__version__ I get "AttributeError: 'module' object has no attribute 'version'". I get a similar error if I try haystack.management: it has no management attribute.
It must be something super simple I'm missing. Thank you for reading this!
Did you perhaps install the wrong thing? This (embarrassingly) happend to me just today. Make sure you install 'django-haystack' and not just 'haystack' (and you will have to remove 'haystack', since it conflicts with 'django-haystack').
Do you have the path to haystack in your Python path? (Either the PYTHONPATH shell variable or the sys.path Python list.)
Did you run python manage.py syncdb?
Does python manage.py shell followed by import haystack work?
After import haystack, what do you get for haystack.__version__?
In the same shell, type the following. Do you get errors for any of them?
haystack.management.commands
haystack.management.commands.rebuild_index
haystack.management.commands.rebuild_index.Command.help
I had the same error that you did, and fixed it by removing the old .egg and installing directly from the latest version. You can use easy_install:
easy_install https://github.com/toastdriven/django-haystack/zipball/v1.2.4
Hope this helps!
I had the same problem - for whatever reason, the haystack version in pip is quite old and obsolete (v 0.6 as of today). To use django-haystack check out the v1. source.
It compiles and installs simply with
python setup.py build
python setup.py install
Hope that helps!
I just had the same problem and hadn't set HAYSTACK_SITECONF in my settings.py.
Instead of using python manage.py rebuild_index try using ./manage.py rebuild_index
just do
pip uninstall haystack and
pip install django-haystack