Name | django-social-links-field JSON |
Version |
0.1.6
JSON |
| download |
home_page | None |
Summary | A Django form field and widget for managing social media links via models.JSONField |
upload_time | 2025-02-06 11:11:33 |
maintainer | None |
docs_url | None |
author | Suraj Singh Bisht |
requires_python | <4.0,>=3.10 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Django Social Links Field
## Overview
`social-links-field` is a Django package that provides a custom model field, form field, and widget for managing social media links with ease. It allows developers to store and manage multiple social media links for a model with built-in validation and a user-friendly interface.

## Features
- Custom JSON-based field for storing social media links
- Predefined social media platforms
- Dynamic form widget for adding/removing social links
- Built-in validation
- Easy integration with Django forms and admin interface
## Installation
Install the package using pip:
```bash
pip install django-social-links-field
```
## Quick Start
### 1. Add to INSTALLED_APPS
In your Django project's `settings.py`:
```python
INSTALLED_APPS = [
...
'social_links_field',
...
]
```
### 2. Use in Models
```python
from django.db import models
from social_links_field.models import SocialLinksField
class UserProfile(models.Model):
name = models.CharField(max_length=100)
social_links = SocialLinksField()
```
### 3. In Django Admin
The field automatically works with Django admin:
```python
from django.contrib import admin
from .models import UserProfile
@admin.register(UserProfile)
class UserProfileAdmin(admin.ModelAdmin):
# No special configuration needed
pass
```
## Supported Social Media Platforms
- Facebook
- Instagram
- Twitter
- LinkedIn
- GitHub
- YouTube
- Custom
Configure the dropdown values from `settings.py`
```
SOCIAL_LINKS_FIELD_MEDIA_TYPES = [
# value, label
("facebook", "Facebook"),
("instagram", "Instagram"),
("twitter", "Twitter"),
("linkedin", "LinkedIn"),
("github", "GitHub"),
("youtube", "YouTube"),
]
```
## Data Structure
Social links are stored as a list of dictionaries:
```python
[
{
'type': 'facebook',
'link': 'example_user',
'label': 'My Facebook Profile'
}
]
```
## Form Usage
```python
from django import forms
from .models import UserProfile
class UserProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ['name', 'social_links']
```
## Customization
### Adding Custom Social Media Platforms
You can extend `SOCIAL_MEDIA_TYPES` in your project:
```python
from social_links_field.models import SOCIAL_MEDIA_TYPES
SOCIAL_MEDIA_TYPES += [
('tiktok', 'TikTok'),
('telegram', 'Telegram')
]
```
You can customize html/css/js by directly overriding default widget html template
```
social_links_field/social_links_widget.html
```
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
MIT License
Raw data
{
"_id": null,
"home_page": null,
"name": "django-social-links-field",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Suraj Singh Bisht",
"author_email": "surajsinghbisht054@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5a/9a/2ed9a0745bf783bc0dd2f6591599d1d1c50b0e403c42e59b4b784d1fa8e6/django_social_links_field-0.1.6.tar.gz",
"platform": null,
"description": "# Django Social Links Field\n\n## Overview\n\n`social-links-field` is a Django package that provides a custom model field, form field, and widget for managing social media links with ease. It allows developers to store and manage multiple social media links for a model with built-in validation and a user-friendly interface.\n\n\n\n\n## Features\n\n- Custom JSON-based field for storing social media links\n- Predefined social media platforms\n- Dynamic form widget for adding/removing social links\n- Built-in validation\n- Easy integration with Django forms and admin interface\n\n\n\n## Installation\n\nInstall the package using pip:\n\n```bash\npip install django-social-links-field\n```\n\n\n## Quick Start\n\n### 1. Add to INSTALLED_APPS\n\nIn your Django project's `settings.py`:\n\n```python\nINSTALLED_APPS = [\n ...\n 'social_links_field',\n ...\n]\n```\n\n### 2. Use in Models\n\n```python\nfrom django.db import models\nfrom social_links_field.models import SocialLinksField\n\nclass UserProfile(models.Model):\n name = models.CharField(max_length=100)\n social_links = SocialLinksField()\n```\n\n### 3. In Django Admin\n\nThe field automatically works with Django admin:\n\n```python\nfrom django.contrib import admin\nfrom .models import UserProfile\n\n@admin.register(UserProfile)\nclass UserProfileAdmin(admin.ModelAdmin):\n # No special configuration needed\n pass\n```\n\n## Supported Social Media Platforms\n\n- Facebook\n- Instagram\n- Twitter\n- LinkedIn\n- GitHub\n- YouTube\n- Custom\n\nConfigure the dropdown values from `settings.py`\n```\nSOCIAL_LINKS_FIELD_MEDIA_TYPES = [\n # value, label\n (\"facebook\", \"Facebook\"),\n (\"instagram\", \"Instagram\"),\n (\"twitter\", \"Twitter\"),\n (\"linkedin\", \"LinkedIn\"),\n (\"github\", \"GitHub\"),\n (\"youtube\", \"YouTube\"),\n]\n\n```\n\n## Data Structure\n\nSocial links are stored as a list of dictionaries:\n\n```python\n[\n {\n 'type': 'facebook', \n 'link': 'example_user', \n 'label': 'My Facebook Profile'\n }\n]\n```\n\n## Form Usage\n\n```python\nfrom django import forms\nfrom .models import UserProfile\n\nclass UserProfileForm(forms.ModelForm):\n class Meta:\n model = UserProfile\n fields = ['name', 'social_links']\n```\n\n## Customization\n\n### Adding Custom Social Media Platforms\n\nYou can extend `SOCIAL_MEDIA_TYPES` in your project:\n\n```python\nfrom social_links_field.models import SOCIAL_MEDIA_TYPES\n\nSOCIAL_MEDIA_TYPES += [\n ('tiktok', 'TikTok'),\n ('telegram', 'Telegram')\n]\n\n```\nYou can customize html/css/js by directly overriding default widget html template\n```\nsocial_links_field/social_links_widget.html\n```\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT License",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Django form field and widget for managing social media links via models.JSONField",
"version": "0.1.6",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e112689c363ae532b7d6116c4dac1628ad454ef0d01991edc5aed84f244340ba",
"md5": "c76555a7f7fedd92e46763fbd01316d4",
"sha256": "f4f267590cbb3ff16e23795427093d835b66f6a6bbaec5f16c47cb053b1b5f16"
},
"downloads": -1,
"filename": "django_social_links_field-0.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c76555a7f7fedd92e46763fbd01316d4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 69910,
"upload_time": "2025-02-06T11:11:30",
"upload_time_iso_8601": "2025-02-06T11:11:30.900862Z",
"url": "https://files.pythonhosted.org/packages/e1/12/689c363ae532b7d6116c4dac1628ad454ef0d01991edc5aed84f244340ba/django_social_links_field-0.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5a9a2ed9a0745bf783bc0dd2f6591599d1d1c50b0e403c42e59b4b784d1fa8e6",
"md5": "6e9619894028b0c6e3d7100216e33556",
"sha256": "7e3499b6a70283223bcdbf13334e70325f76b5833c7c3544a47e150b6f43bc16"
},
"downloads": -1,
"filename": "django_social_links_field-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "6e9619894028b0c6e3d7100216e33556",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 68227,
"upload_time": "2025-02-06T11:11:33",
"upload_time_iso_8601": "2025-02-06T11:11:33.553000Z",
"url": "https://files.pythonhosted.org/packages/5a/9a/2ed9a0745bf783bc0dd2f6591599d1d1c50b0e403c42e59b4b784d1fa8e6/django_social_links_field-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-06 11:11:33",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "django-social-links-field"
}