Course Content
What happened when you created the Article DocType?
COMPLETED
Faris Ansari
May 19, 2021

1. Database Table

A database table with the name tabArticle was created with the fields we specified in the fields table. You can confirm this by checking it from the MariaDB console

$ bench --site library.test mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2445938
Server version: 10.4.13-MariaDB Homebrew

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [_ad03fa1a016ca1c4]> desc tabArticle;
+--------------+--------------+------+-----+-----------+-------+
| Field        | Type         | Null | Key | Default   | Extra |
+--------------+--------------+------+-----+-----------+-------+
| name         | varchar(140) | NO   | PRI | NULL      |       |
| creation     | datetime(6)  | YES  |     | NULL      |       |
| modified     | datetime(6)  | YES  | MUL | NULL      |       |
| modified_by  | varchar(140) | YES  |     | NULL      |       |
| owner        | varchar(140) | YES  |     | NULL      |       |
| docstatus    | int(1)       | NO   |     | 0         |       |
| parent       | varchar(140) | YES  | MUL | NULL      |       |
| parentfield  | varchar(140) | YES  |     | NULL      |       |
| parenttype   | varchar(140) | YES  |     | NULL      |       |
| idx          | int(8)       | NO   |     | 0         |       |
| article_name | varchar(140) | YES  |     | NULL      |       |
| image        | text         | YES  |     | NULL      |       |
| author       | varchar(140) | YES  |     | NULL      |       |
| description  | longtext     | YES  |     | NULL      |       |
| isbn         | varchar(140) | YES  |     | NULL      |       |
| status       | varchar(140) | YES  |     | Available |       |
| publisher    | varchar(140) | YES  |     | NULL      |       |
| _user_tags   | text         | YES  |     | NULL      |       |
| _comments    | text         | YES  |     | NULL      |       |
| _assign      | text         | YES  |     | NULL      |       |
| _liked_by    | text         | YES  |     | NULL      |       |
+--------------+--------------+------+-----+-----------+-------+
21 rows in set (0.002 sec)

MariaDB [_ad03fa1a016ca1c4]>

The fields we specified in Title Case were converted to snake case automatically, and are used as the column names in the table. For e.g., article_name, image, author , and description.

However, many other fields were created like name, creation, modified, modified_by . These are standard fields created for all doctypes. name is the primary key column.

If you created a record with the Form, you can also run a standard select query to get the rows.

MariaDB [_ad03fa1a016ca1c4]> select * from tabArticle;
+------------+----------------------------+----------------------------+---------------+---------------+-----------+--------+-------------+------------+-----+-----------------------------+--
| name       | creation                   | modified                   | modified_by   | owner         | docstatus | parent | parentfield | parenttype | idx | article_name                | i
+------------+----------------------------+----------------------------+---------------+---------------+-----------+--------+-------------+------------+-----+-----------------------------+--
| bd514646b9 | 2020-10-10 16:24:43.033457 | 2020-10-10 16:24:43.033457 | Administrator | Administrator |         0 | NULL   | NULL        | NULL       |   0 | The Girl with all the Gifts | N
+------------+----------------------------+----------------------------+---------------+---------------+-----------+--------+-------------+------------+-----+-----------------------------+--

MariaDB [_ad03fa1a016ca1c4]>

2. Desk Views

There are a number of views that were also created for our DocType. The Article List is the list view that shows the records from the database table. The Form view is the view that is shown when you want to create a new document or view an existing one.

3. Form Layout

If you notice, the layout of fields in the form is according to how you ordered them in the Fields table. For e.g., Article Name is the first field followed by Image which is followed by Author. In later parts of the tutorial we will learn how to customize this further.

4. Boilerplate code

If you look at the changes in your app, you should find a number of files that were created. Go to your terminal and from the frappe-bench directory run the following commands.

$ cd apps/library_management
$ git status -u
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
    library_management/library_management/doctype/__init__.py
    library_management/library_management/doctype/article/__init__.py
    library_management/library_management/doctype/article/article.js
    library_management/library_management/doctype/article/article.json
    library_management/library_management/doctype/article/article.py
    library_management/library_management/doctype/article/test_article.py

nothing added to commit but untracked files present (use "git add" to track)

article.json - JSON file that defines the doctype attributes

article.js - Client-side controller for the Form view

article.py - Python controller for Article

test_article.py - Python Unit Test boilerplate for writing tests

As you can see, a DocType describes a lot of things about the model. Not only does it define the table and column names but also how it will be rendered in various views in the Desk.

Good job following the tutorial so far. Let's keep going!

Questions
On branch master nothing to commit, working tree clean
SM Seid Mohammed
2 months ago
Post
Dismiss

I followed exact steps but the comand on git git status -u repayed to me On branch master nothing to commit, working tree clean

Want to discuss?
Post it here, our mentors will help you out.
No files in the mentioned directory
leeladharan mp
9 months ago
Post
Dismiss

Hi,

I followed exact steps, but at this step, https://frappe.school/courses/frappe-framework-tutorial/learn/6.3

I don't see Article.py, but still everything is working fine as informed in the steps.

This is the frappe version installed

frappe 14.0.0.dev0 /private/var/www/frappe_crm/frappe-bench/apps/frappe

This is the frappe bench version installed

frappe-bench 5.6.0

Jannat Patel
9 months ago
Post
Dismiss

Was the developer mode on when you created the doctype? Doctypes reflect on code only when developer mode is on.

Want to discuss?
Post it here, our mentors will help you out.