Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ To create your first Django project, goto the console and run

This will create a folder *django_blog* with the following structure. Here, *django_blog* is the name of our project.

A Django project is a collection of settings for an instance of Django, including database configuration, Django-specific options and application-specific settings.

<del>A Django project is a collection of settings for an instance of Django, including database configuration, Django-specific options and application-specific settings.</del>
> No useful information

django_blog
├── django_blog
│   ├── __init__.py
│   ├── settings.py
Expand All @@ -34,14 +36,17 @@ A Django project is a collection of settings for an instance of Django, includin

These files are:

- **The outer django_blog/** directory is just a container for your project. Its name doesn't matter to Django; you can rename it to anything you like.
- **The outer django_blog/** directory is just a container for your project. Its name doesn't matter to Django; you can rename it to anything you like.
- **manage.py:** A command-line utility that lets you interact with this Django project in various ways. It is a thin wrapper around django-admin.py. So inside a Django project you can run manage.py instead of django-admin.py.
- **The inner django_blog/** directory is the actual Python package for your project. Its name is the Python package name you'll need to use to import anything inside it (e.g. import mysite.settings).
- **django_blog/__init__.py:** An empty file that tells Python that this directory should be considered a Python package.
- **django_blog/settings.py:** Settings/configuration for this Django project. Django settings will tell you all about how settings work.
- **django_blog/urls.py:** It handles the URL declarations for the Django project. This will simply map URL patterns (simple regular expressions) to Python functions (your views).
- **django_blog/wsgi.py:** An entry-point for WSGI-compatible webservers to serve your project. This will be used, once we want to deploy our application for production. For now, we'll ignore it.

> Feb 7 - import word is kind of alien. What exactly import does needs explanation
> What is WSGI ?

Now, that our project is setup. We can test it by running a development server.

The Django development server is a built-in, lightweight Web server you can use while developing your site. It’s included with Django so you can develop your site rapidly, without having to deal with configuring your production server (e.g., Apache) until you’re ready for production
Expand All @@ -56,11 +61,12 @@ This will run a development server on port 8000. If you preview your app now you
In this module, we'll create our first Django Application that will show a **Hello World** message instead of Weclome to Django.

To create our application, we'll run this command inside our Django project in the console.

cd django_blog
python manage.py startapp blog
This will create a folder *blog* inside our project. The new file structure should look something like this.

This will create a folder *blog* inside our project. The new file structure should look something like this.

django_blog
├── blog
│   ├── __init__.py
│   ├── models.py
Expand Down Expand Up @@ -90,13 +96,17 @@ Let's see how this works

1. First, we import the class HttpResponse, which lives in the django.http module. We need to import this class because it’s used later in our code.
2. We define `home` function, or `home view`. We can name this anything we want. As long as it is a valid python identifier. Every view function takes *request* as first parameter which contains details about the HTTP Request.
3. We call HTTPResponse function to display our **Hello World** message.
3. We call HttpResponse function to display our **Hello World** message.

> django.http module ? What is module at the first place ?
> This HttpResponse is a function different from the HttpResponse class right ?

Now that our view is ready, we need to tell our our django project when to serve this view. If you have been following closely, you can guess. We do this in `django_blog/urls.py`
Now that our view is ready, we need to tell our django project when to serve this view. If you have been following closely, you can guess. We do this in `django_blog/urls.py`

Now, add the following python code below the comment on line 8

url(r'^$', 'blog.views.home'),
> The url mapping like r'^$' needs explanation. blog.views.home is suggestive though.

This shall be enough to tell our django project, to serve the home view in blog application when we visit the root url of the project.

Expand All @@ -106,4 +116,6 @@ You can test the same by running development server again.

That is it, preview your application and you shall see the **Hello World** message.

That's it for this module. We'll get into models and get started with blog views in the next module.
That's it for this module. We'll get into models and get started with blog views in the next module.
> I am able to run the app, but my feedback is - isnt there an easier way to do the hello world. In Rails, we put a html file in public/ & simply render it to show hello world.
> Also, lets complete the blog app & release.