I have django-admin-interface installed in my django app. The problem is that when I try to upload a logo it says that all is okay but the logo doesn't show.
Logo uploaded correctly but not showing
I want to change the default Django logo.
Is there any way to accomplish this?
Create a new template and extends the 'admin' template like below to override the default admin template.
{% extends "admin/base.html" %}
{% block branding %}
<h1 id="site-name">MY_LOGO_OR_TEXT</h1>
{% endblock %}
In the code above, change the MY_LOGO_OR_TEXT section with your html logo or just text to be shown on the admin panel like you wanted.
ADMIN
Related
I am trying to create template inheritance using Jinja2. I am using (basic.py) to define app and render "home.html". I created base.html as framework file that I want to inherit in home.html. Problem is that that the code
{% block content %}
{% endblock %}
in my base1.html file is not getting recognized when I run base.py. These lines of code are greyed out in PyCharm pro editor Also, the following code in home.html that I am using to extend base.html is also not working (greyed out):
{% extends [enter image description here][1]base1.html %}
{% block content%}
<h1>Hello, How are you?</h1>
{% endblock %}
I appreciate any help as there don't seem to be many direct answers available either on PyCharm site or anywhere else. Please see attached picture of code files. I do already have installed Flask package in my project.
i found a solution that worked. the solution is to select Jinja2 as the template language for for HTML template file type.enter image description here
I have created a Django App and want to provide a custom Login page with only the possibility to use a Google login.
I have implemented the Google login based on this post: https://www.section.io/engineering-education/django-google-oauth/
It actually works fine and when I hit localhost/account/login I am getting a login page:
I actually do not want a sign up and a "local" sign in option, I only need a Google login.
To achieve this I have created the following folder structure to overwrite the login template (based on https://learndjango.com/tutorials/django-login-and-logout-tutorial):
MyApp/templaltes/registration/login.html
login.html has the following content:
{% extends "base.html" %}
{% load i18n %}
{% load socialaccount %}
{% block content %}
<div class="row">
<center><h1>{% trans 'LoginHeading' %}</h1></center>
</div>
{% if user.is_authenticated %}
<p>Welcome, You are logged in as {{ user.username }}</p>
{% else %}
Login With Google
{% endif %}
{% endblock %}
I have also added 'DIRS': [str(BASE_DIR.joinpath('templates'))] to the TEMPLATES section in settings.py.
Unfortunately I am still seeing the Django default login page. What am I missing?
(I have also restarted the dev server to make sure it is not an issue there with the same result)
I have figured it out. After reading the documentation of Allauth throughly I found this:
For instance, the view corresponding to the account_login URL uses the
template account/login.html. If you create a file with this name in
your code layout, it can override the one shipped with allauth.
So I changed the folder structure to account/login.html and it works.
To do this thing you can simply create an account folder under the template and add login.html inside it.
This will override your login page.
Make sure that folder name must be account.
In your case, you can rename your folder from "registration" to "account".
Like following:
I am sure this will work well.
Simple solution is to add
SOCIALACCOUNT_LOGIN_ON_GET=True
to your settings.py and it should skip/bypass the sign up form.
Credits: https://stackoverflow.com/a/70680165/11605100
Still does not work?
Stop the server and then;
python manage.py migrate
python manage.py makemigrations
python manage.py runserver
I am editing the template of admins
I successfully override the each model's edit page.
/myapp/template/admin/modelA/change_list_results
/myapp/template/admin/modelB/change_list_results
However how can I override the top of admin??
After login, there is a application and table lists.
I tried to override these below from /django/contrib/admin/templates/admin/ folder
/myapp/template/admin/app_index
/myapp/template/admin/index
/myapp/template/admin/base
However , still in vain.
Try to override base_site.html and include base.html using extends. I use this method to override branding.
tempaltes/admin/base_site.html
{% extends "admin/base.html" %}
{% block branding %}
<h1 id="site-name">
Name of the site
</h1>
{% endblock %}
I'm using django-cms admin style. I managed to change the default DjangoCMS logo, by following the solution mentioned here:
Django cms 3.4.1 admin dlogo
Now the logo is a static one, but I want it to be dynamic, meaning it should get the image path from the database, where the location is stored.
As these admin pages are not render through views.py, I'm not able to sent the querysets to it.
Can anyone suggest how to do it?
using context_processors we can do this.
first need to get this: https://github.com/divio/djangocms-admin-style/blob/master/djangocms_admin_style/templates/admin/inc/branding.html
branding.html file must be put inside templates folder under admin/inc folder, so the structure will be like this templates/admin/inc/branding.html
now suppose through context_processor we got company_logo, that holds the logo url from database.
then in branding.html <div id="header-logo"> would be like:
<div id="header-logo">
{% if company_logo %}
<img src="{{ company_logo.url }}" style="height:inherit;">
{% else %}
<a class="icon-logo" href="/"><span>django CMS</span></a>
{% endif %}
</div>
I have a blog running mezzanine and I can't get the right side bar to auto populate after a blog post with the information about the blog post, like author, tags, etc. The only way I can get it to show at all it to manually edit the base.html file and add a widget for each field. Isn't there a way to automate this?
Thanks again.
By default, mezzanine includes something similar to what you're asking, the filter_panel.html template. This is the template the blog app uses. In whatever template you're using, include this template in the right_panel block, eg:
{% block right_panel %}
{% include "blog/includes/filter_panel.html" %}
{% endblock %}
If you're just using base.html, you can override the right_panel block by replacing it with just the above includes tag.
Hope that helps!