💾 Archived View for chirale.org › 2012-10-08_637.gmi captured on 2024-08-18 at 17:35:56. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

Django development on Virtualbox: step by step setup

I had a bad morning trying to repair my Cygwin installation from a virtualenv mess. It’s time to get a Debian and install it on a Virtualbox for my new django project!

Choosing the distro: what I want

I’m a Debian fan from years so I go to the Debian website and download Wheezy netinst iso (32 bit, since I’m on a 32 bit OS and I want to use more core): wheezy met all the requirements above.

Wheezy netinst

I already have a Virtualbox, so what I do is to add a new virtual disk and to add the new Wheezy netinst iso on CD/DVD images. Then I create a new Debian machine (32 bit) with two cores. I choose the iso image to be mounted on startup so the Debian setup process will start on boot.

Virtualbox

As network device, I choose the Bridge option, so I can access the machine later from my windows host.

Installing the system

When you turn your machine on, many choices will be prompted to you. I install the webserver (apache) from the list, removed SQL server and print server and then leave desktop selected and the other default values. After some minutes Debian is installed and I can log in with the credential I have specified during installation.

Use WORKGROUP as network name if you’re running a Windows host when asked.

Install django packages

Under the Application menu, find the Debian package management tools to install what you want. As the requirements I’ve listeded above I search and install those packages:

Later you can install more useful packages like virtualenv and phpmyadmin.

After you’ve installed those packages, you can do some test. Open a shell (Accessories \> Terminal) and then type these commands:

What version of python I’m running?

$ python

Python 3rc2 (default, Apr 22 2012, 22:35:38)

\[GCC 3\] on linux2

Type “help”, “copyright”, “credits” or “license” for more information.

\>\>\>

So I’ve python Good!

\>\>\> import django

\>\>\> django.VERSION

(1, 4, 1, ‘final’, 0)

And I’ve Django

Share your code to the Windows network (workgroup)

Now I want to read the code from one machine to another. I choose Samba server to read and write files from the virtual machine to windows and back. It will be useful since I’ve a complete Eclipse + pydev IDE on windows and I love work with it.

Eclipse

pydev

I open a Root terminal and type:

\# ifconfig

If you choosed the Bridge network interface on installation, you will got something like this:

eth0 Link encap:Ethernet HWaddr ??????
inet addr:104 Bcast:255 Mask:0
inet6 addr: ???????????/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:49280 errors:0 dropped:0 overruns:0 frame:0
TX packets:19777 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:45400047 (2 MiB) TX bytes:1887849 (8 MiB)
Interrupt:19 Base address:0xd020

The address in bold (104) is the local network address of my virtual machine. If I just type this address in the Chrome browser it’s running on Windows (host) I got the “It works!” from Apache on the virtual machine. If you can’t see nothing, left click on the network icon on the bottom of your virtualbox windows \> click on the menu voice and then choose the Bridge option. Then redo the ifconfig as above.

Samba tuning

Create a directory to store your django code (inside current user home folder). Open the terminal as normal user:

$ cd
$ mkdir my-django-code

Then share this folder with samba. To do this, let’s create a new user without a password:

adduser guest –home=/home/public –shell=/bin/false –disabled-password

Then add these lines to /etc/samba/smb.conf on “## Authentication \##” section:

security = share
guest_account = guest
invalid_users = root
obey pam restrictions = yes

And then after the \[cdrom\] commented text:

\[my-django-code\]
comment=Django-code
read only = no
locking = no
path = /home/myuser/my-django-code
guest ok = yes
force user = myuser

Where myuser is my (normal) user name. The lines above tell something like this to samba:

The “masquerade” thing is all about having the right to write files created from myuser from the guest user on the host.

When i browse my Workgroup on windows, I found the machine name I choose during installation and inside I found the my-django-code directory. I try to read and write files from the host (Windows) and from the guest (Debian) and it’s all ok.

Django, finally!

If you’re starting to develop on django, so this howto for beginners will help you a lot. Since I’ve installed the python-django package from Debian, to start a project is simple as typing this:

howto for beginners

$ cd
$ cd my-django-code
$ django-admin startproject django_unchained
$ cd django_unchained
$ python manage.py runserver 104:8000

Where 104 is the virtual machine local network address from above and 8000 the port of the django testing webserver.

I type:

http://104:8000

on Chrome (host: Windows) and I get the hello page from Django. Perfect!

Then, I can just follow the django howto to do the right things during the creation of my new app django_unchained!

django howto

You can also explore the must-have list of tools and sites for Python developers.

must-have list of tools and sites for Python developers

https://web.archive.org/web/20121008000000*/http://www.debian.org/devel/debian-installer/

https://web.archive.org/web/20121008000000*/https://www.virtualbox.org/

https://web.archive.org/web/20121008000000*/http://www.eclipse.org/

https://web.archive.org/web/20121008000000*/http://pydev.org/

https://web.archive.org/web/20121008000000*/https://docs.djangoproject.com/en/dev/intro/tutorial01/

https://web.archive.org/web/20121008000000*/http://192.168.0.104:8000

<p>on Chrome (host: Windows) and I get the hello page from Django. Perfect!</p> <p>Then, I can just follow the <a href=

https://web.archive.org/web/20121008000000*/https://docs.djangoproject.com/en/dev/intro/tutorial01/