<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: #!z@nko...;</title>
    <description>The latest articles on DEV Community by #!z@nko...; (@zankoan).</description>
    <link>https://dev.to/zankoan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F734518%2Fa9cdf958-9576-416f-a629-318e42d8abdc.jpeg</url>
      <title>DEV Community: #!z@nko...;</title>
      <link>https://dev.to/zankoan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zankoan"/>
    <language>en</language>
    <item>
      <title>Build your Telegram bots in a Django way!</title>
      <dc:creator>#!z@nko...;</dc:creator>
      <pubDate>Sat, 21 Nov 2026 16:43:10 +0000</pubDate>
      <link>https://dev.to/zankoan/build-your-telegram-bots-in-a-django-way-25j8</link>
      <guid>https://dev.to/zankoan/build-your-telegram-bots-in-a-django-way-25j8</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbgducx6z309fkxw8wkb1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbgducx6z309fkxw8wkb1.png" alt=" " width="799" height="400"&gt;&lt;/a&gt;&lt;br&gt;
Hi guys! I hope you're doing well.&lt;/p&gt;

&lt;p&gt;In this post I want to talk about my library, &lt;strong&gt;dj_telegram_bot&lt;/strong&gt;. It helps you build Telegram bots right inside your Django project, and it feels like a normal Django app.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⭐ &lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/zankoAn/dj_telegram_bot" rel="noopener noreferrer"&gt;zankoAn/dj_telegram_bot&lt;/a&gt; (a star helps a lot!)&lt;/li&gt;
&lt;li&gt;📦 &lt;strong&gt;PyPI:&lt;/strong&gt; &lt;a href="https://pypi.org/project/dj-telegram-bot/" rel="noopener noreferrer"&gt;dj-telegram-bot&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;📖 &lt;strong&gt;Docs:&lt;/strong&gt; &lt;a href="https://zankoan.github.io/dj_telegram_bot/" rel="noopener noreferrer"&gt;zankoan.github.io/dj_telegram_bot&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Why I made it
&lt;/h2&gt;

&lt;p&gt;Imagine you want to add a Telegram bot to your Django project. The first thing you do is look for an existing library and use it. But most of them don't fit well with Django, so you still have to take care of a lot of things yourself.&lt;/p&gt;

&lt;p&gt;Here is what you get with dj_telegram_bot:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Decorator routing:&lt;/strong&gt; commands, messages, buttons, inline queries and &lt;code&gt;*&lt;/code&gt; wildcards. You can write functions or classes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Built-in guards:&lt;/strong&gt; &lt;code&gt;@staff_required&lt;/code&gt;, &lt;code&gt;@superuser_required&lt;/code&gt;, &lt;code&gt;@sponsor_required&lt;/code&gt; (makes users join your channels first), and &lt;code&gt;@before_handler&lt;/code&gt; for your own checks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Edit from the admin:&lt;/strong&gt; messages and keyboards live in the database. You can build them visually and change them without a redeploy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fully typed:&lt;/strong&gt; every Telegram type is a Pydantic model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;And more:&lt;/strong&gt; maintenance mode, an optional user model, SOCKS5 proxy, and local Bot API server (TDLib) support.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I use it myself, and I really like the ORM, the simplicity, and how fast I can deploy.&lt;/p&gt;

&lt;p&gt;Here is what the admin panel looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd9rv9zar3gw32ya3pgbt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd9rv9zar3gw32ya3pgbt.png" alt=" " width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fca30pvvvrcdis3szkacv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fca30pvvvrcdis3szkacv.png" alt=" " width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this you can easily build your own Telegram bot or connect your website to Telegram.&lt;/p&gt;
&lt;h2&gt;
  
  
  Your first bot in 2 minutes
&lt;/h2&gt;

&lt;p&gt;The getting started guide shows how to install it, connect the webhook, and answer &lt;code&gt;/start&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://zankoan.github.io/dj_telegram_bot/getting-started/" rel="noopener noreferrer"&gt;https://zankoan.github.io/dj_telegram_bot/getting-started/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, create a directory named &lt;code&gt;bot_handlers&lt;/code&gt; in your app and add a file, for example &lt;code&gt;test.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dj_telegram_bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;handlers&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;command_handler&lt;/span&gt;

&lt;span class="nd"&gt;@command_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Hello!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run your Django server and send &lt;code&gt;/start&lt;/code&gt; to the bot. You will get "Hello!". It's just a normal function with a decorator.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prefer classes? You can use them too
&lt;/h2&gt;

