Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Django Favicon Plus Reloaded
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Libraries
Django Favicon Plus Reloaded
Commits
8d492255
Commit
8d492255
authored
4 years ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Use Django-media instead of static files
parent
2d7b5c7c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
favicon/models.py
+3
-3
3 additions, 3 deletions
favicon/models.py
favicon/templatetags/favtags.py
+3
-4
3 additions, 4 deletions
favicon/templatetags/favtags.py
with
6 additions
and
7 deletions
favicon/models.py
+
3
−
3
View file @
8d492255
...
...
@@ -19,7 +19,7 @@ config = {
config
=
getattr
(
settings
,
'
FAVICON_CONFIG
'
,
config
)
image_path
=
os
.
path
.
join
(
settings
.
STATIC_ROOT
,
getattr
(
settings
,
"
FAVICON_PATH
"
,
"
favicon
"
)
)
image_path
=
getattr
(
settings
,
"
FAVICON_PATH
"
,
"
favicon
"
)
def
pre_delete_image
(
sender
,
instance
,
**
kwargs
):
...
...
@@ -28,7 +28,7 @@ def pre_delete_image(sender, instance, **kwargs):
class
Favicon
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
)
faviconImage
=
models
.
ImageField
(
upload_to
=
settings
.
STATIC_ROOT
+
"
favicon
"
)
faviconImage
=
models
.
ImageField
(
upload_to
=
image_path
)
isFavicon
=
models
.
BooleanField
(
default
=
True
)
...
...
@@ -97,7 +97,7 @@ class FaviconImg(models.Model):
faviconFK
=
models
.
ForeignKey
(
Favicon
,
on_delete
=
models
.
CASCADE
)
size
=
models
.
IntegerField
()
rel
=
models
.
CharField
(
max_length
=
250
,
null
=
True
)
faviconImage
=
models
.
ImageField
(
upload_to
=
'
favicon
'
)
faviconImage
=
models
.
ImageField
(
upload_to
=
image_path
)
def
del_image
(
self
):
self
.
faviconImage
.
delete
()
...
...
This diff is collapsed.
Click to expand it.
favicon/templatetags/favtags.py
+
3
−
4
View file @
8d492255
from
django
import
template
from
django.utils.safestring
import
mark_safe
from
django.conf.urls.static
import
static
from
favicon.models
import
Favicon
,
config
...
...
@@ -14,7 +13,7 @@ def place_favicon(context):
Template Syntax:
{% place
F
avicon %}
{% place
_f
avicon %}
"""
fav
=
Favicon
.
objects
.
filter
(
isFavicon
=
True
).
first
()
...
...
@@ -24,10 +23,10 @@ def place_favicon(context):
for
rel
in
config
:
for
size
in
sorted
(
config
[
rel
],
reverse
=
True
):
n
=
fav
.
get_favicon
(
size
=
size
,
rel
=
rel
)
html
+=
f
'
<link rel=
"
{
n
.
rel
}
"
sizes=
"
{
n
.
size
}
x
{
n
.
size
}
"
href=
"
{
static
(
n
.
faviconImage
.
url
)
}
"
/>
'
html
+=
f
'
<link rel=
"
{
n
.
rel
}
"
sizes=
"
{
n
.
size
}
x
{
n
.
size
}
"
href=
"
{
n
.
faviconImage
.
url
}
"
/>
'
default_fav
=
fav
.
get_favicon
(
size
=
32
,
rel
=
'
shortcut icon
'
)
html
+=
f
'
<link rel=
"
{
default_fav
.
rel
}
"
sizes=
"
{
default_fav
.
size
}
x
{
default_fav
.
size
}
"
\
href=
"
{
static
(
default_fav
.
faviconImage
.
url
)
}
"
/>
'
href=
"
{
default_fav
.
faviconImage
.
url
}
"
/>
'
return
mark_safe
(
html
)
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