404
+ +Page not found
+ + +diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/404.html b/404.html new file mode 100644 index 0000000..22fafab --- /dev/null +++ b/404.html @@ -0,0 +1,113 @@ + + +
+ + + + +Page not found
+ + +By default, the admin interface is login and permission protected. +It means, the user with permission only can perform operation for model navigation.
+However, you can implement your custom permission check manually.
+from dj_admin_plus.navigation import Navigation
+
+
+def can_access_dashboard(request):
+ return False # Return a boolean value
+
+
+...
+
+Navigation(
+ _id='dashboard',
+ title='Dashboard',
+ icon_class='fa-gauge-high',
+ permission_check=can_access_dashboard # Add your custom permission check here
+)
+...
+
+
+ Django admin plus helps you to create beautiful admin interface in minimal steps.
+ +pip install -i https://test.pypi.org/simple/ dj-admin-plus==0.0.6
+
+Add DJ Admin plus in your installed apps.
+INSTALLED_APPS = [
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+
+ 'dj_admin_plus', # Add DJ Admin plus
+]
+
+Add new admin interface to the urls.py file.
+from django.conf import settings
+from django.conf.urls.static import static
+from django.contrib import admin
+from django.urls import path, include
+
+urlpatterns = [
+ path('admin/', include('dj_admin_plus.urls')), # Add DJ Admin plus
+ path('classic/', admin.site.urls), # Old admin interface still works
+]
+
+urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+
+
+You need to register your navigation according to your need either in models.py or views.py in one +of the installed apps.
+For example, update your models.py
.
from django.contrib.auth import get_user_model
+
+from dj_admin_plus import navigation
+from dj_admin_plus.navigation import Navigation
+
+from test_app.models import Blog, Category
+
+navigation.register([
+ Navigation(
+ _id='dashboard',
+ title='Dashboard',
+ icon_class='fa-gauge-high',
+ url='/dashboard/'
+ ),
+
+ Navigation(
+ _id='blog',
+ title='Blog',
+ icon_class='fa-file',
+ model=Blog,
+ children=[
+ Navigation(_id='all_posts', title='All Posts', model=Blog),
+ Navigation(_id='categories', title='Categories', model=Category)
+ ]
+ ),
+
+ Navigation(_id='users', title='Users', icon_class='fa-user', model=get_user_model()),
+
+ Navigation(_id='settings', title='Settings', icon_class='fa-gear')
+])
+
+For sidebar icons, DJ Admin plus uses free font awesome solid icons.
+You need to choose the default page when http://127.0.0.1:8000 is visited. +It is because DJ Admin plus don't know which page to show first until you specify.
+There are two ways to set up default page in DJ Admin plus.
+You need to pass extra argument select_fallback_first=True
.
from dj_admin_plus import navigation
+
+navigation.register([...], select_fallback_first=True)
+
+In this method, when you access the admin page, it will redirect to the first navigation item you specified in register +method.
+The above method may be unsuitable for you when you want to display a navigation like dashboard when the admin page is +accessed.
+It is because the above method adds the additional path which makes the url like +http://127.0.0.1:8001/admin/dashboard/ instead.
+Here is a minimal example.
+Create a new dashboard.html
for dashboard view.
{% extends "dj_admin_plus/base.html" %}
+
+{% block content %}
+{% include 'dj_admin_plus/title.html' with title='Dashboard' %}
+
+<p>Your custom code</p>
+{% endblock %}
+
+In your views views.py
file:
from django.shortcuts import render
+
+
+def dashboard_view(request):
+ return render(request, 'dashboard.html')
+
+Update your previous navigation register to:
+from dj_admin_plus import navigation
+from dj_admin_plus.navigation import Navigation
+
+from test_app.views import dashboard_view
+
+navigation.register([
+ Navigation(
+ _id='dashboard',
+ title='Dashboard',
+ icon_class='fa-gauge-high',
+ view=dashboard_view # Change to view instead
+ ),
+ ...
+])
+
+
+ ' + escapeHtml(summary) +'
' + noResultsText + '
'); + } +} + +function doSearch () { + var query = document.getElementById('mkdocs-search-query').value; + if (query.length > min_search_length) { + if (!window.Worker) { + displayResults(search(query)); + } else { + searchWorker.postMessage({query: query}); + } + } else { + // Clear results for short queries + displayResults([]); + } +} + +function initSearch () { + var search_input = document.getElementById('mkdocs-search-query'); + if (search_input) { + search_input.addEventListener("keyup", doSearch); + } + var term = getSearchTermFromLocation(); + if (term) { + search_input.value = term; + doSearch(); + } +} + +function onWorkerMessage (e) { + if (e.data.allowSearch) { + initSearch(); + } else if (e.data.results) { + var results = e.data.results; + displayResults(results); + } else if (e.data.config) { + min_search_length = e.data.config.min_search_length-1; + } +} + +if (!window.Worker) { + console.log('Web Worker API not supported'); + // load index in main thread + $.getScript(joinUrl(base_url, "search/worker.js")).done(function () { + console.log('Loaded worker'); + init(); + window.postMessage = function (msg) { + onWorkerMessage({data: msg}); + }; + }).fail(function (jqxhr, settings, exception) { + console.error('Could not load worker.js'); + }); +} else { + // Wrap search in a web worker + var searchWorker = new Worker(joinUrl(base_url, "search/worker.js")); + searchWorker.postMessage({init: true}); + searchWorker.onmessage = onWorkerMessage; +} diff --git a/search/search_index.json b/search/search_index.json new file mode 100644 index 0000000..3aab874 --- /dev/null +++ b/search/search_index.json @@ -0,0 +1 @@ +{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"Django Admin Plus Django admin plus helps you to create beautiful admin interface in minimal steps. Installation pip install -i https://test.pypi.org/simple/ dj-admin-plus==0.0.6 Update your settings file Add DJ Admin plus in your installed apps. INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'dj_admin_plus', # Add DJ Admin plus ] Configure urls Add new admin interface to the urls.py file. from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', include('dj_admin_plus.urls')), # Add DJ Admin plus path('classic/', admin.site.urls), # Old admin interface still works ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) Register navigation You need to register your navigation according to your need either in models.py or views.py in one of the installed apps. For example, update your models.py . from django.contrib.auth import get_user_model from dj_admin_plus import navigation from dj_admin_plus.navigation import Navigation from test_app.models import Blog, Category navigation.register([ Navigation( _id='dashboard', title='Dashboard', icon_class='fa-gauge-high', url='/dashboard/' ), Navigation( _id='blog', title='Blog', icon_class='fa-file', model=Blog, children=[ Navigation(_id='all_posts', title='All Posts', model=Blog), Navigation(_id='categories', title='Categories', model=Category) ] ), Navigation(_id='users', title='Users', icon_class='fa-user', model=get_user_model()), Navigation(_id='settings', title='Settings', icon_class='fa-gear') ]) For sidebar icons, DJ Admin plus uses free font awesome solid icons . Configure default navigation page You need to choose the default page when http://127.0.0.1:8000 is visited. It is because DJ Admin plus don't know which page to show first until you specify. There are two ways to set up default page in DJ Admin plus. Option 1: Set first navigation as a default page You need to pass extra argument select_fallback_first=True . from dj_admin_plus import navigation navigation.register([...], select_fallback_first=True) In this method, when you access the admin page, it will redirect to the first navigation item you specified in register method. Option2: Using Django view The above method may be unsuitable for you when you want to display a navigation like dashboard when the admin page is accessed. It is because the above method adds the additional path which makes the url like http://127.0.0.1:8001/admin/dashboard/ instead. Create a new view Here is a minimal example. Create a new dashboard.html for dashboard view. {% extends \"dj_admin_plus/base.html\" %} {% block content %} {% include 'dj_admin_plus/title.html' with title='Dashboard' %}Your custom code
{% endblock %} In your views views.py file: from django.shortcuts import render def dashboard_view(request): return render(request, 'dashboard.html') Update your previous navigation register to: from dj_admin_plus import navigation from dj_admin_plus.navigation import Navigation from test_app.views import dashboard_view navigation.register([ Navigation( _id='dashboard', title='Dashboard', icon_class='fa-gauge-high', view=dashboard_view # Change to view instead ), ... ])","title":"Getting Started"},{"location":"#django-admin-plus","text":"Django admin plus helps you to create beautiful admin interface in minimal steps.","title":"Django Admin Plus"},{"location":"#installation","text":"pip install -i https://test.pypi.org/simple/ dj-admin-plus==0.0.6","title":"Installation"},{"location":"#update-your-settings-file","text":"Add DJ Admin plus in your installed apps. INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'dj_admin_plus', # Add DJ Admin plus ]","title":"Update your settings file"},{"location":"#configure-urls","text":"Add new admin interface to the urls.py file. from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', include('dj_admin_plus.urls')), # Add DJ Admin plus path('classic/', admin.site.urls), # Old admin interface still works ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)","title":"Configure urls"},{"location":"#register-navigation","text":"You need to register your navigation according to your need either in models.py or views.py in one of the installed apps. For example, update your models.py . from django.contrib.auth import get_user_model from dj_admin_plus import navigation from dj_admin_plus.navigation import Navigation from test_app.models import Blog, Category navigation.register([ Navigation( _id='dashboard', title='Dashboard', icon_class='fa-gauge-high', url='/dashboard/' ), Navigation( _id='blog', title='Blog', icon_class='fa-file', model=Blog, children=[ Navigation(_id='all_posts', title='All Posts', model=Blog), Navigation(_id='categories', title='Categories', model=Category) ] ), Navigation(_id='users', title='Users', icon_class='fa-user', model=get_user_model()), Navigation(_id='settings', title='Settings', icon_class='fa-gear') ]) For sidebar icons, DJ Admin plus uses free font awesome solid icons .","title":"Register navigation"},{"location":"#configure-default-navigation-page","text":"You need to choose the default page when http://127.0.0.1:8000 is visited. It is because DJ Admin plus don't know which page to show first until you specify. There are two ways to set up default page in DJ Admin plus.","title":"Configure default navigation page"},{"location":"#option-1-set-first-navigation-as-a-default-page","text":"You need to pass extra argument select_fallback_first=True . from dj_admin_plus import navigation navigation.register([...], select_fallback_first=True) In this method, when you access the admin page, it will redirect to the first navigation item you specified in register method.","title":"Option 1: Set first navigation as a default page"},{"location":"#option2-using-django-view","text":"The above method may be unsuitable for you when you want to display a navigation like dashboard when the admin page is accessed. It is because the above method adds the additional path which makes the url like http://127.0.0.1:8001/admin/dashboard/ instead.","title":"Option2: Using Django view"},{"location":"#create-a-new-view","text":"Here is a minimal example. Create a new dashboard.html for dashboard view. {% extends \"dj_admin_plus/base.html\" %} {% block content %} {% include 'dj_admin_plus/title.html' with title='Dashboard' %}Your custom code
{% endblock %} In your views views.py file: from django.shortcuts import render def dashboard_view(request): return render(request, 'dashboard.html') Update your previous navigation register to: from dj_admin_plus import navigation from dj_admin_plus.navigation import Navigation from test_app.views import dashboard_view navigation.register([ Navigation( _id='dashboard', title='Dashboard', icon_class='fa-gauge-high', view=dashboard_view # Change to view instead ), ... ])","title":"Create a new view"},{"location":"advanced-usage/","text":"DJ Admin plus Permission By default, the admin interface is login and permission protected. It means, the user with permission only can perform operation for model navigation. However, you can implement your custom permission check manually. from dj_admin_plus.navigation import Navigation def can_access_dashboard(request): return False # Return a boolean value ... Navigation( _id='dashboard', title='Dashboard', icon_class='fa-gauge-high', permission_check=can_access_dashboard # Add your custom permission check here ) ...","title":"Advanced Usage"},{"location":"advanced-usage/#dj-admin-plus","text":"","title":"DJ Admin plus"},{"location":"advanced-usage/#permission","text":"By default, the admin interface is login and permission protected. It means, the user with permission only can perform operation for model navigation. However, you can implement your custom permission check manually. from dj_admin_plus.navigation import Navigation def can_access_dashboard(request): return False # Return a boolean value ... Navigation( _id='dashboard', title='Dashboard', icon_class='fa-gauge-high', permission_check=can_access_dashboard # Add your custom permission check here ) ...","title":"Permission"}]} \ No newline at end of file diff --git a/search/worker.js b/search/worker.js new file mode 100644 index 0000000..8628dbc --- /dev/null +++ b/search/worker.js @@ -0,0 +1,133 @@ +var base_path = 'function' === typeof importScripts ? '.' : '/search/'; +var allowSearch = false; +var index; +var documents = {}; +var lang = ['en']; +var data; + +function getScript(script, callback) { + console.log('Loading script: ' + script); + $.getScript(base_path + script).done(function () { + callback(); + }).fail(function (jqxhr, settings, exception) { + console.log('Error: ' + exception); + }); +} + +function getScriptsInOrder(scripts, callback) { + if (scripts.length === 0) { + callback(); + return; + } + getScript(scripts[0], function() { + getScriptsInOrder(scripts.slice(1), callback); + }); +} + +function loadScripts(urls, callback) { + if( 'function' === typeof importScripts ) { + importScripts.apply(null, urls); + callback(); + } else { + getScriptsInOrder(urls, callback); + } +} + +function onJSONLoaded () { + data = JSON.parse(this.responseText); + var scriptsToLoad = ['lunr.js']; + if (data.config && data.config.lang && data.config.lang.length) { + lang = data.config.lang; + } + if (lang.length > 1 || lang[0] !== "en") { + scriptsToLoad.push('lunr.stemmer.support.js'); + if (lang.length > 1) { + scriptsToLoad.push('lunr.multi.js'); + } + if (lang.includes("ja") || lang.includes("jp")) { + scriptsToLoad.push('tinyseg.js'); + } + for (var i=0; i < lang.length; i++) { + if (lang[i] != 'en') { + scriptsToLoad.push(['lunr', lang[i], 'js'].join('.')); + } + } + } + loadScripts(scriptsToLoad, onScriptsLoaded); +} + +function onScriptsLoaded () { + console.log('All search scripts loaded, building Lunr index...'); + if (data.config && data.config.separator && data.config.separator.length) { + lunr.tokenizer.separator = new RegExp(data.config.separator); + } + + if (data.index) { + index = lunr.Index.load(data.index); + data.docs.forEach(function (doc) { + documents[doc.location] = doc; + }); + console.log('Lunr pre-built index loaded, search ready'); + } else { + index = lunr(function () { + if (lang.length === 1 && lang[0] !== "en" && lunr[lang[0]]) { + this.use(lunr[lang[0]]); + } else if (lang.length > 1) { + this.use(lunr.multiLanguage.apply(null, lang)); // spread operator not supported in all browsers: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator#Browser_compatibility + } + this.field('title'); + this.field('text'); + this.ref('location'); + + for (var i=0; i < data.docs.length; i++) { + var doc = data.docs[i]; + this.add(doc); + documents[doc.location] = doc; + } + }); + console.log('Lunr index built, search ready'); + } + allowSearch = true; + postMessage({config: data.config}); + postMessage({allowSearch: allowSearch}); +} + +function init () { + var oReq = new XMLHttpRequest(); + oReq.addEventListener("load", onJSONLoaded); + var index_path = base_path + '/search_index.json'; + if( 'function' === typeof importScripts ){ + index_path = 'search_index.json'; + } + oReq.open("GET", index_path); + oReq.send(); +} + +function search (query) { + if (!allowSearch) { + console.error('Assets for search still loading'); + return; + } + + var resultDocuments = []; + var results = index.search(query); + for (var i=0; i < results.length; i++){ + var result = results[i]; + doc = documents[result.ref]; + doc.summary = doc.text.substring(0, 200); + resultDocuments.push(doc); + } + return resultDocuments; +} + +if( 'function' === typeof importScripts ) { + onmessage = function (e) { + if (e.data.init) { + init(); + } else if (e.data.query) { + postMessage({ results: search(e.data.query) }); + } else { + console.error("Worker - Unrecognized message: " + e); + } + }; +} diff --git a/sitemap.xml b/sitemap.xml new file mode 100644 index 0000000..0f8724e --- /dev/null +++ b/sitemap.xml @@ -0,0 +1,3 @@ + +