&lt;p&gt;If you like CBV in Django, you can write your handlers in a class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dj_telegram_bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;handlers&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;UpdateHandler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;command_handler&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Home&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;UpdateHandler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nd"&gt;@command_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;start_bot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Hello!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Control who can use your handlers
&lt;/h2&gt;

&lt;p&gt;Just put the guards under the route decorator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dj_telegram_bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;guards&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sponsor_required&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;staff_required&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dj_telegram_bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;handlers&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;command_handler&lt;/span&gt;

&lt;span class="nd"&gt;@command_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"stats"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@staff_required&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Only staff can see this."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@command_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@sponsor_required&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Welcome!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;sponsor_required&lt;/code&gt; is my favorite. It makes users join your channels before the handler runs. If they didn't join, the bot sends them a message with a button for each channel.&lt;/p&gt;

&lt;p&gt;More details here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://zankoan.github.io/dj_telegram_bot/access-control/" rel="noopener noreferrer"&gt;https://zankoan.github.io/dj_telegram_bot/access-control/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Manage keyboards from the admin
&lt;/h2&gt;

&lt;p&gt;Another thing I love is the keyboard management. As you saw in the screenshots, there is a keyboard section in the admin panel. You can create your custom keyboards on a web page and edit them anytime, with no code change. Keyboards are fully supported.&lt;/p&gt;

&lt;p&gt;This is how you send one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dj_telegram_bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;contrib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;services&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;MessageService&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dj_telegram_bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;handlers&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;command_handler&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dj_telegram_bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keyboard&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;KeyboardBuilder&lt;/span&gt;

&lt;span class="nd"&gt;@command_handler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MessageService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_msg_by_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"home"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;markup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;KeyboardBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reply_markup&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;markup&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more details, see the admin docs:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://zankoan.github.io/dj_telegram_bot/admin/" rel="noopener noreferrer"&gt;https://zankoan.github.io/dj_telegram_bot/admin/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Fully typed
&lt;/h2&gt;

&lt;p&gt;Every Telegram type is a Pydantic model, based on the Telegram API docs. So your editor can autocomplete and help you while you write your bot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Under the hood
&lt;/h2&gt;

&lt;p&gt;Here is how an update moves through the library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Telegram ──webhook──▶ TelegramWebhookView
                          │
                       Dispatcher        picks a handler class by update type
                          │
                    before handlers      your checks, run on every update
                          │
                   Router.find(...)      exact → step → wildcard
                          │
                     your function or method
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Telegram sends an update to &lt;code&gt;/telegram/webhook/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Dispatcher&lt;/code&gt; wraps it in a handler object for its type (command, message, callback, inline query or chosen inline result).&lt;/li&gt;
&lt;li&gt;Every &lt;code&gt;@before_handler&lt;/code&gt; runs. If one returns &lt;code&gt;True&lt;/code&gt;, processing stops.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;Router&lt;/code&gt; finds a matching route and calls it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where to go next
&lt;/h2&gt;

&lt;p&gt;New to the library? Read these three pages in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://zankoan.github.io/dj_telegram_bot/getting-started/" rel="noopener noreferrer"&gt;Getting started&lt;/a&gt;: install, connect the webhook and answer &lt;code&gt;/start&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://zankoan.github.io/dj_telegram_bot/handlers/" rel="noopener noreferrer"&gt;Handlers&lt;/a&gt;: reply to commands, messages and buttons.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://zankoan.github.io/dj_telegram_bot/examples/" rel="noopener noreferrer"&gt;Examples&lt;/a&gt;: copy a working example for what you are building.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Try it and tell me what you think
&lt;/h2&gt;

&lt;p&gt;If you enjoy it or find it useful, please give it a star on &lt;a href="https://github.com/zankoAn/dj_telegram_bot" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; and share it with your friends. It really helps the project grow.&lt;/p&gt;

&lt;p&gt;Feel free to contribute if you want. Issues and ideas are welcome too!&lt;/p&gt;

</description>
      <category>django</category>
      <category>python</category>
      <category>telegram</category>
      <category>opensource</category>
    </item>
    <item>
      <title>I Built a dj_telegram_bot pkg to create Telegram Bot with Django</title>
      <dc:creator>#!z@nko...;</dc:creator>
      <pubDate>Tue, 28 Jul 2026 11:56:26 +0000</pubDate>
      <link>https://dev.to/zankoan/-telegram-bot-with-django--1co6</link>
      <guid>https://dev.to/zankoan/-telegram-bot-with-django--1co6</guid>
      <description>&lt;p&gt;Hey everyone, especially those of you who are reading these posts and sticking around with me!&lt;/p&gt;

