Skip to content

Commit 562778e

Browse files
committed
Update readme
1 parent ef84d18 commit 562778e

File tree

3 files changed

+66
-65
lines changed

3 files changed

+66
-65
lines changed

README.md

Lines changed: 32 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
<p align="center">
2+
<picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/codingjoe/django-django-dynamic-filenames/raw/main/images/logo-dark.svg">
4+
<source media="(prefers-color-scheme: light)" srcset="https://github.com/codingjoe/django-django-dynamic-filenames/raw/main/images/logo-light.svg">
5+
<img alt="Django DynNames: Advanced filename patterns using f-Strings" src="https://github.com/codingjoe/django-django-dynamic-filenames/raw/main/images/logo-light.svg">
6+
</picture>
7+
<br>
8+
<a href="https://github.com/codingjoe/django-django-dynamic-filenames?tab=readme-ov-file">Documentation</a> |
9+
<a href="https://github.com/codingjoe/django-django-dynamic-filenames/issues/new/choose">Issues</a> |
10+
<a href="https://github.com/codingjoe/django-django-dynamic-filenames/releases">Changelog</a> |
11+
<a href="https://github.com/sponsors/codingjoe">Funding</a> 💚
12+
</p>
13+
114
# Django Dynamic Filenames
215

3-
Write advanced filename patterns using the [Format String
4-
Syntax](https://docs.python.org/3/library/string.html#format-string-syntax).
16+
Write advanced filename patterns using the [Format String Syntax](https://docs.python.org/3/library/string.html#format-string-syntax).
517

618
## Getting Started
719

@@ -35,77 +47,32 @@ Auto slug example:
3547

3648
### Field names
3749

38-
`ext`
39-
40-
: File extension including the dot.
41-
42-
`name`
43-
44-
: Filename excluding the folders.
45-
46-
`model_name`
47-
48-
: Name of the Django model.
49-
50-
`app_label`
50+
- `ext`: File extension including the dot.
51+
- `name`: Filename excluding the folders.
52+
- `model_name`: Name of the Django model.
53+
- `app_label`: App label of the Django model.
54+
- `instance`: Instance of the model before it has been saved. You may not have a primary key at this point.
55+
- `uuid`: UUID version 4 that supports multiple type specifiers.
56+
The UUID will be the same should you use it twice in the same string,
57+
but different on each invocation of the `upload_to` callable.
5158

52-
: App label of the Django model.
53-
54-
`instance`
55-
56-
: Instance of the model before it has been saved. You may not have a
57-
primary key at this point.
58-
59-
`uuid`
60-
61-
: UUID version 4 that supports multiple type specifiers. The UUID will
62-
be the same should you use it twice in the same string, but
63-
different on each invocation of the `upload_to` callable.
64-
65-
```
6659
The type specifiers allow you to format the UUID in different ways,
6760
e.g. `{uuid:x}` will give you a with a hexadecimal UUID.
6861

6962
The supported type specifiers are:
7063

71-
`s`
64+
- `s`: String representation of a UUID including dashes.
65+
- `i`: Integer representation of a UUID. Like to `UUID.int`.
66+
- `x`: Hexadecimal (Base16) representation of a UUID. Like to `UUID.hex`.
67+
- `X`: Upper case hexadecimal representation of a UUID. Like to `UUID.hex`.
68+
- `base32`: Base32 representation of a UUID without padding.
69+
- `base64`: Base64 representation of a UUID without padding.
7270

73-
: String representation of a UUID including dashes.
71+
> [!WARNING]
72+
> Not all file systems support Base64 file names.
7473
75-
`i`
76-
77-
: Integer representation of a UUID. Like to `UUID.int`.
78-
79-
`x`
80-
81-
: Hexadecimal (Base16) representation of a UUID. Like to
82-
`UUID.hex`.
83-
84-
`X`
85-
86-
: Upper case hexadecimal representation of a UUID. Like to
87-
`UUID.hex`.
88-
89-
`base32`
90-
91-
: Base32 representation of a UUID without padding.
92-
93-
`base64`
94-
95-
: Base64 representation of a UUID without padding.
96-
97-
:::: warning
98-
::: title
99-
Warning
100-
:::
101-
102-
Not all file systems support Base64 file names.
103-
::::
104-
105-
All type specifiers also support precisions to cut the string, e.g.
106-
`{{uuid:.2base32}}` would only return the first 2 characters of a
107-
Base32 encoded UUID.
108-
```
74+
All type specifiers also support precisions to cut the string,
75+
e.g. `{{uuid:.2base32}}` would only return the first 2 characters of a Base32 encoded UUID.
10976

11077
### Type specifiers
11178

images/logo-dark.svg

Lines changed: 17 additions & 0 deletions
Loading

images/logo-light.svg

Lines changed: 17 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)