forked from coagulant/django-whatever
-
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.
- Loading branch information
Showing
6 changed files
with
65 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import django | ||
|
||
if django.VERSION >= (1, 8): | ||
from django.utils.lorem_ipsum import paragraphs | ||
else: | ||
from django.contrib.webdesign.lorem_ipsum import paragraphs | ||
|
||
|
||
ipaddress_field_defined = django.VERSION < (1, 9) | ||
|
||
|
||
def get_model_onetoone_fields(model): | ||
if django.VERSION >= (1, 8): | ||
return [ | ||
(relation.name, relation) | ||
for relation in model._meta.get_fields() | ||
if relation.one_to_one and relation.auto_created | ||
] | ||
else: | ||
# procceed reversed relations | ||
return [ | ||
(relation.var_name, relation.field) | ||
for relation in model._meta.get_all_related_objects() | ||
if relation.field.unique # TODO and not relation.field.rel.parent_link ?? | ||
] | ||
|
||
|
||
def get_model_private_fields(model): | ||
if django.VERSION >= (1, 10): | ||
return model._meta.private_fields | ||
else: | ||
return model._meta.virtual_fields | ||
|
||
|
||
def get_related_field_model(field): | ||
if django.VERSION >= (1, 9): | ||
return field.target_field.model | ||
else: | ||
return field.related_field.model |
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