{"id":17030299,"url":"https://github.com/vsoch/contributions-django","last_synced_at":"2026-03-05T09:03:16.261Z","repository":{"id":59294701,"uuid":"284773728","full_name":"vsoch/contributions-django","owner":"vsoch","description":"Django module to create GitHub style contributions graph","archived":false,"fork":false,"pushed_at":"2020-08-03T20:22:43.000Z","size":110,"stargazers_count":8,"open_issues_count":4,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-14T09:31:46.568Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vsoch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-03T18:13:24.000Z","updated_at":"2025-11-06T01:33:20.000Z","dependencies_parsed_at":"2022-09-15T02:41:28.611Z","dependency_job_id":null,"html_url":"https://github.com/vsoch/contributions-django","commit_stats":null,"previous_names":["vsoch/contributions_django"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vsoch/contributions-django","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsoch%2Fcontributions-django","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsoch%2Fcontributions-django/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsoch%2Fcontributions-django/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsoch%2Fcontributions-django/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vsoch","download_url":"https://codeload.github.com/vsoch/contributions-django/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsoch%2Fcontributions-django/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30117487,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T08:19:04.902Z","status":"ssl_error","status_checked_at":"2026-03-05T08:17:37.148Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2024-10-14T08:05:55.503Z","updated_at":"2026-03-05T09:03:16.233Z","avatar_url":"https://github.com/vsoch.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Contributions Django\n\n[![PyPI version](https://badge.fury.io/py/contributions-django.svg)](https://badge.fury.io/py/contributions-django)\n\nCreate a GitHub Contributions graph for Django!\n\n![img/events.png](img/events.png)\n![img/events_blue.png](img/events_blue.png)\n![img/events.png](img/events_pink.png)\n\nThis repository serves a Django app that can be used to generate a GitHub\ncontributions graph. An [example](example)\napplication is provided in the `example` folder that can be interacted with here.\n\n## Quickstart\n\nInstall contributions django:\n\n```bash\npip install contributions-django\n```\n\nAdd it to your `INSTALLED_APPS`:\n\n```python\n    INSTALLED_APPS = (\n        ...\n        'contributions_django',\n        ...\n    )\n```\n\nTo generate the graph in a view, import `generate_contributors_graph`. Give the function\na list of dates, and optionally a title to generate a context for your view:\n\n```python\n# -*- coding: utf-8 -*-\n\nfrom .models import Event\n\nfrom django_contributions.graphs import generate_contributors_graph\nfrom django.shortcuts import render\n\ndef events_view(request):\n    \"\"\"Generate a papers graph using all Events dates\n    \"\"\"\n    # Get a single list of timestamps for the view\n    dates = Event.objects.values_list('date', flat=True)\n    context = generate_contributors_graph(dates, title=\"Contributions\")\n    return render(request, \"events/index.html\", context)\n```\n\nAnd then in your template, include this snippet where you want the graph to show:\n\n```html\n{% include \"contributions_django/graph.html\" %}\n```\n\nNote that by default, the template includes bootstrap style (css) and font awesome icons.\nSee the next section, customization, if you already have these in your template\nand want to remove them.\n\n### Customization\n\nIf you want to customize any colors or text in the graph, you can do that in your\nsettings in a `CONTRIBUTIONS_DJANGO` section - the defaults are shown below.\n\n```python\nCONTRIBUTIONS_DJANGO = {\n\n    # Gradients (0 or weak to stronger)\n    'GRADIENT0': \"#eee\",\n    'GRADIENT1': \"#d6e685\",\n    'GRADIENT2': \"#8cc665\",\n    'GRADIENT3': \"#44a340\",\n    'GRADIENT4': \"#1e6823\",\n\n    # The name to appear in tooltips (e.g., 12 contributions)\n    'ITEM_NAME': 'contributions',\n\n    # Include bootstrap style for outer part of template\n    # set this to false if you already have it on your page\n    'INCLUDE_BOOTSTRAP': True,\n    'INCLUDE_FONTAWESOME': True,\n\n    # The icon to show next to title. Set to None to remove.\n    'ICON_CLASSES': \"fa fa-calendar\",\n\n    # Instead of boxes, use circles.\n    'CIRCLES': True\n\n\n}\n```\n\n#### Shape\n\nThe cells can be circles if you set `CIRCLES` to true:\n\n![img/events_circles.png](img/events_circles.png)\n\n#### Colors\n\nFor gradients, you can find a color palette generation site like [this one](https://coolors.co/palettes/trending)\nand customize gradients 1 through 4. You likely don't want to customize `GRADIENT0` since\nthat is the grey (empty) color. \n\n**green**\n\nThe default (akin to GitHub) is a set of greens:\n\n![img/events.png](img/events.png)\n\n\n**blue**\n\nHere is the settings for a blue:\n\n```python\n# Gradients (0 or weak to stronger)\n'GRADIENT0': \"#eee\", # this is empty gray, likely don't want to change this\n'GRADIENT1': \"#90E0EF\",\n'GRADIENT2': \"#00B4D8\",\n'GRADIENT3': \"#0077B6\",\n'GRADIENT4': \"#03045E\", # this should be the darkest\n```\n\n![img/events_blue.png](img/events_blue.png)\n\n**pinks**\n\nAnd pinks!\n\n```\n# Gradients (0 or weak to stronger) - below is green\n'GRADIENT0': \"#eee\", # this is empty gray, likely don't want to change this\n'GRADIENT1': \"#fbc3bc\",\n'GRADIENT2': \"#f7a399\",\n'GRADIENT3': \"#f38375\",\n'GRADIENT4': \"#ef6351\", # this should be the darkest\n```\n\n![img/events_pink.png](img/events_pink.png)\n\nPlease open a pull request to add examples of your favorite palettes!\n\n#### Template\nIf you want to customize the entire template, then you can create a copy of\nthe [default](contributions_django/templates/contributions_django/graph.html)\nand include it in your view instead.\n\n```html\n{% include \"example/mygraph.html\" %}\n```\n\n### Dates\n\nImportantly, with Django it's recommended to not use naive datetimes. In fact,\nyou'll get an error if you try saving a naive datetime to a model field. This means\nthat contributions_django must be flexible to accept naive or aware times. \nHere is how you can generate timestamps that are aware:\n\n```python\nfrom datetime import timedelta\nfrom django.utils import timezone\nimport pytz\n\n# get today and one year earlier\ntoday = timezone.now()\nlast_year = today - timedelta(days=365)\n\n# Create an event with a timezone aware timestamp\nEvent.objects.create(date=last_year, name=\"My Event\")\n```\n\nAnd here is a naive timestamp:\n\n```python\nfrom datetime import datetime\ntimestamp = datetime.now()\n```\n\nRegardless of your choice, the contributions graph only cares about the day,\nso it takes the `timestamp.date()` that is available regardless of being naive\nor not.\n\n### Example Application\n\nYou can develop or test interactively using the example (very simple) application\nunder [tests](tests). The [manage.py](manage.py) is located in the root directory\nso it's easy to update your install and then interact with your test interface.\nFirst create a virtual environment in the root and install the dependencies, \nmostly your application in development mode:\n\n```bash\npython -m venv env\nsource env/bin/activate\ncd example\npip install -r requirements.txt\n```\n\nThen make migrations - this will create a basic Event model:\n\n```bash\n$  python manage.py makemigrations main\nMigrations for 'main':\n  example/apps/main/migrations/0001_initial.py\n    - Create model Event\n```\n\nAnd migrate\n\n```bash\n$ python manage.py migrate\nOperations to perform:\n  Apply all migrations: admin, auth, contenttypes, main, sessions\nRunning migrations:\n  Applying contenttypes.0001_initial... OK\n  Applying auth.0001_initial... OK\n  Applying admin.0001_initial... OK\n  Applying admin.0002_logentry_remove_auto_add... OK\n  Applying admin.0003_logentry_add_action_flag_choices... OK\n  Applying contenttypes.0002_remove_content_type_name... OK\n  Applying auth.0002_alter_permission_name_max_length... OK\n  Applying auth.0003_alter_user_email_max_length... OK\n  Applying auth.0004_alter_user_username_opts... OK\n  Applying auth.0005_alter_user_last_login_null... OK\n  Applying auth.0006_require_contenttypes_0002... OK\n  Applying auth.0007_alter_validators_add_error_messages... OK\n  Applying auth.0008_alter_user_username_max_length... OK\n  Applying auth.0009_alter_user_last_name_max_length... OK\n  Applying auth.0010_alter_group_name_max_length... OK\n  Applying auth.0011_update_proxy_permissions... OK\n  Applying main.0001_initial... OK\n  Applying sessions.0001_initial... OK\n```\n\nNote that the example app creates the Event model with the sole purpose of\npopulating something with dates. You can use contributions_django for any\nkind of visualization that provides a list of dates. \nAt this point, if you run your server and browse to the index, you'll\nsee the empty graph, because we haven't created any events:\n\n```bash\npython manage.py runserver\n```\n\n![img/empty_events.png](img/empty_events.png)\n\nNext, let's run the management command to create a bunch of random events -\n1000 between today and last year, specifically. This is done by the example\nmanagement command [here](example/example/apps/main/management/commands/create_events.py):\n\n```bash\n$ python manage.py create_events\nCreating 1000 events:\n\nCreating Event joyous-lemon-3372 at 2020-07-12 00:56:15.675397+00:00\nCreating Event misunderstood-leg-5849 at 2019-09-23 23:23:01.675397+00:00\nCreating Event rainbow-leg-6361 at 2020-07-16 19:03:03.675397+00:00\nCreating Event cowy-eagle-2288 at 2020-02-19 21:55:53.675397+00:00\n...\n```\n\nYou should then be able to run the application and see the events populated!\n\n```bash\npython manage.py runserver\n```\n\n![img/events.png](img/events.png)\n\n\n## Development\n\nI suggest that you follow the same steps to set up the example app:\n\n```bash\npython -m venv env\npip install -r requirements.txt\nsource env/bin/activate\n```\n\nAnd then you can change code under [contributions_django](contributions_django)\nand test the live outcome with the example app.\n\n## Many Thanks \n\n* [cookiecutter-djangopackage](https://github.com/pydanny/cookiecutter-djangopackage)\n* The library is resurrected from the archived repository [contributions-graph](https://github.com/alexwlchan/contributions-graph) and updated for Django. The original license can be seen [here](.github/LICENSE-ALEX).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsoch%2Fcontributions-django","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvsoch%2Fcontributions-django","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsoch%2Fcontributions-django/lists"}