django-social-links-field


Namedjango-social-links-field JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryA Django form field and widget for managing social media links via models.JSONField
upload_time2024-12-11 16:36:39
maintainerNone
docs_urlNone
authorSuraj Singh Bisht
requires_pythonNone
licenseMIT
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.


![Admin Panel Screenshot](./social_links_field/screenshot.png?raw=true)

## 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 downdown 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": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Suraj Singh Bisht",
    "author_email": "surajsinghbisht054@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ea/ab/6ee2bfd404b16eb13f99d8ebdf3ea3a9cc061cc8103d5e1e58d11733562d/django_social_links_field-0.1.5.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![Admin Panel Screenshot](./social_links_field/screenshot.png?raw=true)\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 downdown 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.5",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9767e01a8347ca90ca3690d2f00be018e68cc3d4edebb8f315c348162ba37f87",
                "md5": "5281799a47818dd166c91dd02a49df8b",
                "sha256": "060d84288e9f149efb791544019a2db3851ccb76d020897b5881f827d26e2cdd"
            },
            "downloads": -1,
            "filename": "django_social_links_field-0.1.5-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5281799a47818dd166c91dd02a49df8b",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 70782,
            "upload_time": "2024-12-11T16:36:36",
            "upload_time_iso_8601": "2024-12-11T16:36:36.056566Z",
            "url": "https://files.pythonhosted.org/packages/97/67/e01a8347ca90ca3690d2f00be018e68cc3d4edebb8f315c348162ba37f87/django_social_links_field-0.1.5-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eaab6ee2bfd404b16eb13f99d8ebdf3ea3a9cc061cc8103d5e1e58d11733562d",
                "md5": "c96636974a74a6afa296799ec073e47f",
                "sha256": "f9b803f1f1bc791617ce8cc85ae2792787786595f1e17446260c5a6b4e186048"
            },
            "downloads": -1,
            "filename": "django_social_links_field-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "c96636974a74a6afa296799ec073e47f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 66681,
            "upload_time": "2024-12-11T16:36:39",
            "upload_time_iso_8601": "2024-12-11T16:36:39.221570Z",
            "url": "https://files.pythonhosted.org/packages/ea/ab/6ee2bfd404b16eb13f99d8ebdf3ea3a9cc061cc8103d5e1e58d11733562d/django_social_links_field-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-11 16:36:39",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-social-links-field"
}
        
Elapsed time: 0.41158s