Starts a thingy:
$ django-admin startproject mysite
This makes a bunch of stuff:
/projectname
manage.py - what you use for commands and stuff/projectname
__init__.py - for package shit. Mostly dw about thissettings.py - settings for the whole prjecturls.py - “tables of contents” - for routing and shit I assume? -wsgi.py - “entry-point for WSGI-compatible web servers” WTF IS THAT?!K let’s go. Run the Development Server with:
$ python manage.py runserver 198.1284.1.75:8080
Right now let’s make an actual app. Django “generates the basic directory structure of an app”. Cool.
$ python manage.py startapp polls
polls/
__init__.pyadmin.pyapps.pymigrations/
__init__.pymodels.pytests.pyviews.pyThis makes even more stuff!!! It never ends!! Okay let’s go bit by bit.
Where you put your “views”, I’m guessing this means your html files, the actual things you view in your web browser. So we make a super simple thing in there that’s cool.
def index(request):return HttpResponse("Hello, world. You're at the polls index.")
Now we need way to get this view. We need to give it a url….
(it’s funny this wasn’t made by default…) Anyway. Make a regex that recongises a url and routes it to the view you just made:
urlpatterns = [url(r'^$', views.index, name='index'),]
Oooohhh now we need to point the ROOT url router to the polls url router:
You do this by: