nativeInstallerpootle

Create a new Django project

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

Follow the steps below:

  • Change to the Django projects folder and run the following command to create a new project. Replace the PROJECT placeholder with the name of your project in this and all subsequent commands.

      $ cd installdir/apps/django/django_projects/PROJECT
      $ django-admin.py startproject PROJECT
    

    The projects folder is located as follows on each platform:

    • Linux and Mac OS X: installdir/apps/django/django_projects
    • Windows 2000, Windows XP and Windows 2003 Server: C:\Documents and Settings\USER\Bitnami DjangoStack Projects
    • Windows Vista, Windows 7 and Windows 2008 Server: C:\Users\USER\Bitnami DjangoStack Projects
  • If you wish to create a new application inside the project, execute the following commands as well. Replace the APP placeholder with the name of your application in this and all subsequent commands.

      $ cd PROJECT
      $ python3 manage.py startapp APP
    
  • Edit the installdir/apps/django/django_projects/PROJECT/APP/views.py file and add this content:

      from django.http import HttpResponse
    
      def index(request):
        return HttpResponse("Hello world!")
    
  • Create the installdir/apps/django/django_projects/PROJECT/APP/urls.py file and add these lines to it:

      from django.conf.urls import url
    
      from . import views
    
      urlpatterns = [
        url(r'^$', views.index, name='index'),
      ]
    
  • Edit the installdir/apps/django/django_projects/PROJECT/PROJECT/urls.py file and modify it to look like this:

      from django.conf.urls import url
      from django.urls import include
    
      urlpatterns = [
          url(r'^APP/', include('APP.urls')),
      ]
    
  • Follow the steps to deploy your Django project with Apache.

You should now be able to see your new application at http://localhost/PROJECT/APP.

If you prefer to use the standalone server in Django, refer to this section. In this case, you should be able to see your new application at http://localhost:8000/APP.

To get started with Django, check the official Django documentation for the version that you are using.

Last modification November 17, 2020