Skip to content
This repository has been archived by the owner on Aug 13, 2018. It is now read-only.

Commit

Permalink
Fixing posts in dir structure
Browse files Browse the repository at this point in the history
  • Loading branch information
marcanuy committed Aug 8, 2016
1 parent 3d3750a commit 3b182d4
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 6 deletions.
Expand Up @@ -20,7 +20,7 @@ Two alternatives for fully semantically correct [blockquotes](https://developer.

+ Adding the _cite_ attribute in _blockquote_ tag:

~~~ kramdown
~~~ markdown
> The rule of thumb is, don't introduce a new attribute outside of the __init__ method, otherwise you've given the caller an object that isn't fully initialized.
{: cite="https://jeffknupp.com/blog/2014/06/18/improve-your-python-python-classes-and-object-oriented-programming/"}
~~~
Expand Down Expand Up @@ -52,6 +52,22 @@ Generates in HTML:
</blockquote>
~~~

### Generate Bootstrap 4 Blockquotes

In BS4 blockquotes need to have the `class="blockquote"` in the `blockquote` element and optionally a `class=blockquote-footer` in the `<footer>` element at bottom:

~~~ markdown
> Django handles three distinct parts of the work involved in forms.
> <footer class="blockquote-footer">Djangoproject.com tutorial</footer>
{: class="blockquote" cite="https://docs.djangoproject.com/en/1.9/topics/forms/"}
~~~

Generates:

> Django handles three distinct parts of the work involved in forms.
> <footer class="blockquote-footer">Djangoproject.com tutorial</footer>
{: class="blockquote" cite="https://docs.djangoproject.com/en/1.9/topics/forms/"}

## Code syntax highlighting

_kramdown_ can use [rouge](https://github.com/jneen/rouge) or [Coderay](http://coderay.rubychan.de/) for [syntax highlighting](http://kramdown.gettalong.org/syntax_highlighter/coderay.html).
Expand Down
28 changes: 27 additions & 1 deletion docs/python/django/_posts/2016-06-02-django-overview.md
@@ -1,7 +1,7 @@
---
title: Django Overview
subtitle: Framework basic summary
description: Python Web framework ovewview
description: Python Web framework overview
layout: post
weight: 1
---
Expand Down Expand Up @@ -74,6 +74,32 @@ In a Django web app, a form can refer to:
- the structured data returned when a form is submitted
- all of the above interacting together

> Django handles three distinct parts of the work involved in forms
>
> 1. preparing and restructuring data to make it ready for rendering
> 2. creating HTML forms for the data
> 3. receiving and processing submitted forms and data from the client
>
> <footer class="blockquote-footer">Djangoproject.com tutorial</footer>
{: class="blockquote" cite="https://docs.djangoproject.com/en/1.9/topics/forms/"}

Most of the forms in Django should be created from models, using [ModelForms](https://docs.djangoproject.com/en/1.9/topics/forms/modelforms/#modelform), [Model Fields](https://docs.djangoproject.com/en/1.9/ref/models/fields/) and [CSRF protection](https://docs.djangoproject.com/en/1.9/ref/csrf/).

ModelForms are useful to:

- generate HTML
- use [built-in validators](https://docs.djangoproject.com/en/1.9/ref/forms/validation/#using-validation-in-practice) approriate to each field. `forms.ModelForm.is_valid()`

A ModelForm maps fields from model classes to HTML form `<input>` elements via a the Form class.

One of the core features of Django Forms is that they make it easy to validate all the data.
{: class="alert alert-warning"}

### Form methods

If the form is used to retrieve data, it should use the __GET method__,
if it modifies data, it needs to use the __POST method__.

Reference: <https://docs.djangoproject.com/en/1.9/topics/forms/>

## Testing
Expand Down
@@ -0,0 +1,73 @@
---
title:
subtitle: Typical workflow for creating a Django web form
description: Django simplify and automates the process to create a form in simple steps.
layout: post
---

## Overview

A tipical workflow when creating a form in Django consists of these three steps:

<div class="mermaid">
graph TB
a[Create a Form class that defines its fields]-->b
b[Create the view to display the form and process received data]-->c
c[create the template to show the form]
</div>

## Creating the form

A _form_ can be defined [from scratch](https://docs.djangoproject.com/en/1.9/topics/forms/)
or take the field defitions from [Model](https://docs.djangoproject.com/en/1.9/topics/forms/modelforms/) classes.

<div class="mermaid">
graph TB
form-->has_model{"from a model"}
has_model-- no -->scratch["Inherits from django.forms.Form"]
has_model-- yes -->model["Inherits from django.forms.ModelForm"]
scratch-->fields["Define fields using django.forms.*Field"]
</div>

### New Form

~~~ python
# forms.py
from django import forms

class ContactForm(forms.Form):
name = forms.CharField(label='Full name', max_length=70)
~~~

### From Model

~~~ python
from django.forms import ModelForm
from myapp.models import News

class ArticleForm(ModelForm):
class Meta:
model = News
fields = ['title', 'content']
~~~

Creating an empty form to add an article.

~~~ python
form = ArticleForm()
~~~

Creating a form to change an existing article.

~~~ python
article = Article.objects.get(pk=1)
form = ArticleForm(instance=article)
~~~


## References

- Forms API <https://docs.djangoproject.com/en/1.9/ref/forms/api/#module-django.forms>
- Forms tutorial <https://docs.djangoproject.com/en/1.9/topics/forms/>
- New Forms <https://docs.djangoproject.com/en/1.9/topics/forms/>
- Forms from models <https://docs.djangoproject.com/en/1.9/topics/forms/modelforms/>
2 changes: 0 additions & 2 deletions docs/python/django/index.md
Expand Up @@ -2,8 +2,6 @@
title: Django webframework
subtitle: Python Webframework
layout: category_posts
childs:
- "concepts"
---

Main links
Expand Down
5 changes: 5 additions & 0 deletions docs/ruby/rails/index.md
@@ -0,0 +1,5 @@
---
title: Ruby on Rails
subtitle:
layout: category_posts
---
7 changes: 5 additions & 2 deletions docs/html/index.md → docs/web/html/index.md
Expand Up @@ -10,7 +10,10 @@ childs: [""]
Useful Links
============

+ Latest HTML specification version: <https://www.w3.org/TR/html/>
+ HTML5 specification: <https://www.w3.org/TR/html5/>
+ Editor's draft: <http://w3c.github.io/html/>
+ HTML specification
+ Latest <https://www.w3.org/TR/html/>
+ HTML 5 <https://www.w3.org/TR/html5/>
+ HTML 5.1 <https://www.w3.org/TR/html51/>
+ All the HTML tags: <https://developer.mozilla.org/en-US/docs/Web/HTML/Element>
+ [HTML Wikipedia](https://en.wikipedia.org/wiki/HTML/)
File renamed without changes.
6 changes: 6 additions & 0 deletions docs/web/index.md
@@ -0,0 +1,6 @@
---
title: Web
subtitle:
layout: category_posts
---

12 changes: 12 additions & 0 deletions docs/web/structured-data/index.md
@@ -0,0 +1,12 @@
---
title: Structured Data Markups
subtitle:
layout: category_posts
---

## Links

- JSON-LD <http://json-ld.org/>
- Microdata <https://www.w3.org/TR/microdata/>
- RDFa <https://rdfa.info/>

6 changes: 6 additions & 0 deletions index.html
Expand Up @@ -6,6 +6,12 @@
Practical concepts, theory and tutorials.
---

<hr>
<div class="text-xs-center m-y-3">
{{ page.description }}
</div>
<hr>

<div class="home">

<div class="">
Expand Down

0 comments on commit 3b182d4

Please sign in to comment.