User Tools

Site Tools


programming:django

This is an old revision of the document!


Create a project
django-admin startproject mysite
Launch the server
python manage.py runserver
Create a app inside a project

Everything are apps. Each app has it's own subfolder. To create a app sceleton run

python manage.py startapp polls
Register URL

In the polls/urls.py file include the following code:

polls/urls.py
polls/urls.py¶
 
from django.urls import path
 
from . import views
 
urlpatterns = [
    path('', views.index, name='index'),
]

Now we need to add this url to our project:

<code python mysite/urls.py> from django.contrib import admin from django.urls import include, path

urlpatterns = [

  path('polls/', include('polls.urls')),
  path('admin/', admin.site.urls),

] </pyton>

programming/django.1543223487.txt.gz · Last modified: by clemix

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki