Skip to main content

Django TalkTo

Updates Python 3

Overview

Django TalkTo allows you to consume RESTful APIs seamlessly without need to create database

Model
  • TalkToModel, inherits the django Model class, but won't create any migration files, :smiley:
  • APIManager, inherits Django Manager(I won't touch your DB i promise :yum: )
ModelForm
  • TalkToModelForm, inherits Django ModelForm.
Views
  • TalkToWriteView which makes POST/PUT request to an endpoint (Django CreateView and UpdateView in one pot :wink: )

  • TalkToListView which makes GET request to an endpoint (Django ListView, no bigs)

  • TalkToDetailView which makes GET request with a parameter (Django DetailView)

Django Rest Framework support

You can also use Django TalkTo with Django Rest Framework

Serializer
  • TalkToModelSerializer, inherits DRF ModelSerializer, that won't touch the DB, cool right?
View
  • TalkToAPIView which makes POST, GET and PUT requests. DELETE requests coming soon.

Installation

Install using pip

pip install djangotalkto

Notes to Django Rest Framework users

You need to have djangorestframework installed and added to INSTALLED_APPS in settings. You can install it with djangotalkto using

pip install djangotalkto[rest]

Usage

Start a new django project

pip install django
django-admin startproject newproj .
pip install djangotalkto

Add 'talkto' to INSTALLED_APPS in your project settings

Then create TALKTO dict in your settings with the following properties

TALKTO = {
    'default': {
        'URL': 'your-api-base-url', #Important!
        'HEADERS': {key: value}, # You can add your Authorization here
    }

}
Creating your Model
from talkto.models import TalkToModel, APIManager
from django.db import models
class SampleModel(TalkToModel):
    name = models.CharField(max_length=255)
    age = models.IntegerField()

    # Then add your APIManager with the variable name 'api'

    api = APIManager(path='user/')

    # 'path' in this case is the path you will be making your request which is 
    # concatenated with the URL set in TALKTO config in settings.py
Creating your ModelForm is much like the same.
from talkto.forms import TalkToModelForm


class SampleForm(TalkToModelForm):
    class Meta:
        model = SampleModel
        fields = '__all__'
Views
from talkto.views import TalkToWriteView, TalkToDetailView, TalkToListView

class TestCreate(TalkToWriteView):
    form_class = SampleForm
    model = SampleModel
    success_url = reverse_lazy('books')
    template_name = 'index.html'

# Detail view

class SampleDetail(TalkToDetailView):
    model = SampleModel
    template_name = 'detail.html'


# List view

class SampleList(TalkToListView):
    model = SampleModel
    template_name = 'detail.html'

URLConf works the same.

Django Rest Framework
Serializer
from talkto.serializer import TalkToModelSerializer

class SampleSerializer(TalkToModelSerializer):
    class Meta:
        model = SampleModel
        fields = '__all__'
API View
class SampleView(TalkToAPIView):
    model = SampleModel
    serializer_class = SampleSerializer

URLConf works the same.


CONTRIBUTING

coming soon....


Supports

As this is still in it's early project there might be some use cases that are not covered. Therefore you can contact me using the following channels.

Metadata

Release files for djangotalkto 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangotalkto 0.1.4
File Size Uploaded
djangotalkto-0.1.4.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for djangotalkto 0.1.4
File Interpreter ABI Platform
djangotalkto-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 22.1 kB

Release files / djangotalkto-0.1.4.tar.gz

Download URL djangotalkto-0.1.4.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5c4a63adab0df4562066b940e04f2a9e4f65fba0a1a75d9a515bf20bc0c74b54
BLAKE2b-256 checksum
How to use checksums
c2cf6a9c969d7be78ed01fe29db6a91e8de67b7b10b093889859934e76c4c92c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.4rc1

Release files / djangotalkto-0.1.4-py3-none-any.whl

Download URL djangotalkto-0.1.4-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d34e136e4d14ed18de7385965b754cd3c5a11aa4e83d69c7960fcc91031c1e7
BLAKE2b-256 checksum
How to use checksums
dee1982c121ff1e44d92ee5ef1952c9d6faccb48af359b2a5f1c5077ec0a76b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.4rc1

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page