Python environ.Env() Examples
The following are 1
code examples of environ.Env().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
environ
, or try the search function
.
Example #1
Source File: 0004_auto_20171108_1805.py From opencraft with GNU Affero General Public License v3.0 | 6 votes |
def create_watchedforks(apps, schema_editor): env = environ.Env() WatchedPullRequest = apps.get_model('pr_watch', 'WatchedPullRequest') WatchedFork = apps.get_model('pr_watch', 'WatchedFork') if WatchedPullRequest.objects.count() == 0: # This Ocim instance isn't used yet to watch PRs, so we should keep that feature disabled, therefore # we don't create any fork to watch return # To make all PR keep working, we try to use the old "watched fork name" and "watched organization" defined in # the .env file if they are still there (this will be the case when migrating instances which had PRs watcher). # After WATCH_FORK and WATCH_ORGANIZATION are removed from .env, we fall back to other sensible defaults fork_name = env("WATCH_FORK", default=getattr(settings, 'DEFAULT_FORK', None) or 'edx/edx-platform') organization = env("WATCH_ORGANIZATION", default='edx') default_fork = WatchedFork.objects.create( enabled=True, fork=fork_name, organization=organization, ) for pr in WatchedPullRequest.objects.all(): pr.watched_fork = default_fork pr.save()