&lt;p&gt;For a few years now I've been writing Telegram bots on top of the Django codebase I already had lying around, but at some point I thought — why not just turn this into a proper package? It'd be easier to install and you could get moving on your work way faster.&lt;/p&gt;

&lt;p&gt;So that's how &lt;a href="https://github.com/zankoAn/dj_telegram_bot" rel="noopener noreferrer"&gt;dj_telegram_bot&lt;/a&gt; came to be — forked from a friend's project, and I pushed it everywhere it needed to go&lt;/p&gt;




&lt;h2&gt;
  
  
  First stop: Why, why, and... why?
&lt;/h2&gt;

&lt;p&gt;A question that probably crosses everyone's mind:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Why should I use this?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What's actually the point?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What does it even have over the alternatives?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, here are a few advantages, and there will be more in future versions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;1 - Simplicity and convenience:&lt;/strong&gt; if you've worked with Django before, you can build a bot here faster than a "hello world" project 😁 Django's admin panel and ORM handle a ton of the work for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2 - Custom admin panel:&lt;/strong&gt; there's a section of the admin panel built specifically for this library — you can easily add message text and create InlineKeyboardMarkup or ReplyKeyboardMarkup for them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3 - Type-safe and ready to go:&lt;/strong&gt; Telegram types are fully validated with pydantic, so you get helpful error hints right in your editor, plus there are some built-in defaults like a sponsor channel and bot status settings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4 - Flexibility:&lt;/strong&gt; you can very easily send monitoring, logging, and notifications from your Django site over to Telegram.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Second stop: how do you actually write a bot with it?
&lt;/h2&gt;

&lt;p&gt;Since it's structured as a Django app, to work with it you need to build a Django project first; then add the library to &lt;code&gt;INSTALLED_APPS&lt;/code&gt;, You'll also need your own Django app (e.g., created with django-admin startapp bot).&lt;/p&gt;

&lt;p&gt;You can find the installation steps and more details either on the library's &lt;a href="https://pypi.org/project/dj-telegram-bot/" rel="noopener noreferrer"&gt;PyPI&lt;/a&gt; page or in the &lt;a href="https://github.com/zankoAn/dj_telegram_bot" rel="noopener noreferrer"&gt;GitHub README&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;Here are a few screenshots of how to build a simple bot (there's also a demo video on GitHub).&lt;/p&gt;




&lt;p&gt;&lt;em&gt;See how quick it is? This example is literally just copy-pasted from another bot of mine&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The message-adding section in the admin panel&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhxdgy1wtzc5blea1ya7m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhxdgy1wtzc5blea1ya7m.png" alt="django admin panel to add msg and keyboards" width="800" height="734"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample bot code&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0eqtp4vq9rzbtnyzmd33.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0eqtp4vq9rzbtnyzmd33.png" alt="Sample telegram bot code to show options and get the link from user" width="800" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final bot output&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbrg3rogg4qizvjb2m1zw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbrg3rogg4qizvjb2m1zw.png" alt="telegram bot with dynamic keyboard and msgs" width="800" height="592"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;In the example above, I realized changing the "step" is a bit annoying... it'd be better to have a service for the user with an update-step method and so on.&lt;/p&gt;

&lt;p&gt;Oh, and the docs are still at version one — if I get the time, adding something with mkdocs would be nice.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;If you found this interesting or useful, I'd really appreciate a star on the GitHub&lt;/strong&gt; ⭐️&lt;/p&gt;

&lt;p&gt;If you'd like, you're welcome to contribute to the docs!!&lt;/p&gt;

&lt;p&gt;Thanks for sticking with me and reading all the way through, hope you're doing well. Cheers ❤️&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/zankoAn/dj_telegram_bot" rel="noopener noreferrer"&gt;https://github.com/zankoAn/dj_telegram_bot&lt;/a&gt;&lt;/p&gt;

</description>
      <category>telegram</category>
      <category>django</category>
      <category>python</category>
      <category>bot</category>
    </item>
    <item>
      <title>upload local image/video in django TinyMCE text editor.</title>
      <dc:creator>#!z@nko...;</dc:creator>
      <pubDate>Thu, 23 Dec 2021 21:20:46 +0000</pubDate>
      <link>https://dev.to/zankoan/upload-local-imagevideo-in-django-tinymce-text-editor-mkn</link>
      <guid>https://dev.to/zankoan/upload-local-imagevideo-in-django-tinymce-text-editor-mkn</guid>
      <description>&lt;p&gt;In the TinyMCE editor, when you want to upload an image, you do not have the option to upload your local image (i.e with the file browser dialog) like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzmsc6wffy3eslqu92cs3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzmsc6wffy3eslqu92cs3.png" alt="What? Where is the upload option!"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;to solve this problem you need to edit templates of django admin panel and create new js file for add upload option...&lt;/p&gt;




