django-admin.py startproject mysite; results in an empty directory - python

django version 1.7b1
ubuntu 12 LTS
python3.2
The command:
django-admin.py startproject mysite
results in an empty directory, but in reality it should put the following files in mysite/:
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
ideas?

Please try:
django-admin startproject myproject
no .py!
Reference: https://docs.djangoproject.com/en/dev/faq/troubleshooting/#troubleshooting-django-admin-py

Related

How to create all django apps inside a folder?

Here is my project folder structure:
.venv [virtual environment]
apps
budgetApp
__init__.py
settings.py
urls.py
wsgi.py
manage.py
When I run the following command python manage.py startapp budget it creates a new folder named budget beside the folder budgetApp.
But I want to create all my apps folder inside the apps folder.
At first, you need to create a directory Your_App_Name inside the /apps folder.
After that, run the following command to create the new app
python manage.py startapp Your_App_Name ./apps/Your_Apps_Folder_Name/
Then don't forget to add just created app name in the settings.py like below:
INSTALLED_APPS = [
...,
'apps.Your_App_Name',
]
You can specify the path to destination directory after app_label in the startapp command.
python manage.py startapp <app_label> [destination]
In your case you the command is like this:
python manage.py startapp budget ./apps
Then you should add just created app name in settings.py like below:
INSTALLED_APPS = [
...,
'apps.budget',
]
You can also do it like this
cd apps && django-admin startapp app_name
First run python manage.py startapp budget app/budget
Then, on your settings.py, change the INSTALLED_APPS to the full path name:
INSTALLED_APPS = [
'app.budget.apps.BudgetConfig',
]
When you use a nested structure for apps, you also need to change the name of the app in apps.py as follows:
class BudgetConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.budget'
Check https://code.djangoproject.com/ticket/24801 for more information.
If you're on Windows, you'll first need to create a folder app/budget. Then add the file __init__.py to the folder add. Then run the command py manage.py startapp budget app/budget.
Then, on your settings.py, change the INSTALLED_APPS to the full path
name:`INSTALLED_APPS = [
...,
'app.budget',
]`
also need to change the name of the app in apps.py as follows
class BudgetConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'app.budget'
I am making the following assumptions:
You are on a Unix/Linux PC
Your app is named: perstep
1. mkdir -p apps/perstep && touch apps/__init__.py
2. python manage.py startapp perstep ./apps/perstep
OR
1. mkdir -p apps && touch apps/__init__.py
2. cd apps && django-admin startapp perstep
configurations
reference the added diagram when in doubt.
1. In settings.py "INSTALLED_APPS" add "apps.perstep.apps.PerstepConfig" to it.
├── apps
│   ├── __init__.py
│   └── perstep
│   ├── apps.py
2. Change name = 'apps.perstep' within 'apps > perstep > apps.py' PerstepConfig
This works as at Django==4.0.5

why can't I run my flask server? what is happening with this code here?

(env) Lydias-MacBook-Air:flask_class lydiahuang$ ls
README.md config.py env migrations tests
app config.pyc manage.py requirments.txt
(env) Lydias-MacBook-Air:flask_class lydiahuang$ python manage.py
-bash: /Applications/MAMP/Library/bin/python: No such file or directory
(env) Lydias-MacBook-Air:flask_class lydiahuang$ which pip
/usr/local/bin/pip
Hi, what's happening with my code here? Why is my Python bin routed to the PHP(MAMP) application route? This doesn't look good, how do I fix this? I can't run my server like this.

Django: Startapp Generated files into existing project folder

I want to place django app files into generated Django project folder .
MyProject/
MyProject/
settings.py
urls.py
here i want to insert my Django app files like, views.py, admin.py, models.py etc into same MyProject folder itself. we can do the same by copy paste after app was created. but i want to know is their any magic we can achieve the same while executing this command?
django-admin startapp MyApp <directory>
I dont want to create Myapp folder instead Myapp/* should be move onto Myproject/ itself. without doing copy paste thing.
so finally i want my Project folder should be like this,
MyProject/
MyProject/
admin.py
models.py
settings.py
urls.py
views.py
command to run from same direcory. If you change directory then change in path also:
django-admin startproject myproject
django-admin startapp myapp myproject\myproject\
command sample:
E:\write here>django-admin startproject myproject
E:\write here>dir myproject\myproject
Volume in drive E has no label.
Volume Serial Number is ****-****
Directory of E:\write here\myproject\myproject
03-06-2017 11.53 AM <DIR> .
03-06-2017 11.53 AM <DIR> ..
03-06-2017 11.53 AM 3,103 settings.py
03-06-2017 11.53 AM 766 urls.py
03-06-2017 11.53 AM 396 wsgi.py
03-06-2017 11.53 AM 0 __init__.py
4 File(s) 4,265 bytes
2 Dir(s) 80,954,753,024 bytes free
E:\write here>django-admin startapp myapp myproject\myproject\
CommandError: E:\write here\myproject\myproject\__init__.py already exists, overlaying a project or app into an existing directory won't replace conflicting files
don't worry about above error because it is just notifying you that __init__.py is not to be overwrite.

Pinax Structure

I have just installed the Pinax but i'm very confused now.
in my structre
i have two directories
mysite and mysite-env
I dont why i have two directories. I just followed the installitation directions
in mysite,
<project-root>
apps/
__init__.py
deploy/
__init__.py
fcgi.py
wsgi.py
fixtures/
initial_data.json
locale/
...
requirements/
base.txt
project.txt
sitemedia/static // I move static file from mysite-env to here
...
templates/
_footer.html
homepage.html
site_base.html
__init__.py
manage.py
settings.py
urls.py
However,
default index page is in mysite-env/lib/python2.6/site-packages/pinax_theme_bootstrap/templates/banner_base.html
Should i manage my site from mysite ?
Pinax uses virtualenv to prevent messing up your local python libs by your project dependency.
So, launch the site with $ source mysite-env/bin/activate it will be fine. If you really hate mysite-env, just skip the virtualenv part.

Exist a diference in use django-admin.py or manage.py

I'm learning something about Django.In some tutorials that i've read is used django-admin.py for execute commands like " syncdb, startapp and startproject", in the others tutorials is used manage.py, So exist any important diference between use django-admin.py or manage.py ?
See: django-admin.py and manage.py in Django documentation
manage.py is a wrapper around django-admin.py automatically created in each Django project which puts your project's package on sys.path and sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project's settings.py file.
So, I think is more comfortable to use manage.py when you're working on a Django project.
manage.py is a file that excists in a project environment and is created after starting a project. It's purpose is to control project commands. Django-admin.py is a script to start a project ( you can put it anyhwhere, or shortcut it via .bash or .profile )
manage.py is django-admin fitted in your project: it uses settings.py in your project dir

Categories