Hey guys ;)
Hope you’re doing well, summer is almost over and some of us will go back to University (for example me) or maybe even some of us will even go to school. My summer was pretty good, actually I’ve finished 2 projects and 1 is in the final stage (yep I still remember about the Chess Project 😂). Okay, let’s move to the main topic of this post.
Secret Santa done.
Actually almost done, I mean all logic and design were cooked, there is still one task - README.md. I’m going to do it after finishing this post. Secret Santa now available for everyone, you could access it via this link https://secret-santa-baf4.onrender.com/
But you need to wait about 50 secs because I deployed it with free Render trial (at least deployed, not localhost XD )
What can my Secret Santa do ?
Okay, Santa working with a simple data pipeline, first you enter all required data and then just send an email. Now more detailed.
- Participants input with 3 modes:
- manual input mode;
- file input mode;
- Faker script generator mode;
- Party general info (name, time, date, location, host email)
- Results and sending email
What more interesting All this you could do for free, even sending the emails.
More technical info about Django
I couldn’t say that after this little project I became a super Django user, I’m a beginner (I even didn’t finish my tutorial). But I’ll tell you some important stuff that I’ve learned.
In a previous post I described basics like views and urls in general. Today I wanna talk about how Django sees data.
So basically when we talk about big websites it has a database. Django allows work with different databases and changes nothing in logic. So for working with data usually you need 2 things - model and form. I think all we know is what it is. The model describes something and how it should look, form could be built on this model and then you just create form inside of view and transfer it to the frontend.
But what to do, if I don’t need to save my data to the database. We use for it sessions(cookies). My pipeline is simple, I collect data from participants form, save it to request.sessions["participants"], do the same for party info and in result page use pop method, which clear all sessions data after using it. So what I’ve done in Secret Santa.
- Created forms with specific fields (like CharField, IntegerField, FileField and EmailField). All fields are available in Django.Forms.
- Import created forms in views.py. We need to create 2 forms. One for the POST method and the other just an empty form. And obviously we need to add our form into the context dictionary.
- And finally we could access forms in HTML.
You could create Forms based on Models (for this in Form Class after all fields add Meta Class) or just ordinary Form. The difference in Model form will be very strict, if you change Form and forgot to change Model then you’ll get some troubles.
How to send an email ?
Actually I thought that it would be the hardest part of the project. But I was wrong. First of all the situation is similar to databases. You write logic once, then just change settings in settings.py. So what do we need to send an email?
We could use many different APIs, like Resend or Brevo. But the problem is that you need an email domain for this. I don’t have one. But you could still do something.
And it’s Google. All you need is to add 2 step verification for your account and create an App and get a password for it. Save your email (account where you created the App) and password (usually 16 symbols) to the .env file, and that’s all. Now you could use @gmail.com domain for sending email for everyone you want. So it’s looks like that
- from: your_email@gmail.com
- to: secret_santa_participant@gmail.com
- reply_to: party_host@gmail.com
It was really easier than I thought. I was planning to finish Secret Santa and some KNN projects by the summer end. But the KNN project I’ll start next week, I hope it will be interesting, and the more important it will be enough for getting my first job, yep I wanna try my luck on freelance.
So, see ya in September, hope you have a nice summer.
Oh yeah, I’ll add a link to my X post with 3 videos, where I tried to show Secret Santa, but there were 2 fails 😂.













