-
Notifications
You must be signed in to change notification settings - Fork 75
Django
Here we will include a log of the work done on the Django web app.
- We start by creating a project.
django-admin startproject DeepChatModels
- Next we need to create an app for this project. We create the userinput app which will take in the users text and feed it into our model.
- The landing page will be a text input field which the user can type into, so we must add a
urls.py
file to the userinput directory and map this to the index view. - We also modify the
urls.py
file for the project, DeepChatModels, so that we can reference the userinput app. - We make sure to add the app into the installed apps list in the
settings.py
file. - We create a template for the index view which in order to process the form.
In basic HTML a form is generated using the <form>...</form>
tags. The form helps the user transmit data to your website model.
* where - this denotes where the data should be sent to.
* how - is this a POST or a GET
POST - Bundles the forms data and encodes it, sends it to the server and receives its response. GET - This bundles the data into a string and uses it as a URL.
The usage for these methods are:
If the state of the system is going to change we should use the POST
methods. GET
is ideal for when the system is not going to change.
Django does a lot for the developer. * prepares the data for rendering * creates the html forms for the data * receives and processes the data
- We use the Django Form class to do this
forms.Form
- We use a check for 'POST' or 'GET' to determine the behavior of our page.