Newbee help on deploying Django App to Apache2
App written in ubuntu virtual environment python 3.8.5. Works well on Visual Studio Code development server. Am trying to make it run on Apache2 development server. I have been able to install WSGI module on Apache Server and ran a test Hello World in Python and it worked. However, the django app when ported over does not work. The error log confirms that the mod_wsgi has been created using by Python 3.8 [mpm_event:notice] [pid 607786:tid 140700034231360] AH00489: Apache/2.4.41 (Ubuntu) mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations The error I am getting indicates that the Apache / WSGI is reading the files in the virtual environment I copied over. mod_wsgi (pid=609049): Exception occurred processing WSGI script '/ File "/usr/public/apache/MCE/learn/djpro/wsgi.py", line 12, in from django.core.wsgi import get_wsgi_application ModuleNotFoundError: No module named 'django' My research indicates that this error occurs when the mod--wsgi in being interpreted by a different version than what was used to create my virtual environment. It also might be permissions/ownership issues with the file and directories copied over to the server, or improperly configured module. My question is this: Does the mod_WSGI module have to be the same as the one that created my virtual environment? My understanding is that WSGI has two components, the server side, and the application side. It would not make sense that the Server side MUST match the application side because it would not be possible to service various apps with different versions of Python/Django. I assumed the server side was python version independent and that the requirement for Python similarity was only on the application side in that the Python used to create the virtual environment and my app must match the version used to create the WSGI interface on the application side (this side not the server). That said, I have discovered there is a Python 2.7 version of the mod_WSGI for the server side which differs from the 3.7 version. Can someone clear up the Python version requirement and if it does require a match between the server and the app side, how will I be able to run future versions of Python/Django apps without having to go back and "recomplie"? Also if someone has any clues on solving my error that would be very much appreciated. Thanks Moose -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d3041741-1604-473f-8810-263bb3b16c59n%40googlegroups.com.
Re: Newbee help on deploying Django App to Apache2
Thanks Guy Very helpful thanks for the information. I'm working the issue right now. On Sunday, May 30, 2021 at 10:30:18 AM UTC-4 Antonis Christofides wrote: > Apache and nginx are called "web servers". Windows and FreeBSD are called > "operating systems". What is the term for Gunicorn, uWSGI and mod_wsgi? I > believe there's no good term, which is one reason for the confusion. > > Gunicorn, uWSGI and mod_wsgi are specialized web servers that run Python > WSGI-compliant applications. For lack of a better name, I'll call them > Python application servers, but don't forget that they are nothing more > (and nothing less) than specialized web servers that run Python > WSGI-compliant applications. > > What the Python application server does is > > from djpro.wsgi import application > > and then, in each HTTP request, it calls application() in a standard way > that is specified by the WSGI specification. The fact that the interface of > this function is standardized is what permits you to choose between many > different Python application servers such as Gunicorn, uWSGI, or mod_wsgi, > and why each of these can interact with many Python application frameworks > like Django or Flask. > > The Python application server does not *communicate* with the Django > project, it *imports* the Django project. From the point of view of the > operating system, it is the same process. You don't have a separate server > which "runs" or "communicates with" Django, which would mean that the > Python application server and Django could run in separate virtualenvs. You > have a single Python program and there is only one virtualenv. What we do > for Gunicorn, for example, is install it in the same virtualenv where we > have Django (pip install gunicorn), and then run it from there. > > I am not familiar with mod_wsgi, but the thing is, by the time it's ready > to import the Django project, Python is already running, and you can't > select or change a virtualenv any more. So selecting a virtualenv (which I > assume is possible) must be in the mod_wsgi configuration. I hope these > principles help you understand mod_wsgi's documentation. > > I find Gunicorn an easier and better way to deploy, regardless the web > server. More information: > >- How to setup Apache with Gunicorn > > <https://djangodeployment.com/2016/11/30/how-to-setup-apache-with-gunicorn/> >- Detailed instructions on setting up Gunicorn ><https://djangodeployment.readthedocs.io/en/latest/06-gunicorn.html> > > Antonis Christofides+30-6979924665 <+30%20697%20992%204665> (mobile) > > > > On 30/05/2021 09.29, Moose Smith wrote: > > App written in ubuntu virtual environment python 3.8.5. Works well on > Visual Studio Code development server. Am trying to make it run on Apache2 > development server. I have been able to install WSGI module on Apache > Server and ran a test Hello World in Python and it worked. However, the > django app when ported over does not work. > The error log confirms that the mod_wsgi has been created using by Python > 3.8 > [mpm_event:notice] [pid 607786:tid 140700034231360] AH00489: Apache/2.4.41 > (Ubuntu) mod_wsgi/4.6.8 Python/3.8 configured -- resuming normal operations > The error I am getting indicates that the Apache / WSGI is reading the > files in the virtual environment I copied over. > > mod_wsgi (pid=609049): Exception occurred processing WSGI script '/ File > "/usr/public/apache/MCE/learn/djpro/wsgi.py", line 12, in > from django.core.wsgi import get_wsgi_application > ModuleNotFoundError: No module named 'django' > > My research indicates that this error occurs when the mod--wsgi in being > interpreted by a different version than what was used to create my virtual > environment. It also might be permissions/ownership issues with the file > and directories copied over to the server, or improperly configured module. > > My question is this: Does the mod_WSGI module have to be the same as the > one that created my virtual environment? My understanding is that WSGI has > two components, the server side, and the application side. It would not > make sense that the Server side MUST match the application side because it > would not be possible to service various apps with different versions of > Python/Django. I assumed the server side was python version independent and > that the requirement for Python similarity was only on the application side > in that the Python used to create the virtual environment and my app must > match the version used to create the WSGI interface on the applicatio
Newbie question
I have a table which holds simple data like addresses. Created a form which displays the records in the form and allows the user to select a record "address" to edit. I want this edit function to be generic so it will work on any table without me having to define fields etc... and using ModelForm I accomplished by goal. Django creates a form and using instance='myrecord' it even populated the fields in the form with the record I want to edit. I can edit my fields and now it is time to save the changes back to the database. I found a .save() method for # Create a form to edit an existing Article, but use # POST data to populate the form. >>> a = Article.objects.get(pk=1) >>> f = ArticleForm(request.POST, instance=a) >>> f.save() My question is this: The .save method discuss in the Django Documentation above is a method of ModelForm but I have rendered my form and when I hit the SUBMIT button the edited fields are returned in a WSGI type object which does not have a save method. I can use the POST data and pass the PK and so on, and update the record manually with some code. BUT WHAT is the use of a .SAVE method on a ModelForm. In order to edit the form I need to RENDER it right? Is there a way to return the ModelForm object with the edited fields and then save back to the database? Thanks Moose -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6ccb9692-5f95-4f8a-86b1-18259b00c0dan%40googlegroups.com.
Re: Help
Hello I am a newbie to Django and Python. However, after a couple of intense weeks watching of some video's on Youtube, Google Searches, and Django Documentation I have been creating a cool website for quality control for my company. To answer your question I assume you have a Django application that you must debug and update. If I were you i would start by selecting a IDE (development environment) I use Visual Studio Code but there are many others. Then I would open the project and use the breakpoint functionality of the IDE to begin debugging the code. Since you understand Python and I assume you know some OOP you should be able to debug your code. As I mentioned, I'm new at this , so that is the best advise I can give you now. Good Luck Moose On Monday, June 7, 2021 at 12:22:02 PM UTC-4 mk85...@gmail.com wrote: > Sir I'm internee i know python my company has assigned me bugs to resolve > in live project but i have not didn't experience of Django. Anyone who can > help me how to find bugs destination and how to resolve. i can pay for this > i want to be expert in 1 month because i'm in probations period. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/15d258a2-0f6b-4411-9ff4-224122f737bcn%40googlegroups.com.