Will & Skill Developers

Will & Skill Developers


Thoughts, snippets and ideas from the team at Will & Skill AB, Stockholm.

Will & Skill Developers

Thoughts, snippets and ideas from the team at Will & Skill AB, Stockholm.


Tips for a cleaner Django settings.py

Clean paths import os # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # The root of the git repo - Could be ~/project or ~/repo REPO_DIR = os.path.realpath(os.path.join(BASE_DIR, '..')) # The directory of the current user ie /home/django a.k…

Faisal MahmudFaisal Mahmud

Resetting a database in Postgres

Sometimes when You are trying things out and You feel that Your Django migration files are getting out of hand and You want to start clean it might be a good idea to start fresh. Instead of truncating separate tables in a large database You can just drop the database and the recreate it. Follow these steps Become the postgres user with su…

Faisal MahmudFaisal Mahmud

Migrating from MySQL to PostgreSQL

1. Create database user & database: $ sudo -i -u postgres $ psql $ CREATE USER <DATABASE_USER> WITH PASSWORD '<DATABASE_PASSWORD>'; $ CREATE DATABASE <DATABASE_NAME>; $ GRANT ALL PRIVILEGES ON DATABASE <DATABASE_NAME> to <DATABASE_USER>; 2. Create interim database settings in settings.py NOTE: Make sure…

Erik SvedinErik Svedin

When PostGIS and pg_dump does not play well together

I was trying to make pg_dump backup of our database. When I got the error shown below: pg_dump: [archiver (db)] query failed: ERROR: permission denied for schema topology pg_dump: [archiver (db)] query was: COPY topology.topology TO stdout; This error is caused due to the fact that the user that own the topology table might be the po…

Faisal MahmudFaisal Mahmud

Django Rest Framework, Many-To-Many and Multipart

If you are using Django, you have or will probably create a model that includes both a ManyToManyField and a File/ImageField. And if you're using Django Rest Framework and want to created a new object with both a file and m2m values you may encounter the following error: questions: ["Incorrect type. Expected pk value, received unicode.”]…

Mohammed HammoudMohammed Hammoud

How to submit package to PyPi

Hi there. So we meet again. I just created a simple django package (django-session-notifier) and submitted it to PyPI. Therefore I want to share me experience on how you submit your python package to PyPI. Structure Let's say that our package has the name "awesome_pypi_package" and that it contains of a "utils.py" file. The structure of w…

Mohammed HammoudMohammed Hammoud