Metadata-Version: 2.1
Name: django-toots
Version: 0.0.0
Summary: An app to manage toots (Mastodon posts) in a Django project
Author-email: Rami <ramiboutas@protonmail.com>
Project-URL: Homepage, https://github.com/ramiboutas/django-toots
Project-URL: Bug Tracker, https://github.com/ramiboutas/django-toots/issues
Classifier: Development Status :: 1 - Planning
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Mastodon.py
Requires-Dist: django

# django-tweets
[<img align="center"  width="100%"  src="images/logo_large.png">](https://twitter.com/django_tweets)

Create and delete tweets in a Django project.

This packages takes the advantage of the [tweepy](https://www.tweepy.org/) functionalities to connect it to a Django Backend.

The tweets objects can have media files as well.




## Set up


1. Install from PyPI
```
python -m pip install django-toots
```

2. Add the package to your settings INSTALLED_APPS

```python

INSTALLED_APPS = [
    ...
    "django_toots",
    ...
]

```


3. Add the following settings to your Django project.


Example:

```python
import os
from dotenv import load_dotenv
load_dotenv()

...

# django-toots 
MASTODON_ACCESS_TOKEN=os.environ.get("MASTODON_ACCESS_TOKEN", "") 
MASTODON_API_BASE_URL = "https://fosstodon.org"

```

4. Run migrations

```
python manage.py migrate

```


## Usage

TODO: Document this!

<!-- 


### Create a simple tweet

```python

from django_tweets.models import Tweet

# create a tweet in the db
tweet = Tweet.objects.create(text="Hi, this is my tweet using django-tweets and tweepy")

# publish it
tweet.publish()

```
### Create a tweet with a media file

```python
from pathlib import Path
from django.core.files.base import ContentFile
from django_tweets.models import Tweet, TweetFile

# create a media file
path = Path("path/to/my/file.jpg")

with open(path, "rb") as f:
    f.seek(0)
    contents = f.read()

tweet_file = TweetFile.objects.create(title="nice photo")
tweet_file.file.save(path.name, ContentFile(contents))
# upload to Twitter
tweet_file = tweet_file.upload()

# create a tweet in the db
tweet = Tweet.objects.create(text="My tweet with a file")

# add the media file to the tweet object
tweet.files.add(tweet_file)

# publish it
tweet.publish()

```

### Usage in the admin

![Django admin](images/admin.png)

* Use [http://127.0.0.1:8000/admin/django_tweets/tweet/](http://127.0.0.1:8000/admin/django_tweets/tweet/) to create a Tweet object
* Use [http://127.0.0.1:8000/admin/django_tweets/tweetpublication/](http://127.0.0.1:8000/admin/django_tweets/tweetpublication/) to link a Tweet object to publish it.

Similarly works with the `TweetFile` and `TweetFileUpload` models.



## About

[🐣 django_tweets](https://twitter.com/django_tweets)

©Django is a registered trademark of the Django Software Foundation.
-->
