Sentence finder: my first Django project

Sunday, October 28, 2018
Reading time 3 minutes

During the last few months, I have been captivated by Django and its rich set of features. I have been learning a few different technologies recently, including Django and Flask. I have been using Web2py for the last 3 years, and while I still use it for several projects and consider it a very stable and mature framework, I wanted to try out other frameworks to do web stuff in Python.

Today I have finished with the first effort to decouple everything in my website and make separate Django apps as much as possible: In Django’s terminology, an application is a set of files that should do something. A good practice among the Django community is to separate apps to make them as independent as possible, for example, in my website I have different applications together:

  • static_pages: This application serves the static pages in my website, for example the contact form, about me and make a donation. In this application also I have defined the base layout for the entire website, so other applications can inherit the layout from static_pages.
  • blog: Obviously, this is my blog. Every bit related to my blog lives here: mechanisms to handle posts, categories, comments in posts, RSS and Atom feeds and a few other security measurements are here.
  • music_dl, socializer, town_of_peril: Every project has its own Django application that serves all related pages for that project. This allow me to extend something for a project without having to mantain a very large codebase and add or remove these applications as required.

Advantages of aving alot of applications instead just a folder with alot of files are that you can edit, modify or even remove any of these applications at any time, or add other new applications, without having to touch a single line of the others. You just would have to create a new app, add it to the project, and you will be done .

Sentence finder

Today I have created a simple, but totally independent, Django application. Its name is Sentence Finder, is available at my Gitlab instance and it has been designed to help me studying Russian phrases, but later I have extended it to support English and Spanish too. It imports a very big list of sentences (over 2 Millions for the 3 supported languages so far) from the Tatoeba project and shows the results containing the words entered in a search form.

Results are divided in pages of 100 sentences per page, and you can click the link generated in every result to hear the sentence, of course spoken in the language selected when searching.

I have a few plans for more features to add to this application, though I like how it works right now, I think it may be useful to others and in case someone is wanting to learn Django, I think that may be helpful. I have tried to follow the best practices I was able to follow with the time I had for the project, and ideally it will be improved in future with more tasks (perhaps speech to text recognition in the results, interactive exercise generation with phrases, verb conjugations and what not?).

If you want to see a demo of this Django application, you can go to the sentence finder section in my website to see it in action. Also, visit the Source code repository


Announcements web