&lt;h2&gt;
  
  
  0. Directory Structures
&lt;/h2&gt;

&lt;p&gt;Suppose you have a directory structure like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

. 
├── core
│   ├── urls.py
│   ├── settings.py
│   └── ...
├── post
│   ├── admin.py
│   ├── models.py
│   └── ...
└── static
    └── js
        └── uploader.js


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;in this structure you have static directory to store your static file(&lt;a href="https://docs.djangoproject.com/en/4.0/howto/static-files/" rel="noopener noreferrer"&gt;if you don't have this static file read this page&lt;/a&gt;) and now create a js directory and then put the uploader.js file in this directory, But what data should be in this file?👇🏻&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Add upload feature to TinyMCE editor.
&lt;/h2&gt;

&lt;p&gt;You have to up this js code in uploader.js:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

tinymce.init({
      selector: "textarea#id_body",      
      height: "700",
      width: "1300",
      plugins: "insertdatetime media image preview",
      toolbar: "undo redo |  bold italic | alignleft alignright aligncenter alignjustify | image media | preview",
      image_title: true,
      image_caption: true,
      automatic_uploads: true,
      image_advtab: true,
      file_picker_types: "image media",

      file_picker_callback: function (cb, value, meta) {
        var input = document.createElement("input");
        input.setAttribute("type", "file");
        if (meta.filetype == "image") {
            input.setAttribute("accept", "image/*");}
        if (meta.filetype == "media") {
        input.setAttribute("accept", "video/*");}

        input.onchange = function () {     
            var file = this.files[0];
            var reader = new FileReader();
            reader.onload = function () {
                var id = "blobid" + (new Date()).getTime();
                var blobCache =  tinymce.activeEditor.editorUpload.blobCache;
                var base64 = reader.result.split(",")[1];
                var blobInfo = blobCache.create(id, file, base64);
                blobCache.add(blobInfo);
               cb(blobInfo.blobUri(), { title: file.name });
             };
             reader.readAsDataURL(file);
         };
         input.click();
      },
      content_style: "body { font-family:Helvetica,Arial,sans-serif; font-size:14px }"
  });


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This script contains small configuration for the TinyMCE editor, if you want more options in the toolbar or add multiple plugins and so on.. you can put your configuration in this file, and you can find all the configuration options in the TinyMCE documentation...&lt;/p&gt;

&lt;p&gt;if you want to add more image configuration, you can read this link below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.tiny.cloud/docs/plugins/opensource/image" rel="noopener noreferrer"&gt;image&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.tiny.cloud/docs/configure/file-image-upload" rel="noopener noreferrer"&gt;file-image-upload&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Edit Django AdminPanel
&lt;/h2&gt;

&lt;p&gt;Ok lets edit admin panel template to add TinyMCE editor and upload image/video option.&lt;/p&gt;

&lt;p&gt;first you need to find this file and edited:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

/django/contrib/admin/templates/admin/change_form.html



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This file has the tag &lt;strong&gt;{\% endblock \%}&lt;/strong&gt; in the end line, you must put the following line before this line&lt;br&gt;
‍‍‍‍‍```&lt;br&gt;
&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
This line is to load uploader.js file, which is exactly my js script for adding the image/video upload feature, this line should be added to this file.

---
## 3. Upload Image/Video


Now your job is done! You can save **change_form.html** and reload the admin panel, now the image upload option has been added and you can use it to upload your video and images.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bpwufgf0rsfvyw04gj3v.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3o1i2c3pl01hcj2zmtml.png)


---

**Note:**
&amp;gt; If you have the TinyMCE configuration in **settings.py**, after this change in the &amp;lt;u&amp;gt;admin panel&amp;lt;/u&amp;gt;, all **TinyMCE** settings will be ignored and the configuration in the &amp;lt;u&amp;gt;uploader.js&amp;lt;/u&amp;gt; file will be applied.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>django</category>
      <category>texteditor</category>
      <category>tinymce</category>
      <category>editor</category>
    </item>
  </channel>
</rss>
