-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from jedymatt/add-docs
Add docs
- Loading branch information
Showing
5 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Relationships | ||
============= | ||
|
||
To add reference attribute, | ||
add prefix to the attribute to differentiate reference attribute from normal ones. | ||
|
||
.. code-block:: json | ||
{ | ||
"model": "models.Employee", | ||
"data": { | ||
"name": "John Smith", | ||
"!company": { | ||
"model": "models.Company", | ||
"data": { | ||
"name": "MyCompany" | ||
} | ||
} | ||
} | ||
} | ||
Base on the example above, **name** is a normal attribute and **!company** is a reference attribute | ||
which translates to ``Employee.name`` and ``Employee.company``, respectively. | ||
|
||
.. note:: | ||
The default reference prefix is ``!`` and can be customized. | ||
|
||
Reference attribute can either be foreign key or relationship attribute. | ||
|
||
Customizing prefix | ||
------------------ | ||
If you want '@' as prefix, | ||
you can just specify it to what seeder you use by | ||
adding ref_prefix='@' in the argument when initializing a seeder class. | ||
|
||
.. code-block:: python | ||
seeder = Seeder(session, ref_prefix='@') | ||