How to fix this error in geonode - django

when we run this command :
:/usr/local/lib/python2.7/dist-packages/geonode/locale/si/LC_MESSAGES# geonode makemessages --all
Get this error message :
CommandError: This script should be run from the Django Git tree or
your project or app tree. If you did indeed run it from the Git
checkout or your project or application, maybe you are just missing
the conf/locale (in the django tree) or locale (for project and
application) directory? It is not created automatically, you have to
create it by hand if you want to enable i18n for your project or
application.
could you please help for me to solve this problem...

Related

Pyinstaller is unable to import custom commands of Django 2.1.5

I am using PyInstaller for creating build for my project on ubuntu machine.
I have written one custom commands createsappsuperuser in django to create sime special users. To create the executable file, I am running my manage.spec file and the executable is getting created successfully. The location of that executable is in dist folder.
After that I am running ./dist/manage createsappsuperuser which gives error like -
Unknown command: 'createsappsuperuser'. Did you mean createsuperuser?
Type 'manage help' for usage.
To solve the above issue, I tried adding my cusom command in the dict
in Pyinstaller/loader/rthooks/pyi_rth_django.py file as because pyi_rth_django.py always return some static set of commands.
I have added it like 'createsappsuperuser': 'idmgmt' in the dictionary. Here, idmgmt is my app name.
But the above solutions was valid for upto Django 1.8, and even the file "pyi_rth_django.py" says that it is tested with Django 1.8.
Then how should i do it in Django 2.1.5 ?
Thanks In Advance

How can I get PyCharm to use the Vagrant Directories rather than my development machines?

When I try to run my Django app via PyCharm inside of Vagrant, it sends my Windows Path over SSH which then provides an error in the shell:
> ssh://vagrant#127.0.0.1:2200/usr/bin/python -u C:/Projects/dev_project/dev/manage.py runserver 0.0.0.0:8000
bash: line 0: cd:
C:/Projects/dev_project/dev: No such
file or directory /usr/bin/python: can't open file
'C:/Projects/dev_project/dev/manage.py':
[Errno 2] No such file or directory
I created a Python Project in PyCharm (and instantiated a Django Project in a sub-folder) in order to incorporate Vagrant.
dev_project (PyCharm project root)
|--.vagrant
|--dev (Django project root)
|--dev
|--app
|--manage.py
|--Vagrantfile
In Settings
I enabled Django Support (providing the Windows Paths as there is no other option) in Settings > Languages & Frameworks > Django.
The Vagrant Python Interpreter is selected as the Project Interpreter (and Django Console & Python Console)
In Run Configurations
My host is 0.0.0.0 and port is 8000
My Python Interpreter is the Vagrant Environment. I am also adding the Content Roots & Source Roots to the Python Path.
The bizarre problem is it was working fine, and then I exited out and it broke again. Also, I do not have 'Working Directory' explicitly defined anywhere.
This blog article showed me my issue, as I did not have my Path Mappings setup within my Run Configuration.
From the Article (Configure Your Project to Use the Correct Interpreter):
Select Run->Edit Configurations…
Select the configuration on the right PyCharm created for us. In my case it was called “session_tracker”.
Change “Python interpreter” to our newly created one.
A new field will appear. Click the button next to “Path mappings”. A new window will appear to let you create your mappings.
Vagrant shares a local directory with the VM. My Vagrant file is configured so a folder is called “django_shared” in our [VagrantFolder] locally, and “django_shared” in the home directory on the VM are the same. You need to enter the full paths of each of those in the “Edit Path Mappings” window. - Click the + button to create a new mapping, then enter the values for the mapping on each side.
When no other option works I do the following:
Create seperate virtualenv in my local directory
Reconfigure PyCharm to use the interpreter in that venv
Restart PyCharm
Maybe not a very good solution, but works.

django-admin.py startproject returns CommandError

