<commit_before>Quick How to
============

The Base Skeleton Application
-----------------------------

If your working with the base skeleton application :doc:`instalation`

you now have the following directory structure::

    <your project name>/
        config.py : All the applications configuration
        run.py    : A runner mainly for debug
        app/
            __init__.py : Application's initialization
            models.py : Declare your database models here
            views.py  : Implement your views here

    
It's very easy and fast to create an application out of the box, with detailed security.

Please take a look at github `examples <https://github.com/dpgaspar/Flask-AppBuilder/tree/master/examples>`_


Simple contacts application
---------------------------

Lets create a very simple contacts application.

First we are going to create a *Group* table, to group our contacts

Define your models (models.py)
------------------------------

The group table.

::

        class Group(db.Model):
            id = db.Column(db.Integer, primary_key=True)
            name = db.Column(db.String(50), unique = True, nullable=False)

            def __repr__(self):
                return self.name

An *Contacts* table.

::

	class Contact(db.Model):
	    id = db.Column(db.Integer, primary_key=True)
	    name =  db.Column(db.String(150), unique = True, nullable=False)
	    address =  db.Column(db.String(564))
	    birthday = db.Column(db.Date)
	    personal_phone = db.Column(db.String(20))
	    personal_celphone = db.Column(db.String(20))
	    group_id = db.Column(db.Integer, db.ForeignKey('group.id'))
	    group = db.relationship("Group")	
	    <commit_msg>Update quickhowto.rst<commit_after>Quick How to
============

The Base Skeleton Application
-----------------------------

If your working with the base skeleton application :doc:`instalation`

you now have the following directory structure::

    <your project name>/
        config.py : All the applications configuration
        run.py    : A runner mainly for debug
        app/
            __init__.py : Application's initialization
            models.py : Declare your database models here
            views.py  : Implement your views here

    
It's very easy and fast to create an application out of the box, with detailed security.

Please take a look at github `examples <https://github.com/dpgaspar/Flask-AppBuilder/tree/master/examples>`_


Simple contacts application
---------------------------

Lets create a very simple contacts application.

First we are going to create a *Group* table, to group our contacts

.. note::
	Since version 0.3.9 i advise not using Flask-SqlAlchemy to define your tables, because you will be in a diferent declarative model of the security tables of AppBuilder.

	Use BaseMixin to have automatic table name baptism like in Flask-SqlAlchemy, and inherit also from Base, that you import::

		flask.ext.appbuilder import Base
	

Define your models (models.py)
------------------------------

The group table.

::

        class Group(BaseMixin, Base):
            id = Column(Integer, primary_key=True)
            name = Column(String(50), unique = True, nullable=False)

            def __repr__(self):
                return self.name

An *Contacts* table.

::

	class Contact(BaseMixin, Base):
	    id = Column(Integer, primary_key=True)
	    name =  Column(String(150), unique = True, nullable=False)
	    address =  Column(String(564))
	    birthday = Column(Date)
	    personal_phone = Column(String(20))
	    personal_celphone = Column(String(20))
	    group_id = Column(Integer, ForeignKey('group.id'))
	    group = relationship("Group")	
	    
{'fraction_non_alphanumeric': 0.13266413456321216, 'fraction_numerical': 0.007325013564839935, 'mean_word_length': 2.5047528517110265, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4510593', 'n_tokens_mistral': 1041, 'n_tokens_neox': 970, 'n_words': 345}