{"action":"created","comment":{"url":"https://api.github.com/repos/matllubos/django-is-core/pulls/comments/45238428","id":45238428,"diff_hunk":"@@ -1,3 +1,93 @@\n-\n Forms\n =====\n+\n+``is_core.forms`` contains helpers for forms rutines. The most interesting class is ``SmartForm``.\n+\n+SmartForm\n+---------\n+A base class for forms. Image that you want to call a method when a form is constructed. A basic approach is\n+to override ``__init__`` method, which is pretty uncomftable because you have to call ``super`` and pass argument\n+and etc. With ``SmartForm`` you can simply define a ``_init_fields`` method. But more interesting things are\n+``_init_{field_name}`` method. The following code::\n+\n+    from is_core.forms import SmartForm\n+\n+    class MyForm(SmartForm):\n+\n+        def _init_fields():\n+\n+            for field in self.fields:\n+                if field.name == 'foo':\n+                    # do logic for foo\n+                elif field.name == 'bar':\n+                    # do logic for bar\n+\n+\n+you can simply write in this way::\n+\n+    from is_core.forms import SmartForm\n+\n+    class MyForm(SmartForm):\n+\n+        def _init_foo(field):\n+            # do logic for foo\n+\n+        def _init_bar(field):\n+            # do logic for bar\n+\n+Yay! It's pretty, isn't it?\n+\n+\n+``SmartForm`` contains helper methods that are called when an instance is created in a following order:\n+\n+1. ``_pre_init_fields``\n+2. ``_init_{field_name}`` methods\n+3. ``_init_fields``\n+\n+.. method:: SmartForm._pre_init_fields()\n+\n+This method is called when a form is created (after super ``__init__`` method and before ``_init_{field_name}`` methods).\n+It make fields from ``base_required_fields`` attribute required.","path":"docs/forms.rst","position":null,"original_position":51,"commit_id":"e46e47a3e7c360675acc94dec927f01c9161e65e","original_commit_id":"7d24000e3c63a91e71d85ab7cec6d9261d4390c6","user":{"login":"LukasRychtecky","id":585068,"avatar_url":"https://avatars.githubusercontent.com/u/585068?v=3","gravatar_id":"","url":"https://api.github.com/users/LukasRychtecky","html_url":"https://github.com/LukasRychtecky","followers_url":"https://api.github.com/users/LukasRychtecky/followers","following_url":"https://api.github.com/users/LukasRychtecky/following{/other_user}","gists_url":"https://api.github.com/users/LukasRychtecky/gists{/gist_id}","starred_url":"https://api.github.com/users/LukasRychtecky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LukasRychtecky/subscriptions","organizations_url":"https://api.github.com/users/LukasRychtecky/orgs","repos_url":"https://api.github.com/users/LukasRychtecky/repos","events_url":"https://api.github.com/users/LukasRychtecky/events{/privacy}","received_events_url":"https://api.github.com/users/LukasRychtecky/received_events","type":"User","site_admin":false},"body":"Fixed","created_at":"2015-11-18T18:24:58Z","updated_at":"2015-11-18T18:24:58Z","html_url":"https://github.com/matllubos/django-is-core/pull/150#discussion_r45238428","pull_request_url":"https://api.github.com/repos/matllubos/django-is-core/pulls/150","_links":{"self":{"href":"https://api.github.com/repos/matllubos/django-is-core/pulls/comments/45238428"},"html":{"href":"https://github.com/matllubos/django-is-core/pull/150#discussion_r45238428"},"pull_request":{"href":"https://api.github.com/repos/matllubos/django-is-core/pulls/150"}}},"pull_request":{"url":"https://api.github.com/repos/matllubos/django-is-core/pulls/150","id":50749409,"html_url":"https://github.com/matllubos/django-is-core/pull/150","diff_url":"https://github.com/matllubos/django-is-core/pull/150.diff","patch_url":"https://github.com/matllubos/django-is-core/pull/150.patch","issue_url":"https://api.github.com/repos/matllubos/django-is-core/issues/150","number":150,"state":"open","locked":false,"title":"Added documentation for is_core.forms","user":{"login":"LukasRychtecky","id":585068,"avatar_url":"https://avatars.githubusercontent.com/u/585068?v=3","gravatar_id":"","url":"https://api.github.com/users/LukasRychtecky","html_url":"https://github.com/LukasRychtecky","followers_url":"https://api.github.com/users/LukasRychtecky/followers","following_url":"https://api.github.com/users/LukasRychtecky/following{/other_user}","gists_url":"https://api.github.com/users/LukasRychtecky/gists{/gist_id}","starred_url":"https://api.github.com/users/LukasRychtecky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LukasRychtecky/subscriptions","organizations_url":"https://api.github.com/users/LukasRychtecky/orgs","repos_url":"https://api.github.com/users/LukasRychtecky/repos","events_url":"https://api.github.com/users/LukasRychtecky/events{/privacy}","received_events_url":"https://api.github.com/users/LukasRychtecky/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-15T15:59:22Z","updated_at":"2015-11-18T18:24:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"014a579cbcae0581deb5c3f644c8bf25a1f295d6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/matllubos/django-is-core/pulls/150/commits","review_comments_url":"https://api.github.com/repos/matllubos/django-is-core/pulls/150/comments","review_comment_url":"https://api.github.com/repos/matllubos/django-is-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matllubos/django-is-core/issues/150/comments","statuses_url":"https://api.github.com/repos/matllubos/django-is-core/statuses/e46e47a3e7c360675acc94dec927f01c9161e65e","head":{"label":"LukasRychtecky:v1.4_docs","ref":"v1.4_docs","sha":"e46e47a3e7c360675acc94dec927f01c9161e65e","user":{"login":"LukasRychtecky","id":585068,"avatar_url":"https://avatars.githubusercontent.com/u/585068?v=3","gravatar_id":"","url":"https://api.github.com/users/LukasRychtecky","html_url":"https://github.com/LukasRychtecky","followers_url":"https://api.github.com/users/LukasRychtecky/followers","following_url":"https://api.github.com/users/LukasRychtecky/following{/other_user}","gists_url":"https://api.github.com/users/LukasRychtecky/gists{/gist_id}","starred_url":"https://api.github.com/users/LukasRychtecky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LukasRychtecky/subscriptions","organizations_url":"https://api.github.com/users/LukasRychtecky/orgs","repos_url":"https://api.github.com/users/LukasRychtecky/repos","events_url":"https://api.github.com/users/LukasRychtecky/events{/privacy}","received_events_url":"https://api.github.com/users/LukasRychtecky/received_events","type":"User","site_admin":false},"repo":{"id":16541499,"name":"django-is-core","full_name":"LukasRychtecky/django-is-core","owner":{"login":"LukasRychtecky","id":585068,"avatar_url":"https://avatars.githubusercontent.com/u/585068?v=3","gravatar_id":"","url":"https://api.github.com/users/LukasRychtecky","html_url":"https://github.com/LukasRychtecky","followers_url":"https://api.github.com/users/LukasRychtecky/followers","following_url":"https://api.github.com/users/LukasRychtecky/following{/other_user}","gists_url":"https://api.github.com/users/LukasRychtecky/gists{/gist_id}","starred_url":"https://api.github.com/users/LukasRychtecky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LukasRychtecky/subscriptions","organizations_url":"https://api.github.com/users/LukasRychtecky/orgs","repos_url":"https://api.github.com/users/LukasRychtecky/repos","events_url":"https://api.github.com/users/LukasRychtecky/events{/privacy}","received_events_url":"https://api.github.com/users/LukasRychtecky/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LukasRychtecky/django-is-core","description":"","fork":true,"url":"https://api.github.com/repos/LukasRychtecky/django-is-core","forks_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/forks","keys_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/teams","hooks_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/hooks","issue_events_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/issues/events{/number}","events_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/events","assignees_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/assignees{/user}","branches_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/branches{/branch}","tags_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/tags","blobs_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/statuses/{sha}","languages_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/languages","stargazers_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/stargazers","contributors_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/contributors","subscribers_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/subscribers","subscription_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/subscription","commits_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/contents/{+path}","compare_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/merges","archive_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/downloads","issues_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/issues{/number}","pulls_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/pulls{/number}","milestones_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/milestones{/number}","notifications_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/labels{/name}","releases_url":"https://api.github.com/repos/LukasRychtecky/django-is-core/releases{/id}","created_at":"2014-02-05T10:21:28Z","updated_at":"2014-06-09T06:50:38Z","pushed_at":"2015-11-18T18:24:27Z","git_url":"git://github.com/LukasRychtecky/django-is-core.git","ssh_url":"git@github.com:LukasRychtecky/django-is-core.git","clone_url":"https://github.com/LukasRychtecky/django-is-core.git","svn_url":"https://github.com/LukasRychtecky/django-is-core","homepage":null,"size":2100,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"matllubos:v1.4_docs","ref":"v1.4_docs","sha":"6db5e576f89ccda4a1450148e917ba8a63fee035","user":{"login":"matllubos","id":424409,"avatar_url":"https://avatars.githubusercontent.com/u/424409?v=3","gravatar_id":"","url":"https://api.github.com/users/matllubos","html_url":"https://github.com/matllubos","followers_url":"https://api.github.com/users/matllubos/followers","following_url":"https://api.github.com/users/matllubos/following{/other_user}","gists_url":"https://api.github.com/users/matllubos/gists{/gist_id}","starred_url":"https://api.github.com/users/matllubos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matllubos/subscriptions","organizations_url":"https://api.github.com/users/matllubos/orgs","repos_url":"https://api.github.com/users/matllubos/repos","events_url":"https://api.github.com/users/matllubos/events{/privacy}","received_events_url":"https://api.github.com/users/matllubos/received_events","type":"User","site_admin":false},"repo":{"id":16474183,"name":"django-is-core","full_name":"matllubos/django-is-core","owner":{"login":"matllubos","id":424409,"avatar_url":"https://avatars.githubusercontent.com/u/424409?v=3","gravatar_id":"","url":"https://api.github.com/users/matllubos","html_url":"https://github.com/matllubos","followers_url":"https://api.github.com/users/matllubos/followers","following_url":"https://api.github.com/users/matllubos/following{/other_user}","gists_url":"https://api.github.com/users/matllubos/gists{/gist_id}","starred_url":"https://api.github.com/users/matllubos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matllubos/subscriptions","organizations_url":"https://api.github.com/users/matllubos/orgs","repos_url":"https://api.github.com/users/matllubos/repos","events_url":"https://api.github.com/users/matllubos/events{/privacy}","received_events_url":"https://api.github.com/users/matllubos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matllubos/django-is-core","description":"","fork":false,"url":"https://api.github.com/repos/matllubos/django-is-core","forks_url":"https://api.github.com/repos/matllubos/django-is-core/forks","keys_url":"https://api.github.com/repos/matllubos/django-is-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matllubos/django-is-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matllubos/django-is-core/teams","hooks_url":"https://api.github.com/repos/matllubos/django-is-core/hooks","issue_events_url":"https://api.github.com/repos/matllubos/django-is-core/issues/events{/number}","events_url":"https://api.github.com/repos/matllubos/django-is-core/events","assignees_url":"https://api.github.com/repos/matllubos/django-is-core/assignees{/user}","branches_url":"https://api.github.com/repos/matllubos/django-is-core/branches{/branch}","tags_url":"https://api.github.com/repos/matllubos/django-is-core/tags","blobs_url":"https://api.github.com/repos/matllubos/django-is-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matllubos/django-is-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matllubos/django-is-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/matllubos/django-is-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matllubos/django-is-core/statuses/{sha}","languages_url":"https://api.github.com/repos/matllubos/django-is-core/languages","stargazers_url":"https://api.github.com/repos/matllubos/django-is-core/stargazers","contributors_url":"https://api.github.com/repos/matllubos/django-is-core/contributors","subscribers_url":"https://api.github.com/repos/matllubos/django-is-core/subscribers","subscription_url":"https://api.github.com/repos/matllubos/django-is-core/subscription","commits_url":"https://api.github.com/repos/matllubos/django-is-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/matllubos/django-is-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/matllubos/django-is-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/matllubos/django-is-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/matllubos/django-is-core/contents/{+path}","compare_url":"https://api.github.com/repos/matllubos/django-is-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matllubos/django-is-core/merges","archive_url":"https://api.github.com/repos/matllubos/django-is-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matllubos/django-is-core/downloads","issues_url":"https://api.github.com/repos/matllubos/django-is-core/issues{/number}","pulls_url":"https://api.github.com/repos/matllubos/django-is-core/pulls{/number}","milestones_url":"https://api.github.com/repos/matllubos/django-is-core/milestones{/number}","notifications_url":"https://api.github.com/repos/matllubos/django-is-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matllubos/django-is-core/labels{/name}","releases_url":"https://api.github.com/repos/matllubos/django-is-core/releases{/id}","created_at":"2014-02-03T08:54:04Z","updated_at":"2015-08-12T13:47:30Z","pushed_at":"2015-11-18T18:24:28Z","git_url":"git://github.com/matllubos/django-is-core.git","ssh_url":"git@github.com:matllubos/django-is-core.git","clone_url":"https://github.com/matllubos/django-is-core.git","svn_url":"https://github.com/matllubos/django-is-core","homepage":null,"size":2189,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":9,"forks":9,"open_issues":9,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matllubos/django-is-core/pulls/150"},"html":{"href":"https://github.com/matllubos/django-is-core/pull/150"},"issue":{"href":"https://api.github.com/repos/matllubos/django-is-core/issues/150"},"comments":{"href":"https://api.github.com/repos/matllubos/django-is-core/issues/150/comments"},"review_comments":{"href":"https://api.github.com/repos/matllubos/django-is-core/pulls/150/comments"},"review_comment":{"href":"https://api.github.com/repos/matllubos/django-is-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matllubos/django-is-core/pulls/150/commits"},"statuses":{"href":"https://api.github.com/repos/matllubos/django-is-core/statuses/e46e47a3e7c360675acc94dec927f01c9161e65e"}}}}