I want to integrate AdmineLTE to my django project, with the help of its
README file.
https://github.com/StephenPCG/django-adminlte-templates
I followed all steps required in the file, but when I'm running my app, and want to login, I'm getting the following error.
You're using the staticfiles app without having set the required STATIC_URL setting.
which come from here
django-adminlte-templates/AdminLTE/templatetags/AdminLTE.py in <module>
bootstrap_url_base = _bootstrap_url_base if _bootstrap_url_base else static('bootstrap')
Related
I hope you are well.
The reason i'm writing to you is because ive been utilizing the Django cms bootstrap carousel plug in.
Im all set however i am struggling to figure out how to add me newly added custom template to my application.
Im wondering if there is something i need to add to my settings.py file like CAROUSEL_TEMPLATES = [ ' ' ]
I am not using setup.py
All of the applications are installed via requirements.txt
static and troage files are in AWS and templates are served from the source code of the applictation.
I would be very grateful if you could point me in the right direction?
Djangocms version: Django-cms 3.10
Django version : Django==3.2
Plug in im using: djangocms-bootstrap 1.1.2
The default setting for these templates is;
DJANGOCMS_BOOTSTRAP4_CAROUSEL_TEMPLATES = (
('default', _('Default')),
)
And you can see those default templates here.
So that default path within the templates directory looks like templates/djangocms_bootstrap4/carousel/default
Assuming you have a set of templates you called theme you'd change that setting to;
DJANGOCMS_BOOTSTRAP4_CAROUSEL_TEMPLATES = (
('default', _('Default')),
('theme', _('Theme')),
)
And you would add your templates in the following directory;
templates/djangocms_bootstrap4/carousel/theme
It all worked perfectly thank you.The only thing i had to remove the _ from your settings .py suggestion. so it workeed with the following:
DJANGOCMS_BOOTSTRAP4_CAROUSEL_TEMPLATES = (
('default', ('Default')),
('theme', ('Theme')),
)
Thanks again!
In the standard setup, Django applications are called by a WSGI server (like gunicorn and mod_wsgi) to answer HTTP requests, the entrypoint at user-level is the django View.
Can I make a custom entrypoint to call Django apps? If so, How I properly load a Django app?
Edit: Looking at the entrypoint in the wsgi.py file made by the startproject command, I see that 1) it sets the DJANGO_SETTINGS_MODULE var and calls get_wsgi_application which 2) calls django.setup() and 3) returns a WSGI application that will be called by the WSGI Server. 1 and 2 also happens when django's admin commands are ran. Is it enough to do 1 and 2 and have a properly loaded Django app? At 3 the django's middlewares are loaded, but they are not compatible, since I will not be doing HTTP calls (but the Django app will, of course, answer HTTP requests coming from other clients).
Is it enough to do 1 and 2 and have a properly loaded Django app?
Looking at Django's source code and this documentation, I figured out how to load a Django app. Taking as example the Django's intro tutorial, I could load the polls app and call its index view this way:
# Let Django knows where the project's settings is.
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
from django.apps import apps
# Load the needed apps
apps.populate(installed_apps=['polls.apps.PollsConfig'])
# Make sure the above apps were loaded
apps.check_apps_ready()
apps.check_models_ready()
# Call it
from polls.views import index
# Here index view is decoupled from Django's HTTP interface, so in polls/views.py you have:
# def index():
# return Question.objects.order_by('-pub_date')[:5]
print('index view: ' + str(index()))
It does not load any of the Django middlewares (they are coupled to the HTTP interface). The polls app does not depends on other installed apps, otherwise all dependencies should be loaded too.
I am trying to make an admin panel that includes some database. I have used flask-admin to automatically generate admin panel. When I ran the server locally in my PC, the bootstrap swatch is loading and works fine. However, when I hosted it in pythonanywhere and ran, it shows that the CSS is not found as shown in the image.
I have not used any templates of my own for admin panel. I used the following code to automatically generate the template.
admin = Admin(app, name='Admin Panel', template_mode='bootstrap3')
Link for the error message.
Same happened to me, but it turned out I used an unsupported swatch, here is the code that worked
app.config['FLASK_ADMIN_SWATCH'] = 'flatly'
# Create admin with custom base template
admin = admin.Admin(app, name='XXX', template_mode='bootstrap4')
I have a Flask-Admin project set up with Flask-Security as well. It is pretty much https://pythonhosted.org/Flask-Security/quickstart.html#id1 but just more advanced. I can access the login page at localhost/login and logout and localhost/logout. The logging in and logging out works.
The templates for Flask-Admin works and everything is displayed as I'd expect. However, there are no templates on my machine or docker container where the Flask-Admin app is run. I installed Flask by running pip install Flask-Admin. I know I can over ride the security log in by adding something like
SECURITY_LOGIN_USER_TEMPLATE = 'security/login_user.html'
to the config file and uploading to /templates/security/login_user.html. There is also using
{%extends base.html}
to have a common theme. Should I have template files already in my project?
Flask Security have a default login template, if you want to use your own template for login or register follow these steps:
Create in template folder the a subfolder named security
Add your html documents to this folder
Go to your flask configuration and add the following settings:
If your want the register functionality
SECURITY_REGISTERABLE = True
Add the name of your templates:
SECURITY_LOGIN_USER_TEMPLATE = 'security/login.html'
SECURITY_REGISTER_USER_TEMPLATE = 'security/register.html'
Remember to use the appropriate form in login.html and in register.html, usually causes doubts but is simple:
register.html: register_user_form.field
login.html: login_user_form.field
These are the configurations for this work correctly.
this repository can you to see and understand better doubt:
In django how to run /admin interface as well as customized admin index page. My template dirs is followed below.
TEMPLATE_DIRS = (
PROJECT_PATH + '/templates/',
)
And...
ADMIN_MEDIA_PREFIX = '//admin/'
If i will comment this line my other functions would not work, if i put it uncommented then ma admin interface shows my specified file.
What should i do to run both simultaneously. Thanks in advance
Leave TEMPLATE_DIRS alone, that affects more than just the admin, and that's not your problem anyways.
The way to override any admin page is to include the associated template from the default Django admin templates in your own 'yourproject/templates/admin' directory, and make the necessary modifications.
See the documentation: https://docs.djangoproject.com/en/1.3/ref/contrib/admin/#overriding-admin-templates