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!
Related
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:
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')
I am developing Django (1.6) app. In my app I have to use the static images to be displayed on the HTML pages (like magnifying glass for search box,logo,etc). After little bit of research I came to know that we have to create a folder (say "static") which holds the static images and then I have mention the path in my settings.py like shown below :
`STATIC_URL = '/static/'
STATICFILES_DIRS = (
"C:/Users/Welcome/Desktop/business/static/polls",
"C:/Users/Welcome/Desktop/business/static",
)`
I also added the code shown below in urls.py too after which I could get the images on my HTML pages.
urlpatterns = patterns(''......... ...........) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
My question now is every time I change the directory (current working directory or if I transfer the project to another pc ) I have to update the path in settings.py.
How to not do that ? how to get path of "static" folder automatically when I run my project. Please do help. What I'm missing ?
Normally the static files finder of django will expect that your app itself has a static sub-directory, and you can store everything there.
+ myproj
- manage.py
+ app
- __init__.py
- settings.py
- urls.py
+ static <-- notice the static directory.
+ templates
This is good of course for development where the Django server is the one serving these static files. In production you'll need to collect everything to the location declared in your STATIC_ROOT setting with the collectstatic management command.
This way you won't need to change the location each time you copy your project to a new location or a new computer.
Of course, that once you do that you can drop the STATICFILES_DIRS definition from your settings.py. This setting is used to tell Django that there are other static assets that reside outside of a certain app. If you want to use it anyway then you can define those directories relative to the project itself, i.e.:
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static")
)
Your urls.py should then use the staticfiles_urlpatterns like this:
if settings.DEBUG:
urlpatterns += staticfiles_urlpatterns()
For more information see the Django documentation on static files:
https://docs.djangoproject.com/en/1.7/howto/static-files/
I just figured out the solution for my question. First you need to get the current working directory and then for looking out for the folder in that current working directory(where your project is being installed) assign this to variable say path_for_images and then pass it to the STATICFILES_DIR as shown below:
path_for_images = os.getcwd()+"\static"
STATICFILES_DIRS = ( path_for images,) <-- note ,(comma) after `path_for_images`
No need to do any changes for the urls.py and images get loaded. This isn't exact pythonic way but it's surely one of the way.
I'm trying to combine Django with Jade, but I've had some problems.
I have model which is named About. This has a view like this:
def about(request):
return render_to_response('about.jade',{},RequestContext(request))
and in my urls I have:
url(r'about/', views.about),
But it provides an error that the Templates doesn't exist (and yes, it exists). Is it correct to write the url like this?
Any help would be appreciated!
If your getting the big Template does not exist page in your browser, this usually means that django cannot find where you have stored the your template file (irrespective of using jade).
If you ve created a djnago 1.6 project you need to add the following line to settings:
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
Then create a templates directory inside your app (not project) directory, and put your template there.
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