Tuesday, March 12, 2019

How to make Brother HL 2040 printer working under Linux?


Go to this link -> https://www.openprinting.org/printer/Brother/Brother-HL-2040

Click on the link "directly download PPD" which is underlined in green colour
PPD for Brother-HL-2040


Now in your linux machine (Debian based)
goto printer settings -> Select the "provide PPD" option -> Browse to the downloaded PPD file and "apply"

Check with the test print.

Friday, March 1, 2019

how to do math operations inside Django template?

1. Install "django-mathfilters" package using pip
   pip install django-mathfilters

2. Open settings.py file of your Django project and add  'mathfilters' in INSTALLED_APPS section.
   After this your settings.py file's INSTALLED_APPS section will look as follows
   INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'mathfilters',
   ]

3. Now you can do the basic math operations like add, sub, mul, div etc., like as follows
    add - {{ 8|add:4 }}
    mul - {{ your_var|mul:2 }}

For more details please refer -> https://pypi.org/project/django-mathfilters/