Upgrading Django version - cookiecutter-django

I am trying to update the django version in requirements/base.txt from 3.0.11 to 3.1
requirements/base.txt
# Django
# ------------------------------------------------------------------------------
django==3.1 # pyup: < 3.1 # https://www.djangoproject.com/
Does upgrading Django version in the project would create a problem ?

Reading the official documentation it doesn't seem to have any compatibility issue.
However, you have to see all the dependencies that your project uses.
For exemple, if a requirement poll uses django and has defined its requirements.txt file as django<3.0, so you will have an error.
In general, the best way is to create a new virtual environment and test if there are any dependency issues.
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt
python3 manage.py test
python3 manage.py runserver

Related

ModuleNotFoundError: No module named 'wagtail'. How to fix this?

I have tried to get wagtail up and running twice: once using the guide in https://engineertodeveloper.com/wagtail-developer-portfolio/ and this time using: https://docs.wagtail.io/en/v2.12.4/support.html. Both times the error comes after:
python manage.py migrate
pip freeze shows:
anyascii==0.2.0
asgiref==3.3.4
beautifulsoup4==4.8.2
certifi==2020.12.5
chardet==4.0.0
Django==3.1.8
django-filter==2.4.0
django-modelcluster==5.1
django-taggit==1.4.0
django-treebeard==4.5.1
djangorestframework==3.12.4
draftjs-exporter==2.1.7
et-xmlfile==1.0.1
html5lib==1.1
idna==2.10
l18n==2020.6.1
openpyxl==3.0.7
Pillow==8.2.0
pytz==2021.1
requests==2.25.1
six==1.15.0
soupsieve==2.2.1
sqlparse==0.4.1
tablib==3.0.0
urllib3==1.26.4
wagtail==2.12.4
webencodings==0.5.1
Willow==1.4
xlrd==2.0.1
XlsxWriter==1.3.9
xlwt==1.3.0
So I have installed wagtail (latest version)
As pointed out by Tibor at Slack, python sometimes becomes confused. Solution was to use
python -m pip
instead of just
pip

Terminal issues error message that no Django module "models" exists, but it is in the directory

I'm a motivated beginner working my way through Python Crash Course. I created a project and an app using Django. I'm unable to get the python manage.py run server command to work. This is the header of the long error message:
"Watching for file changes with StatReloader
Exception in thread Django-main-thread".
The middle includes several lines of "".
At the end, it says "from models import Activity"
"ModuleNotFoundError: No module named 'models''
There IS a module named models in the directory. This is my second exercise using Django, and the program worked earlier. I've searched the net and read everything remotely similar, but have been unable to find a solution. How can I make the program recognize a module that is there?
I think the problem was that the version of pip in the virtual environment was the python 2.7 version instead of the 3.9 version I used to create the project. It had to be upgraded using:
python3 -m pip install --upgrade pip
I also used python3 for the manage.py runserver command instead of just python.

ASP.Net Core 2.2 or 3.1 SPA with React and Docker

I am trying two days already to containerize ASP.NET Core 2.2, but without any luck, I have read most than 20 articles about it, and I am not sure if it is even possible. It leads me to an error page stating that it cannot find npm and to check if it exists and is added to PATH.
I tried adding this
RUN apt-get install --yes curl
RUN curl --silent --location https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install --yes nodejs
to the dockerfile, also added **/node_modules to the .dockerignore file as I read in the articles but without luck
Read that someone has succeeded on .NET Core 2.1, but I haven't tried it because it won't work for me. Can someone please share if it is possible with dot net core 2.2 or above, I can settle for 2.2, 3.0, 3.1.
I finally managed to do it.
the trick was to use another image (node:13-alpine) to do the npm install and to add a condition in the .cproj file for the publish part.
It is explained better in this article:
Link

pipenv install glob fails

I tried to install glob in my virtual python (version 3.5) environment. This is an error I got. I found similar questions on this channel, but not much of help.
$pipenv install glob
Installing glob…
Collecting glob
Error: An error occurred while installing glob!
Could not find a version that satisfies the requirement glob (from versions: )
No matching distribution found for glob
The issue is that pipenv looks up the version in the url specified in [[source]] in the Pipfile and glob is not in there. However, glob is part of the Standard Library in Python so you do not need to install it via pipenv and you can just call it from your script 'import glob' and it should work.
You are using python 3.X
here are the correct glob versions
for python 2.7
sudo pip install glob2
for python 3.7
sudo pip3 install glob3

How to intall drush on hostgator servers

I would like to have Drush on Hostgator shared hosting. I just spent 1 hour trying various outdated tutorials (Drush now requires composer). Does somebody have proved, tested and working solution how to install Drush there? I'm using PHP 5.4.
My last achieved step is drush st error:
Unable to load autoload.php. Drush now requires Composer in order to install its dependencies and autoload classes. Please see README.md
Content-type: text/html
When I run php composer.phar diagnose I see:
Content-type: text/html
Warning: Composer should be invoked via the CLI version of PHP, not the cgi-fcgi SAPI
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity: OK
Checking disk free space: OK
Checking composer version: OK
Incase it helps others, I had been using a variety of google inspired resources to install Drush, which just complicated the situation for me. I would highly recommend following the official documentation which is the main source of information. I even read on there that they only maintain the documentation here, not even on drupal.org.
I was missing this step based on other instructions,
Now add Drush to your system path by placing export
PATH="$HOME/.composer/vendor/bin:$PATH"
into your ~/.bash_profile (Mac OS users) or into your ~/.bashrc (Linux users).
These instructions helped me resolve the error:
curl -sS https://getcomposer.org/installer | php mv composer.phar
/usr/local/bin/composer ln -s /usr/local/bin/composer
/usr/bin/composer
git clone https://github.com/drush-ops/drush.git /usr/local/src/drush
cd /usr/local/src/drush git checkout 7.0.0-alpha5 #or whatever
version you want. ln -s /usr/local/src/drush/drush /usr/bin/drush
composer install drush --version
I think you are trying to use Drush version 7.x.
Try using Drush 6.x, I don't think it requires composer. Drush releases. I have had drush 6.4 installed on shared hosting environment successfully without any problems.

Resources