Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codermungan/djangoessentials
DjangoEssentials is a Python library designed to streamline and enhance the development process of Django applications. It offers a collection of commonly used Django models and deployment settings, encapsulating repetitive patterns and configurations into a reusable package.
https://github.com/codermungan/djangoessentials
django django-application django-framework django-library django-rest-framework library python python-library
Last synced: 11 days ago
JSON representation
DjangoEssentials is a Python library designed to streamline and enhance the development process of Django applications. It offers a collection of commonly used Django models and deployment settings, encapsulating repetitive patterns and configurations into a reusable package.
- Host: GitHub
- URL: https://github.com/codermungan/djangoessentials
- Owner: CoderMungan
- License: mit
- Created: 2024-03-18T15:23:06.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-08-25T23:40:01.000Z (about 1 month ago)
- Last Synced: 2024-09-25T14:37:04.397Z (13 days ago)
- Topics: django, django-application, django-framework, django-library, django-rest-framework, library, python, python-library
- Language: Python
- Homepage: https://pypi.org/project/DjangoEssentials/
- Size: 18.6 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DjangoEssentials
[Join Our Community - Kampus](https://discord.gg/kampus)
DjangoEssentials is a Python library designed to streamline and enhance the development process of Django applications. It offers a collection of commonly used Django models and deployment settings, encapsulating repetitive patterns and configurations into a reusable package. The library is intended to evolve with contributions from the community, making it a collaborative project.
## Features
- **TimeBasedStampModel:** An abstract model providing time-based fields for tracking creation, update, and deletion times of model instances.
- **MyS3Storage:** A custom storage class for Django, facilitating integration with Amazon S3 for media storage, with features such as non-overwriting of files with the same name and public read access by default.## Getting Started
Below are instructions on how to install DjangoEssentials and examples of how to use its features in your Django projects.
### Installation
Install DjangoEssentials using pip:
```bash
pip install DjangoEssentials
```### Usage
- **TimeBasedStampModel**
Inherit from TimeBasedStampModel to add automatic creation, update, and soft deletion timestamps to your models.
```python
from django.db import models
from djangoessentials import TimeBasedStampModelclass YourModel(TimeBasedStampModel):
name = models.CharField(max_length=255)
# Add your fields here```
- **MyS3Storage**
Configure your Django project to use MyS3Storage for handling media files with Amazon S3.
Example:```python
# settings.py
USE_S3 = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/if USE_S3:
# aws settings
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID") ## get your aws access key
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY") ## get your aws secret access key
AWS_STORAGE_BUCKET_NAME = os.getenv("AWS_STORAGE_BUCKET_NAME") ## Your bucket name
AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'
AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'}
# s3 public media settings
PUBLIC_MEDIA_LOCATION = 'media'
MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{PUBLIC_MEDIA_LOCATION}/'
else:
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static/'),
]
```Than
```python
from django.db import models
from djangoessentials import MyS3Storageclass MyModel(models.Model):
document = models.FileField(upload_to='documents/', storage=MyS3Storage)
# Add your fields here
```- **CustomUser Model**
Usages:```python
#settings.py
AUTH_USER_MODEL = 'yourapp.CustomUser'
``````python
#example
from django import forms
from djangoessentials import CustomUserclass YourModelForm(forms.ModelForm):
password1 = forms.CharField()
password2 = forms.CharField()
class Meta:
model = CustomUser
fields = ('username', 'phone_number', 'date_of_birth')
```### Advanced Usage
DjangoEssentials aims to provide more utilities and helpers over time, driven by community contributions and the evolving needs of Django developers.
### Contributing
We welcome contributions from the community, whether it's adding new features, improving documentation, or reporting bugs. Please follow these steps to contribute:
Fork the repository.
- Create your feature branch (git checkout -b feature/AmazingFeature).
- Commit your changes (git commit -am 'Add some AmazingFeature').
- Push to the branch (git push origin feature/AmazingFeature).
- Open a Pull Request.### Contact
For questions or additional information, please reach out to