-
Notifications
You must be signed in to change notification settings - Fork 5
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 #7 from wharton/feature/add-suffix-settings
Adds a setting to customize the var suffix.
- Loading branch information
Showing
4 changed files
with
29 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
import keyword | ||
|
||
from django.conf import settings | ||
|
||
def get_reserved_words_to_append_underscore(): | ||
|
||
def get_reserved_words_to_append_suffix(): | ||
""" | ||
A list of reserved words list that can not be used for Django field names. This | ||
includes the Python reserved words list, and additional fields not allowed by | ||
Django REST Framework. | ||
We will append `_var` to the model field names and map to the underlying database | ||
column in the models in the code generator. | ||
We will append the value returned by `get_reserved_word_suffix` to the model field | ||
names and map to the underlying database column in the models in the code generator. | ||
""" | ||
reserved_words = keyword.kwlist | ||
reserved_words.append("format") | ||
|
||
return reserved_words | ||
|
||
|
||
def get_reserved_word_suffix(): | ||
""" | ||
Returns the Django setting for the reserved word suffix, or the default of `var`. | ||
""" | ||
|
||
return getattr(settings, "AUTOMAGIC_REST_RESERVED_WORD_SUFFIX", "var") |
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