How can I upgrade specific packages using pip and a requirements file?

I ran the following command and it upgraded from 1.2.3 to 1.4.0 pip install Django –upgrade Shortcut for upgrade: pip install Django -U Note: if the package you are upgrading has any requirements this command will additionally upgrade all the requirements to the latest versions available. In recent versions of pip, you can prevent this … Read more

How to revert the last migration?

You can revert by migrating to the previous migration. For example, if your last two migrations are: 0010_previous_migration 0011_migration_to_revert Then you would do: ./manage.py migrate my_app 0010_previous_migration You don’t actually need to use the full migration name, the number is enough, i.e. ./manage.py migrate my_app 0010 You can then delete migration 0011_migration_to_revert. If you’re using … Read more

How to upload a file in Django? [closed]

Phew, Django documentation really does not have good example about this. I spent over 2 hours to dig up all the pieces to understand how this works. With that knowledge I implemented a project that makes possible to upload files and show them as list. To download source for the project, visit https://github.com/axelpale/minimal-django-file-upload-example or clone … Read more

How can I combine two or more querysets in a Django view?

Concatenating the querysets into a list is the simplest approach. If the database will be hit for all querysets anyway (e.g. because the result needs to be sorted), this won’t add further cost. from itertools import chain result_list = list(chain(page_list, article_list, post_list)) Using itertools.chain is faster than looping each list and appending elements one by … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)