{"id":24204733,"url":"https://github.com/bigsbug/django-ffield","last_synced_at":"2026-06-07T08:32:14.414Z","repository":{"id":195310074,"uuid":"692495138","full_name":"bigsbug/django-ffield","owner":"bigsbug","description":"A Django Field with extra contol over fields","archived":false,"fork":false,"pushed_at":"2023-09-17T12:18:51.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T23:17:54.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bigsbug.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-16T16:49:24.000Z","updated_at":"2023-09-18T05:50:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"2ed5162f-7f07-4858-995c-87828c514ca8","html_url":"https://github.com/bigsbug/django-ffield","commit_stats":null,"previous_names":["bigsbug/django-ffield"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigsbug%2Fdjango-ffield","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigsbug%2Fdjango-ffield/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigsbug%2Fdjango-ffield/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigsbug%2Fdjango-ffield/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigsbug","download_url":"https://codeload.github.com/bigsbug/django-ffield/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241669977,"owners_count":20000320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-13T23:18:05.286Z","updated_at":"2026-06-07T08:32:13.476Z","avatar_url":"https://github.com/bigsbug.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n  \n\n# django-ffield\n\n  \n\ndjango-ffield is a Django package that provides additional functionality and control over Django model fields, specifically focusing on file fields. this guide will you through the package's features, installation process, and provide examples of how to use it effectively.\n\n  \n\n## Table of Contents\n\n- [Installation](#installation)\n\n- [Usage](#usage)\n\n- [FileFField](#fileffield)\n\n- [FiledFField](#filedffield)\n\n- [Utility Functions](#utility-functions)\n\n- [Validators](#validators)\n\n- [Contributing](#contributing)\n\n- [License](#license)\n\n  \n\n---\n\n  \n\n## Installation\n\n  \n\nYou can install `django-ffield` via pip:\n\n  \n\n```bash\n\npip  install  django-ffield\n\n```\n\n  \n\n## Usage\n\n  \n\n### FileFField\n\n  \n\n`FileFField` extends Django's `FileField` and allows you to specify accepted file types and disallowed types during field initialization.\n\n  \n\n#### Example:\n\n  \n\n```python\n\nfrom django.db import models\n\nfrom django_ffield.fields import FileFField\n\n  \n\nclass  MyModel(models.Model):\n\nimage_field = FileFField(upload_to='images/', types=['image'])\n\npdf_field = FileFField(upload_to='pdfs/', types=['pdf'],\n\t\t\t\t\tdisallowed_types=['image','video'])\n\nvideo_field = FileFField(upload_to='videos/', types=['video'])\n\n  \n\n# Usage\n\nmy_instance = MyModel.objects.get(pk=1)\n\nmy_instance.image_field = 'example.png'  # Validates as it matches the 'image' type\n\nmy_instance.pdf_field = 'example.pdf'  # Validates as it matches the 'pdf' type\n\nmy_instance.video_field = 'example.mp4'  # Validates as it matches the 'video' type\n\n```\n\n  \n\n### FiledFField\n\n  \n\n`FiledFField` is a field that extends Django's `FieldFile` and provides additional properties to access file-related information.\n\n  \n\n#### Example:\n\n  \n\n```python\n\nfrom django.db import models\n\nfrom django_ffield.fields import FiledFField\n\n  \n\nclass  MyModel(models.Model):\n\nfile_field = FiledFField(upload_to='uploads/')\n\n  \n\n# Usage\n\nmy_instance = MyModel.objects.get(pk=1)\n\nfile = my_instance.file_field\n\n  \n\n# Accessing file properties\n\nmime_type = file.mime_type # Returns the mimetype (e.g., 'image/png')\n\nfile_type = file.type # Returns the type of file (e.g., 'Image')\n\nfile_format = file.format # Returns the file format (e.g., 'png')\n\n```\n\n  \n\n## Utility Functions\n\n  \n\n`django-ffield` provides a utility function for detecting file MIME types.\n\nThis function detects the MIME type of a file by reading the first 2048 bytes\n##### note : the file should be opened in binary mode.\n\n  \n\n#### Example:\n\n  \n\n```python\n\nfrom django_ffield.utils import meme_type\n\nfrom django.core.files import File\n\n  \n\nwith  open('example.png', 'rb') as  file:\n\ntype, subtype = meme_type(file)\n\nprint(f\"Type: {type}, Subtype: {subtype}\")\n\n```\n\n  \n\n## Validators\n\n  \n\n`django-ffield` includes a custom file type validator that can be used with `FileFField`.\n\nThis validator ensures that the uploaded file's type is among the specified types.\n\n  \n\n#### Example:\n\n  \n\n```python\n\nfrom django_ffield.validators import FileTypeValidator\n\n  \n\nclass  MyModel(models.Model):\n\nfile_field = models.FileField(upload_to='uploads/', validators=[\n\n\t\tFileTypeValidator(\n\t\tallowd_types=['image', 'pdf', 'mp4'],\n\t\tdisallowed_types = [\"audio\"],\n\t\t)\n\n])\n\n  \n\n# Usage\n\nmy_instance = MyModel.objects.get(pk=1)\n\nmy_instance.file_field = 'example.mp3'  # This will raise a ValidationError since 'mp3' is not in the accepted types\n\n```\n\n  \n\n## Contributing\n\n  \n\nFeel free to contribute to `django-ffield`.\n\n  \n\n## License\n\n  \n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/bigsbug/django-ffield/blob/main/LICENSE) file for details.\n\n  \n\n---\n\n  \n\nFeel free to explore and utilize `django-ffield` to enhance your Django projects. If you have any questions, issues, or feature requests, please open an [issue](https://github.com/bigsbug/django-ffield/issues) on our GitHub repository. Happy coding!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigsbug%2Fdjango-ffield","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigsbug%2Fdjango-ffield","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigsbug%2Fdjango-ffield/lists"}