how to edit views.py in django when installed in ubuntu server - django

I installed Django in ubuntu server ,when I connect t my public server:8080 I got Django installed, now how to edit urls.py file or tests.py in server, should I use WinSCP or is there any graphical option to edit files in server to modify Django website

As a full Linux platform you can use any of these https://www.inmotionhosting.com/blog/ubuntu-text-editors/
I use Nano which can be run from within the folder of the file in question from the command line using
nano views.py
Assuming you're running the CLI version I suggest you edit your files from outside the Ubuntu non-graphical server and then upload those files with your preferred FTP platform afterwards.
This link also discusses the different types of editors
as well as how to find yours using $ echo $EDITOR

Related

/opt/alt/python39/bin/lswsgi: No such file or directory

I have a shared Cpanel host with the Litespeed web server. I want to deploy a Django application on it. After creating a Python application inside the Cpanel where I have not deployed the application on the host I try loading the website, and instead of displaying the Django version, I face 503 Unavailable!!
Also inside the "stderr.log" file, there is the following error.
/usr/local/lsws/fcgi-bin/lswsgi_wrapper: line 9: /opt/alt/python39/bin/lswsgi: No such file or directory
I'm creating the application with Python 3.9.
But it works when I create it with Python 3.8 and show the following message when I load the web,
It works!
Python 3.8.6
The issue is mostly caused by the lack of the Python 3.9 WSGI package. On out-of-date versions of LiteSpeed, the package needs to be installed manually.
To work around this, first ensure that LiteSpeed is up to date. LiteSpeed must be at version 5.4.10 for this to work. Once that is confirmed, execute the following script from LiteSpeed. It will pull the required Python Selector packages:
/usr/local/lsws/admin/misc/enable_ruby_python_selector.sh
Refer cpanel support

How do I continue working on an existing django project in pycharm from ddesktop computer to my laptop?

I created a django project in pycharm from my desktop computer. Now that I want to work on that same project from my laptop I'm not able to do so. What are the commands to be written in the terminal for continuing the project in pycharm from my laptop? (how do I work in that existing virtual environment and run the server now?)
If you want to work on a same project in multi device, the best option in using git which is distributed version-control system for tracking changes in source code during software development, for more information use the link below:
git
if you want to run your project on a virtual server, you have multi option, which on of them is using pycharm, pycharm has builtin tools for run your project, the other option is using builtin django and python virtual server that could run with this command : python manage.py runserver. for complete information about how run django project virtually, use this link:
The development server
Configure PyCharm for Python/Django

Using Windows to run a virtual environment Created on Ubuntu

so i have been developing a website with a backend database. The following is my current setup and it is working great:
Currently using Ubuntu 16.04
I created a virtualenv and downloaded Django and postgreSQL within the virtual environment.
I also downloaded and am using Python 3.5.2 within the virtual environment.
My entire folder structure is on GitHub so that I can edit the code on the go (Again, everything working fine on Ubuntu).
The problem comes when I want to start doing some editing on Windows 10 using Powershell. I am unsure of how to run the 'activate.sh', 'activate.csh', or 'activate.fish' file in order to run the virtual environment and initialize my server using 'python manage.py runserver' so I can start editing my website.
Has anyone run into the problem and found out how to fix this? Any help on how to get started working on Windows would be great.
If you need any more details id be glad to provide them.
Thanks!
Assuming that you have created a virtualenv on ubuntu without relocatable option. You will have to firstly create a new virtual environment on Windows because they have differences on OS variations. So navigate to the directory where you would like to create the new virtual environment on Windows and run the following command:-
virtualenv .
(Note the . specifies current directory option)
After this there will be three directories created in your directory namely
1) Include
2) Lib
3) Scripts
As now the activate.bat file is in Scripts you can activate your virtualenv by the following command:
Scripts\activate
After the environment is activated you can pip install -r requirements.txt and then run your manage.py script as usual.
For further reference you can read:-
https://virtualenv.pypa.io/en/stable/userguide/

Django site on Webfaction - how the flow of information works, and integrating with Pycharm remote dev

I have been learning Django in the development mode for a two months and I am up to speed with most basic aspects of python + django now. However, I was using the built-in runserver till this time
Now, I have got a Webfaction hosting account and wanted to know the following
1) Webfaction sets up the project with a certain Django version (say 1.6.4) and Python version (say 2.7) initially
The project directory (for say project MYAPP) is /<>/webapps/MYAPP
When the site is running in production mode, how does the apache server know which Python version, and which site-packages versions to use with the MYAPP source code to render the site?
I can see that the MYAPP folder has a lib/python2.7 folder, however when I am connected to SSH terminal, and do a "which python", i see :
which python
/usr/local/bin/python
so, do I take that this is the Python executable that is being used for rendering the website instead of the one in webapps/MYSITE/lib/python2.7 folder? How does the information/data flow about which programs to use during rendering the site with apache mod_wsgi work?
2) I was using a virtualenv in the development mode during testing. How do I use this on webfaction in production mode?
3) I am using Pycharm IDE. It worked well for the development mode. I can see that it has a remote interpreter configuration and a Deployment setting/option.
The python path that the remote interpreter settings tool detects automatically is the python executable at /usr/local/bin/python
Is this fine, or should I be pointing it to the more local python2.7 in the webapps/lib folder?
Thanks a lot of the answers and pls let me know if you need any supplemental info
Note to the OP: This should really be three separate questions.
1) For WebFaction, your Django app will use the Python version (and libraries, etc.) defined in:
~/webapps/<appname>/apache2/conf/httpd.conf
Specifically, you'll want to look at what is defined for WSGIPythonPath (which should mostly match up with WSGIDaemonProcess unless you modify the config and are doing something strange).
Note that which python just tells you what the default python is in your shell. This has nothing to do with the config file for the webapp.
2) You may want to expand on this as to exactly what your use case is and why the default Django webapp created by WebFaction doesn't fit your needs. But the short answer is:
Create a virtualenv on your WebFaction account.
Install Django, etc. into the virtualenv.
Edit the httpd.conf file I mentioned above to use your virtualenv instead.
I've done this with both a Django webapp made via the WebFaction control panel and via a custom mod_wsgi webapp. So it does work. Just make sure to use the right Python version when making your virtualenv.
3) I don't use PyCharm so I can't answer this (one reason why this question should be split up).

I've installed django on dreamhost using passenger_wsgi now how do I export my development project onto this?

I followed the wiki on http://wiki.dreamhost.com/Django .
Django is installed in my site's directory and I've even created my first project, now what do I do ?
You can copy your project files to the server and transfer your database to the sql server on dreamhost. Don't forget to make changes in your settings.py to reflect the environment. Should work otherwise me thinks.