The First Django Project:
Now everything seems fine and dandy and its time to make our first Django project. Well, say hello to Windows bugs!
According to the Django documentation both in the original page and in the BitNami one starting a new Django project is as simple as typing:
$ django-admin.py startproject mysite
In the project's console but sadly that's no the case. I had to search a lot for the right way to execute the application and read that there's a bug with the Windows version of Django (v1.4.7) and as such must be initialized as follows:
1.-Execute the BitNami Django Stack Manager tool and the Use BitNami Django Stack Console application.
According to the Django documentation both in the original page and in the BitNami one starting a new Django project is as simple as typing:
$ django-admin.py startproject mysite
In the project's console but sadly that's no the case. I had to search a lot for the right way to execute the application and read that there's a bug with the Windows version of Django (v1.4.7) and as such must be initialized as follows:
1.-Execute the BitNami Django Stack Manager tool and the Use BitNami Django Stack Console application.
2.-The BitNami manager will start the Servers and the other will open a console where we can code the projects. Now we create a directory where we'll store our project. In my case I created a Directory called DjangoTest on my Desktop. I go there using the Console commands (MS-DOS course here) and then type the following command:
$ python "C:\Program Files\BitNami\djangostack-1.4.7-0\apps\django\django\bin\django-admin.py" startproject mysite
Which will tell Python to execute the file django-admin.py and create a project (startproject) called "mysite" in the current directory, in my case the DjangoTest directory located on my Desktop. Now you must know that the file path between the commans is where you currently have Django installed; for example if you installed BitNami Django Stack on "C:" your path would be something like:
$ python "C:\BitNami\djangostack-1.4.7-0\apps\django\django\bin\django-admin.py" startproject mysite
3.-If you check using the "dir" command on the console you should see the mysite directory within the DjangoTest one.
$ python "C:\Program Files\BitNami\djangostack-1.4.7-0\apps\django\django\bin\django-admin.py" startproject mysite
Which will tell Python to execute the file django-admin.py and create a project (startproject) called "mysite" in the current directory, in my case the DjangoTest directory located on my Desktop. Now you must know that the file path between the commans is where you currently have Django installed; for example if you installed BitNami Django Stack on "C:" your path would be something like:
$ python "C:\BitNami\djangostack-1.4.7-0\apps\django\django\bin\django-admin.py" startproject mysite
3.-If you check using the "dir" command on the console you should see the mysite directory within the DjangoTest one.
Troubleshooting:
*Python can't import the Django package.
According to what I read it wasn't the problem as Python automatically comes linked with the Django installer (version 2.7.5 in my case) but in case the import Django command on the console gives error, you can try adding the directory where Django is installed on the PythonPath as shown here.
1.-Basically check if Python can recognize the import Django command in the BitNami Console as shown in the figure.
*Typing "python" will show the version and initialize the version installed in the BitNami module.
*Typing "import django" must return nothing if its correctly installed.
1.-Basically check if Python can recognize the import Django command in the BitNami Console as shown in the figure.
*Typing "python" will show the version and initialize the version installed in the BitNami module.
*Typing "import django" must return nothing if its correctly installed.
2.-If it shows something like "import error django not found" you can go to START and type Regedit. This will open the Registry Editor with all the keys the system uses. BEWARE its delicate data so don't mess with it too much if you can avoid it.
3.-Once inside you must go to:
HKEY_LOCAL_MACHINE -> SOFTWARE -> Python -> PythonCore -> [ Version Number ] -> PythonPath.
4.-Make right click and select create new Key / Crear una nueva clave. Call it anything, I called mine DjangoPath.
5.-It will generate a file without value. Double click on it and add the directory where Django is installed as show in the figure.
HKEY_LOCAL_MACHINE -> SOFTWARE -> Python -> PythonCore -> [ Version Number ] -> PythonPath.
4.-Make right click and select create new Key / Crear una nueva clave. Call it anything, I called mine DjangoPath.
5.-It will generate a file without value. Double click on it and add the directory where Django is installed as show in the figure.
6.-Make click in OK / Aceptar and close the application. Now after you type import django in the console it should be recognized.