Create an event on Google calendar using Django and NoCodeAPI

Anozie Baron Chibuikem
4 min readAug 22, 2022

--

In this article, I will be showing you how to create an event schedule and have it sync with your user’s google calendar automatically using Django and NoCodeAPI.

Recently I needed to implement a feature on one of the projects I’ve been working on which will allow me
1. Create events and save the events to a database
2. Add the creator of the event automatically as an attendee to the event
3. Have a mail sent automatically to the event creator's email
4. Save the event automatically to my user’s google calendar when they click to join an event
5. Edit an event and have it edited automatically on the user’s google calendar
6. Delete an event and have it deleted automatically on the user’s google calendar

To implement this feature, I tried a couple of third-party APIs out there but most weren’t flexible for want I wanted(for example hiding the guest list in the mail to be sent to the user) or were too complicated to achieve something as basic as changing the name of the email sender from the third-party provider mail to your own custom name.

It was in the course of trying different things that I came across NoCodeAPI and they ticked the box. For the calendar sync I wanted, they were using google calendar API in the background and although I could have chosen to integrate google calendar API myself, I simply didn’t want to and instead preferred to try out already existing solutions out there, hence my integration with NoCodeAPI.

For the first part of this article, navigate to https://app.nocodeapi.com/ and create an account. If you successfully did that, you should be redirected to your dashboard

NoCodeApi dashboard preview

Next on the Marketplace tab, select Google Calendar and click the activate button

After activating Google Calendar, the page above will show up, click on Create Google Calendar API

Next, go ahead and click Authenticate, this will help you setup the gmail you will want to use to send out the email invites

After authenticating with your Gmail account, an API Endpoint will be generated for you. Copy and save this API somewhere as we will be using it later in our project. You can click on “Use this API” button to see all the other embedded APIs we will be using to manage our events.

Alright, let's dive into the second part Django integration with NoCodeAPI.

I’m going to assume you know how to set up a basic Django application with DRF(Django Rest Framework) for API development and Postgres as dastabse.
For this project, we will be using two apps, account and events, so go ahead and create the apps.

Add the following inside your account/models

account/serializer.py

account/views

account/utils

account/urls

from django.urls import path
from account.api.v1 import views

app_name = 'app_account_api'
urlpatterns = [
path('register/', views.UserRegistration.as_view(), name='api_registration'),
path('login/', views.UserLoginView.as_view(), name='api_login'),
path('change-password/', views.UserChangePasswordView.as_view(), name='api_change_password'),
path('logout/', views.UserLogoutView.as_view(), name='api_logout')
]

Now let's build out our events app. Go ahead and create anevents" app

Add the following to the events/models

events/serializers.py

events/urls

events/views

events/utils

Create a folder in your root directory name externals, inside externals create a folder called nocodeapi and finally inside nocodeapi, create a python file called google_calendar

externals/nocodeapi/google_calendar.py

Finally, update your main urls

With our setup complete, you can navigate to the following urls and test out the feature using POSTMAN.
The swagger UI url should be run on your browser.

Swagger UI. GET: http://127.0.0.1:8000/swagger/
To register. POST: http://127.0.0.1:8000/accounts/api/register/
To login. POST: http://127.0.0.1:8000/accounts/api/login/
To create an event. POST: http://127.0.0.1:8000/api/events/v1/create-event/
To edit an event. PATCH: http://127.0.0.1:8000/api/events/v1/edit-event/add event id/
To join an event.PATCH: http://127.0.0.1:8000/api/events/v1/join-event/add event id/add current authenticated user id/
To retrieve all event. GET: http://127.0.0.1:8000/api/events/v1/get-events/

In summary, we just finished integrating Django and NoCodeApi for creating/scheduling event both on our own database and syncing it with google calendar on our authenticated user's google calendar who clicks to join any of our events.

Thanks for reading this article, I will see you on another cool topic next time. Till then,

Stay Safe..! Keep Learning..!

Thank you for reading!

Follow me on Medium for the latest updates

--

--

Anozie Baron Chibuikem

A backend engineer constantly building a shit ton of things with python and javascript and occasionally writes on technical topics.