Installation of IPython in a Virtualenv

Working with Virtualenvs like pipenv is more than beneficial as you keep track easily of the different dependencies of your project and dont have to worry about your main python environment. However in during the development of your projects you might run into the situation that you require the shell for just verifying some small functions or run some scripts. The basic python shell provides is definitely suitable for this situation but using a shell like from ipython is even better. You can select last commands with the arrow keys and also have a nice highlighting, but how do you setup the ipython shell? Its straight forward: ...

March 24, 2019 路 1 min 路 Moritz Gnisia

Accessing the values of a relationship field in a Django Dashboard

Accessing the values of a relationship field in a Django Dashboard When you would like to group your instances of model by a category that stands in relationship to this model like the following: from django.db import models class model1(models.Model): name = models.CharField(max_length=256) def __str__(self): return self.name class model2(models.Model): some_other_name = models.CharField(max_length=256) name_model_1 = models.ForeignKey(model1, on_delete=models.CASCADE) def __str__(self): return self.some_other_name You might run into the problem that when you group the objects of your model2 by the field name_model_1 that you actually don鈥檛 get the exact values of this field. Instead you will be given the id of the belonging field, in this case name. But when you would like to visualise your data in a bar chart like the django extension django-controlcenter. In this case you can easily modify your queryset by just extending the string selection with the double underscore: ...

March 17, 2019 路 1 min 路 Moritz Gnisia

Adding Click- and Mouseover-Events simultaneously to GeoJson Markers on a Leaflet Map

When you are developing Leaflet Maps for Desktop and Mobile Applications, you might want to add nice features like a Mouse Over Effect for Desktop Users, but what if you have a mobile user also accessing the website in this case the easiest way might be just to add a click event. When I dealed with this problem, I found a good hint in this Stackexchange with a top answer of IvanSanchez, where he mentioned that when you bind a popup you automatically also add and click event. Having this in mind you only need to add an mouseover event to your markers! Then you have successfully added the mouseover and click event. ...

March 14, 2019 路 1 min 路 Moritz Gnisia

Download PDFs batchwise with Python

Downloading multiple PDFs in a batch depending on your browser can be a time consuming job, so the easiest way to do this properly and platform independent is simply to write a small python script 馃槂馃悕 ...

December 15, 2018 路 1 min 路 Moritz Gnisia

A simple class

Definition of the class The first step to write a class in C++ is by typing the keyword class and the corresponding name of the class like so class Airplane { // Attributes and Methods of the class come here } In the next step you can define three different type of attributes to this class: private protected public The main difference between the public and the two other attributes are the aspect that you can鈥檛 access from the outside. This might be helpful in terms of security reasons. We will just take the public attributes. ...

December 4, 2018 路 3 min 路 Moritz Gnisia