I've just installed django and I'm having trouble creating a project.
Running django-admin.py startproject test_project returns:
CommandError: '/usr/local/mysql-5.6.13-osx10.7-x86_64/docs/test_project' already exists
I also looked in the path above and there is no test_project folder.
Anybody come across this one?
EDIT
I restarted the terminal and tried again. The error has disappears but it doesn't seem to be creating the test_project folder on my desktop.
You seem to have found your solution through gersande's comment (update your question if you haven't with the new problem); so I'm just going to formalize it here:
I restarted the terminal and tried again. The error has disappears but it doesn't seem to be creating the test_project folder on my desktop.
I'm not sure why restarting the terminal helped (and it's probably a heisenbug), but I do notice an incongruence in your question: you've (seemingly, as the command isn't outputting any errors; but you could confirm by checking if running echo $? is 0 right after) created you new Django project directory in /usr/local/mysql-5.6.13-osx10.7-x86_64/docs/, but you seem to be looking for it on your Desktop (which is mapped to a different folder, probably ~/Desktop.
Simply navigate to the above path in your file explorer, or run cd <directory> to view it in your terminal.

Cannot start any django app

I am a newbie at Django and everytime I try to run
python panel/manage.py startapp %app% (panel is my project) it gives me the error:
Error: '%app%' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.
Am I doing something wrong?
Surely companies or contacts or stats is not the name of an existing Python module?
This is a fun one - your project and your app need to have different names. You probably created a project, then tried to startapp with the same name.
I was confused as well, until I realized that a Django project is a container for applications; this sequence makes it a bit clearer:
# first create a Project (container).
django-admin.py startproject Project
# create multiple apps
cd Project
python manage.py startapp polls
python manage.py startapp hello
...
Perhaps you need to
cd panel
python manage.py startapp yourappname
I'm not sure running the command from a directory above your project will work properly.
I had the same issue because I was trying to "restart" my app after carrying out changes, but startapp is meant to be used once to create a new app. To view changes, syncronize app with DB with python manage.py migrate and restart the server with python manage.py runserver instead.
From the django-admin docs
(manage.py does essentially the same thing as django-admin)
startapp <app_label> [destination]
django-admin startapp
Creates a Django app directory structure for
the given app name in the current directory or the given destination.
By default the directory created contains a models.py file and other
app template files. (See the source for more details.) If only the app
name is given, the app directory will be created in the current
working directory.
If the optional destination is provided, Django will use that existing
directory rather than creating a new one. You can use ‘.’ to denote
the current working directory.
For example:
django-admin startapp myapp /Users/jezdez/Code/myapp
This message is displayed if you run "startapp" twice with the same app name. As pointed out above by the OP it doesn't reload the app, it creates one.
You should choose different names for your project and app in Codes:
django-admin startproject **my_project**
python manage.py startapp **my_app**
You need to create the directory before using the commands. Suppose you want a polls app inside apps folder.
mkdir apps apps/polls
python manage.py startapp polls apps/polls
I guess maybe you have already created the app's dir in panel dir manually. The command 'startapp' is to create an app automatically. If you already have one there, it fails.
I reproduced the issue and there's actually something not working as I expected.
I wonder if we stumbled upon a Django's bug, or a limitation that I don't understand.
Having a project called "project" and an empty folder app/newapp
…I tried:
python manage.py startapp newapp apps/newapp
It returns:
CommandError: 'newapp' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.
But if I target ANY other route in which the last folder is not called the same name as the app I'm starting, it works.
So I ended up doing:
python manage.py startapp newapp apps/main
Using Django 2.1.3.
if you want to make an empty directory that will contain your new app
project-dir
└── blog
├── __init__.py
├── ...
├── blog-ext #this empty dir that will contain the new app
└── views.py
so instead of typing :
python manage.py newapp blog/blog-ext
it should be :
django-admin startapp newapp blog/blog-ext
Try classic "mysite" or "myproject". You can delete it anytime you want, so if it will accepted, then all your privious ideas conflict with Python modules.
Edit: I tried all your ideas, there was no error for me. So, if you installed support libraries or modules for django, then some of them can contains such names.
this error is because of the name conflicts between the app name and project name.you had given same name for your app and project .your project and app need to be different name .if you had given the same name the above mentioned error will occur .
understand the difference between app and project
Projects vs. apps
What’s the difference between a project and an app? An app is a Web application that does something – e.g., a Weblog system, a database of public records or a simple poll app. A project is a collection of configuration and apps for a particular Web site. A project can contain multiple apps. An app can be in multiple projects.
first create the project.
then create the app.
NOTE: name for app and project should be different
first create a project with projectname
django-admin.py startproject Projectname .
Then create app with appname. (to create your app make sure you are in the same directory manage.py and type this command)
python manage.py startapp Appname
It's the process how I got my doubt clear.
First, I created a directory inside my project directory and put __init__.py, models.py, admin.py, apps.py & views.py.
Then I ran python manage.py runserver & It work well.
Then as suggested on that page I used startapp command. I got this error :
CommandError: 'ucportal' conflicts with the name of an existing Python
module and cannot be used as an app name. Please try another name.
After that I deleted that directory and ran startapp command with same name and it worked fine.
So 'startapp' command is to create an app automatically. If you already have one there, it fails.
Answer given by #DAG worked for me.
I ran into this issue while trying to set up a Wagtail project.
Before creating the app, I had created and activated a virtualenv (using virtualenvwrapper) with the same name: $APPNAME. When I then ran wagtail start $APPNAME, Django looks for naming conflics in the $PYTHONPATH which in this instance points to /Users/User/.virtualenvs.
Naturally, this results in a conflict as /Users/User/.virtualenvs/$APPNAME already exists.
None of these answers helped me. In the end I ended up creating an app with a different name and then just renaming the directory to the app name I wanted all along. Note that you also will need to change the class name in apps.py to match your app name.
Just Simply Use This command
for Django Project Creation
python -m django startproject name_of_django_Project
for Django App Creation
python -m django startapp App_name
I had the same issue when working with wagtail cms. I got this error even there is no such a created app. This occurs when there is an app already that has the same name you need to create inside the site-packages directory.
Once you get this error, you need to check the following directory,
C:\Users\{user}\AppData\Local\Programs\Python\Python38-32\Lib\site-packages
If there is a package with the name same you want to create then you need to remove that package. Also make sure to check that package is important or not before deleting.
The application directory should be created first.
Example: apps/practice
The command appears to be duplicated, but it is correct.
Example: python manage.py startapp practice ./apps1/practice

Django, error with custom admin commands when executing with absolute path

I have a custom admin command named temperature.py which is under /home/user/project/monitor/management/commands. If I change directory to /home/user/ and execute:
user#localhost:~/project$ ./manage.py temperature
It runs ok, and its listed in the available commands. But if I try running it with the absolute path:
user#localhost:/$ /home/user/project/manage.py temperature
It says the command does not exist, it does not show up in the available commands either. I have django 1.2.1 with python 2.6.5 in ubuntu 10.04. Could this be a problem with django? is it the python version? Thanks in advance
Found the reason, it seems that django is looking for the settings under the main directory, if it fails to find one, it will use the defaults. You can change your python path or use this in your manage.py file