Skip to content
Ivan Aguilar edited this page Mar 21, 2017 · 2 revisions

Django

Here we will include a log of the work done on the Django web app.

  1. We start by creating a project. django-admin startproject DeepChatModels
  2. 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.
  3. 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.
  4. We also modify the urls.py file for the project, DeepChatModels, so that we can reference the userinput app.
  5. We make sure to add the app into the installed apps list in the settings.py file.
  6. We create a template for the index view which in order to process the form.

Working with forms

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

GET and POST

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 and Forms

Django does a lot for the developer. * prepares the data for rendering * creates the html forms for the data * receives and processes the data

Building a Django Form
  1. We use the Django Form class to do this forms.Form
  2. We use a check for 'POST' or 'GET' to determine the behavior of our page.
Clone this wiki locally