Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
99
Issue boards
Milestones
Wiki
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp
Commits
ed5dc655
Commit
ed5dc655
authored
5 years ago
by
Jean-Baptiste
Browse files
Options
Downloads
Patches
Plain Diff
update: automaticaly call admin.site.register for all sublclasses of djangoldp.Model
parent
468a9de9
No related branches found
No related tags found
1 merge request
!73
Resolve "admin.py"
Pipeline
#985
passed with stage
Stage: test
in 1 minute and 31 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
djangoldp/admin.py
+17
-1
17 additions, 1 deletion
djangoldp/admin.py
with
17 additions
and
1 deletion
djangoldp/admin.py
+
17
−
1
View file @
ed5dc655
from
importlib
import
import_module
from
django.conf
import
settings
from
django.contrib
import
admin
from
.models
import
LDPSource
from
.models
import
LDPSource
,
Model
for
package
in
settings
.
DJANGOLDP_PACKAGES
:
try
:
import_module
(
'
{}.models
'
.
format
(
package
))
except
ModuleNotFoundError
:
pass
model_classes
=
{
cls
.
__name__
:
cls
for
cls
in
Model
.
__subclasses__
()}
for
class_name
in
model_classes
:
model_class
=
model_classes
[
class_name
]
if
not
admin
.
site
.
is_registered
(
model_class
):
admin
.
site
.
register
(
model_class
)
admin
.
site
.
register
(
LDPSource
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment