Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
interfect
funkwhale
Commits
38950340
Verified
Commit
38950340
authored
Oct 01, 2018
by
Eliot Berriot
Browse files
Ensure we always use raw_ids for related fields in django's admin
parent
8d75d58e
Changes
9
Hide whitespace changes
Inline
Side-by-side
api/config/urls.py
View file @
38950340
...
...
@@ -5,7 +5,7 @@ from django.conf import settings
from
django.conf.urls
import
url
from
django.urls
import
include
,
path
from
django.conf.urls.static
import
static
from
django.contrib
import
admin
from
funkwhale_api.common
import
admin
from
django.views
import
defaults
as
default_views
...
...
api/funkwhale_api/common/admin.py
0 → 100644
View file @
38950340
from
django.contrib.admin
import
register
as
initial_register
,
site
,
ModelAdmin
# noqa
from
django.db.models.fields.related
import
RelatedField
def
register
(
model
):
"""
To make the admin more performant, we ensure all the the relations
are listed under raw_id_fields
"""
def
decorator
(
modeladmin
):
raw_id_fields
=
[]
for
field
in
model
.
_meta
.
fields
:
if
isinstance
(
field
,
RelatedField
):
raw_id_fields
.
append
(
field
.
name
)
setattr
(
modeladmin
,
"raw_id_fields"
,
raw_id_fields
)
return
initial_register
(
model
)(
modeladmin
)
return
decorator
api/funkwhale_api/favorites/admin.py
View file @
38950340
from
django.contrib
import
admin
from
funkwhale_api.common
import
admin
from
.
import
models
...
...
api/funkwhale_api/federation/admin.py
View file @
38950340
from
django.contrib
import
admin
from
funkwhale_api.common
import
admin
from
.
import
models
from
.
import
tasks
...
...
api/funkwhale_api/history/admin.py
View file @
38950340
from
django.contrib
import
admin
from
funkwhale_api.common
import
admin
from
.
import
models
...
...
api/funkwhale_api/music/admin.py
View file @
38950340
from
django.contrib
import
admin
from
funkwhale_api.common
import
admin
from
.
import
models
...
...
api/funkwhale_api/playlists/admin.py
View file @
38950340
from
django.contrib
import
admin
from
funkwhale_api.common
import
admin
from
.
import
models
...
...
api/funkwhale_api/radios/admin.py
View file @
38950340
from
django.contrib
import
admin
from
funkwhale_api.common
import
admin
from
.
import
models
...
...
api/funkwhale_api/users/admin.py
View file @
38950340
...
...
@@ -2,7 +2,7 @@
from
__future__
import
absolute_import
,
unicode_literals
from
django
import
forms
from
django.contrib
import
admin
from
funkwhale_api.common
import
admin
from
django.contrib.auth.admin
import
UserAdmin
as
AuthUserAdmin
from
django.contrib.auth.forms
import
UserChangeForm
,
UserCreationForm
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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