DjangoEssentials


NameDjangoEssentials JSON
Version 0.1.9 PyPI version JSON
download
home_pagehttps://github.com/CoderMungan/DjangoEssentials
SummaryReusable Django models, utils and storages
upload_time2024-08-25 23:32:04
maintainerNone
docs_urlNone
authorCoder Mungan
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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 TimeBasedStampModel

class 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 MyS3Storage

class 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 CustomUser

class 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 <codermungan@gmail.com>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/CoderMungan/DjangoEssentials",
    "name": "DjangoEssentials",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Coder Mungan",
    "author_email": "codermungan@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2f/4d/78a3047b9cdf0bc314e73aeb0a7c1827f37da6d21fc308a218151f165e79/DjangoEssentials-0.1.9.tar.gz",
    "platform": null,
    "description": "# DjangoEssentials\n\n[Join Our Community - Kampus](https://discord.gg/kampus)\n\nDjangoEssentials 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.\n\n## Features\n\n- **TimeBasedStampModel:** An abstract model providing time-based fields for tracking creation, update, and deletion times of model instances.\n- **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.\n\n## Getting Started\n\nBelow are instructions on how to install DjangoEssentials and examples of how to use its features in your Django projects.\n\n### Installation\n\nInstall DjangoEssentials using pip:\n\n```bash\npip install DjangoEssentials\n```\n\n### Usage\n\n- **TimeBasedStampModel**\n\nInherit from TimeBasedStampModel to add automatic creation, update, and soft deletion timestamps to your models.\n\n```python\n\nfrom django.db import models\nfrom djangoessentials import TimeBasedStampModel\n\nclass YourModel(TimeBasedStampModel):\n    name = models.CharField(max_length=255)\n    # Add your fields here\n\n```\n\n- **MyS3Storage**\n\nConfigure your Django project to use MyS3Storage for handling media files with Amazon S3.\nExample:\n\n```python\n# settings.py\nUSE_S3 = True\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/4.2/howto/static-files/\n\nif USE_S3:\n    # aws settings\n    AWS_ACCESS_KEY_ID = os.getenv(\"AWS_ACCESS_KEY_ID\")  ## get your aws access key\n    AWS_SECRET_ACCESS_KEY = os.getenv(\"AWS_SECRET_ACCESS_KEY\")  ## get your aws secret access key\n    AWS_STORAGE_BUCKET_NAME = os.getenv(\"AWS_STORAGE_BUCKET_NAME\")  ## Your bucket name\n    AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'\n    AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400'}\n    # s3 public media settings\n    PUBLIC_MEDIA_LOCATION = 'media'\n    MEDIA_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{PUBLIC_MEDIA_LOCATION}/'\nelse:\n    MEDIA_URL = '/media/'\n    MEDIA_ROOT = os.path.join(BASE_DIR, 'media')\nSTATIC_URL = 'static/'\nSTATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')\nSTATICFILES_DIRS = [\n    os.path.join(BASE_DIR, 'static/'),\n]\n```\n\nThan\n\n```python\nfrom django.db import models\nfrom djangoessentials import MyS3Storage\n\nclass MyModel(models.Model):\n    document = models.FileField(upload_to='documents/', storage=MyS3Storage)\n    # Add your fields here\n```\n\n- **CustomUser Model**\n  Usages:\n\n```python\n#settings.py\nAUTH_USER_MODEL = 'yourapp.CustomUser'\n```\n\n```python\n#example\nfrom django import forms\nfrom djangoessentials import CustomUser\n\nclass YourModelForm(forms.ModelForm):\n    password1 = forms.CharField()\n    password2 = forms.CharField()\n    class Meta:\n        model = CustomUser\n        fields = ('username', 'phone_number', 'date_of_birth')\n```\n\n### Advanced Usage\n\nDjangoEssentials aims to provide more utilities and helpers over time, driven by community contributions and the evolving needs of Django developers.\n\n### Contributing\n\nWe welcome contributions from the community, whether it's adding new features, improving documentation, or reporting bugs. Please follow these steps to contribute:\n\nFork the repository.\n\n- Create your feature branch (git checkout -b feature/AmazingFeature).\n- Commit your changes (git commit -am 'Add some AmazingFeature').\n- Push to the branch (git push origin feature/AmazingFeature).\n- Open a Pull Request.\n\n### Contact\n\nFor questions or additional information, please reach out to <codermungan@gmail.com>\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Reusable Django models, utils and storages",
    "version": "0.1.9",
    "project_urls": {
        "Homepage": "https://github.com/CoderMungan/DjangoEssentials"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3a35852d229fd83355c8d883f9580d94e652f9367b0f9e3727ba261506157e5b",
                "md5": "293ffad386399035b88c9250ea2c16a8",
                "sha256": "d75df7bb1d05bcf1faee1365822b97c6fa2290da0d99abe72ae19d8c65b507fd"
            },
            "downloads": -1,
            "filename": "DjangoEssentials-0.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "293ffad386399035b88c9250ea2c16a8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6871,
            "upload_time": "2024-08-25T23:32:02",
            "upload_time_iso_8601": "2024-08-25T23:32:02.753315Z",
            "url": "https://files.pythonhosted.org/packages/3a/35/852d229fd83355c8d883f9580d94e652f9367b0f9e3727ba261506157e5b/DjangoEssentials-0.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f4d78a3047b9cdf0bc314e73aeb0a7c1827f37da6d21fc308a218151f165e79",
                "md5": "0f800c54d1c3543a41bc04ac0e2b3901",
                "sha256": "3fb51bda42e2baf23464cfd523ff15fdb435cc86af5b3966554b42319c303ca7"
            },
            "downloads": -1,
            "filename": "DjangoEssentials-0.1.9.tar.gz",
            "has_sig": false,
            "md5_digest": "0f800c54d1c3543a41bc04ac0e2b3901",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5562,
            "upload_time": "2024-08-25T23:32:04",
            "upload_time_iso_8601": "2024-08-25T23:32:04.422472Z",
            "url": "https://files.pythonhosted.org/packages/2f/4d/78a3047b9cdf0bc314e73aeb0a7c1827f37da6d21fc308a218151f165e79/DjangoEssentials-0.1.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-25 23:32:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CoderMungan",
    "github_project": "DjangoEssentials",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "djangoessentials"
}
        
Elapsed time: 0.43072s