Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Samir
django-cas-server
Commits
29522aad
Commit
29522aad
authored
Aug 06, 2016
by
Valentin Samir
Browse files
Usage of the documented API for models _meta
parent
d0e92ed8
Changes
1
Hide whitespace changes
Inline
Side-by-side
cas_server/auth.py
View file @
29522aad
...
...
@@ -369,8 +369,16 @@ class DjangoAuthUser(AuthUser): # pragma: no cover
"""
if
self
.
user
:
attr
=
{}
for
field
in
self
.
user
.
_meta
.
fields
:
attr
[
field
.
attname
]
=
getattr
(
self
.
user
,
field
.
attname
)
# _meta.get_fields() is from the new documented _meta interface in django 1.8
try
:
field_names
=
[
field
.
attname
for
field
in
self
.
user
.
_meta
.
get_fields
()
if
hasattr
(
field
,
"attname"
)
]
# backward compatibility with django 1.7
except
AttributeError
:
# pragma: no cover (only used by django 1.7)
field_names
=
self
.
user
.
_meta
.
get_all_field_names
()
for
name
in
field_names
:
attr
[
name
]
=
getattr
(
self
.
user
,
name
)
return
attr
else
:
return
{}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment