Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imvickykumar999/toggle-button
zip -r toggle.zip .
https://github.com/imvickykumar999/toggle-button
ajax django-jazzmin django-material-admin toggle
Last synced: about 22 hours ago
JSON representation
zip -r toggle.zip .
- Host: GitHub
- URL: https://github.com/imvickykumar999/toggle-button
- Owner: imvickykumar999
- License: bsd-3-clause
- Created: 2025-01-07T13:22:08.000Z (21 days ago)
- Default Branch: main
- Last Pushed: 2025-01-16T09:07:25.000Z (12 days ago)
- Last Synced: 2025-01-16T10:35:44.165Z (12 days ago)
- Topics: ajax, django-jazzmin, django-material-admin, toggle
- Language: Python
- Homepage: https://toggle.pythonanywhere.com/
- Size: 23.1 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
># **Material Admin**
>Material Admin is based on Google’s Material Design and supports the latest Django versions.
>
>[![image](https://github.com/user-attachments/assets/70fc62a8-f6a3-4a8b-b89c-ca394f598c2a)](https://toggle.pythonanywhere.com/admin/toggle_app/toggleitem/)
>![image](https://github.com/user-attachments/assets/f1152fa4-b73c-49f6-aa11-d3702d82cf5c)
>[![image](https://github.com/user-attachments/assets/ae7b952f-4fe2-48c4-8a6c-1834d567a18b)](https://toggle.pythonanywhere.com/)
>#### **Installation**:
1. Install Material Admin:
```bash
pip install django-material-admin
```2. Add `material` to `INSTALLED_APPS` in `settings.py` **before** `django.contrib.admin`:
```python
INSTALLED_APPS = [
'material',
'django.contrib.admin',
# other apps
]
```3. Start the development server and check the admin interface.
---
```
TemplateSyntaxError at /admin/toggle_app/toggleitem/6/change/
Invalid filter: 'length_is'
```### **1. Create Your Custom Filter**
1. **Define the Filter**
Create a `templatetags` folder (if it doesn’t already exist) in your app, and include an `__init__.py` file inside it. Add a `custom_filters.py` file.Folder structure:
```
toggle_app/
├── templatetags/
│ ├── __init__.py
│ ├── custom_filters.py
```In `custom_filters.py`, define the `length_is` filter:
```python
from django import templateregister = template.Library()
@register.filter
def length_is(value, length):
"""Check if the length of the value is equal to the given length."""
try:
return len(value) == int(length)
except (ValueError, TypeError):
return False
```---
### **2. Add to `builtins` in `settings.py`**
To make the custom filter globally available without needing to `{% load custom_filters %}` in each template, register it as a built-in template tag library.1. In your `settings.py`, add:
```python
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
"builtins": ["toggle_app.templatetags.custom_filters"], # Add your custom filters here
},
},
]
```---
### **3. Restart Your Development Server**
After making these changes, restart your Django development server to ensure the changes take effect:
```bash
python manage.py collectstatic
python manage.py runserver
```