How to fix "Uncaught SyntaxError: Unexpected number" appearing only in Chrome? - django

I am trying to run a Django site, using Gunicorn (with docker compose). Everything works as expected in Firefox, but Chrome reports the error "Uncaught SyntaxError: Unexpected number" for random .js scripts. If I reload the page, scripts are loaded without any errors.
So, at first I had a similar issue, since Chrome was randomly failing to load scripts. I solved this by changing the port in Gunicorn from 8080 to 80. However, once I did that, the scripts started loading but also started throwing the Unexpected number error.
I have tested it on both Chromium (Ubuntu 18) and Google Chrome (Windows), running the web site locally and from a server.
Also, I've noticed the following:
1) files which throw errors are rarely the same, so in one window script example1.js may work, and example2.js throws the error, and in another window example3.js throws an error and the rest work.
2) if I reload the page, no .js file throws an error.
3) every error indicates that the problem is in line 5, like this: "Uncaught SyntaxError: Unexpected number jquery-3.2.1.min.js:5".
Would greatly appreciate any advise on how to tackle this.

Related

Django app on Windows Server 2012 - HTTP Error 500.0 - The FastCGI process exited unexpectedly

I setup a django "hello world" app IIS (Windows Server 2012). The application is run successfully using the Django web server. However, when I tried to install in on IIS (following the instructions provided here) I get an HTTP 500 error with the message "python.exe - The FastCGI process exited unexpectedly".
I have seen numerous related posts on stackoverflow, but nothing seems to work for me. Based on the guidance
I have checked file permissions on both the app and virtual environment folder but they in my opinion this should not be the issue as the users IUSR and IIS_IUSRS can Read & execute, Read and List folder contents.
I have tried also to run wfastcgi-enable based on the instructions provided by this post but I get the error "ensure your user has sufficient privileges and try again". Please note that I tried running it both from an "elevated" command line and also power shell with no results.
I have reinstalled python to make sure it is installed for "all users" (as suggested by this post) but I get an error "0x80070659 - This installation is forbidden by system policy".
I looked in the Event viewer but I could not find something useful.
My questions:
Is there a specific log that I should check? How could I find it?
My django app does not have a web.config file. Should I create one?
My setup: Windows Server 2012 R2, IIS 8.5, Python 3.9.1

How to fix error 500 installing elgg on WAMP

I am trying to install elgg version 1.12.3 on WAMP, but i keep getting an 'Internal Server error' on Requeriments Step.
I activate "mod_rewrite" on my apache, and check the htaccess file. Still have no idea why dnt work.
500 error is a very generic error that does not tell much itself (it's basically "something is very wrong on server side"). You should have more details in Apache error log. It's likely that either something is off with Apache configuration or additional thing is required in .htaccess. Error log should make it clear. You can find it under "Apache" -> "Apache error log" in wampmanager.exe options.

Django CMS Deployment issues using Apphooks with Postgresql

I am trying to run a Django CMS project that i created recently. The project uses PostgreSQL for its database, and works great with the runserver command.
But i started having intermittent Bad Gateway(Nginx) issues when i deployed the project using NGINX and WSGI. This error was sometimes happening on the whole site or sometimes in the sidebar where the pages, administration, etc would show up or sometimes in the page or advanced page settings.
The error i was getting was as follows:
django.db.utils.OperationalError: SSL error: decryption failed or bad record mac
So i decided to get into the details of the error and found out that this error occurs only when i am using AppHooks in the project and that too only with PostgreSql. The project worked well when i deployed it using Sqlite database.
I further tried to resolve the issue by setting ssl = false in the config. file of PostgreSql to see if that would change anything. It changed the error i was getting earlier as follows:
django.db.utils.InterfaceError: connection already closed
So i was wondering the reason behind this issue? Let me remind you that this error is happening only when the project is deployed and not when runserver is being used.
UPDATE:
I tried using the Django-debug-toolbar to check what sql queries are being executed during these errors and it turns out the app is working fine. Somehow the debug toolbar is slowing down the applications which is not breaking the app any more. What might be the reason for the app to not work? How can i get around this issue

django-rosetta not saving translations on hitting "Save and Translate next block" in Chrome

django-rosetta is not saving the translations on hitting "Save and Translate next block" in Chrome.
It seems to be working fine in Firefox though. I tried clearing cache so that does not seem to be an issue.
On Chrome, after entering translated text and hitting the "Save.." button, I'm redirected to the main screen without my changes being saved.
I updated to the most recent version of rosetta thinking that the Issue13 fix would solve my problem but it does not.
I've also made sure that my .po and .mo files have 777 permissions.
Been a long time, not sure if you were able to sort it out?
I have a dev environment running Django 1.4.2 and Rosetta 0.6.8 on Lion and it works flawlessly. Im setting it up with the python manage.py runserver command.
Then when I wanted to deploy it to my Ubuntu 12 server Rosetta started to behave quite weird. I installed Nginx as a proxy and was running apache with wsgi. Same versions besides that. It was not just the translated strings that were not being saved but the navigation became absolute random. Did not matter what button I pressed, I suspected the proxy configuration wasn´t setup properly since I could run it locally in my dev.
To make a long story short, I finally shutdown nginx and apache and just ran django with the builtin and hence got the django logs in my terminal. It got a lot of errors that made the server restart itself every few seconds. This obviously explained the somewhat non-reliable behavior of the app. I dumped the database in production and resynced it. Now when I runserver in production it works just as good as in my dev. When I plug in apache to do the job (going around nginx for the moment) the problem still persist, not as bad as before though. Browser does not make any difference.
One of the errors that did pop up was this
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x1781710>>
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 50, inapport_excepthook
if not enabled():
TypeError: 'NoneType' object is not callable
Still havent solved this but will be posting the solution when I do.
EDIT:
Scratched the good ol´ apache wsgi setup and went for Gunicorn instead. Works really well now, not sure what that was all about but I´m quite happy with the new setup anyways.
Here´s a good setup guide
http://ijcdigital.com/blog/django-gunicorn-and-nginx-setup/
hopefully this helps someone in the future!

Occasional Internal Server Errors using Django with mod_wsgi and Apache

We are set up using Django + mod_wsgi + Apache.
Cccasionally, whilst we are doing site updates/changing the back-end Python code, site users run into Internal Server Error pages that appear to be served by Apache, not by Django (at least they are the horribly ugly ones, not the nice ones). They do seem to generate error reports though (via email) I think, they just don't seem to land on our 500 server error template.
I'd like to get to the bottom of why this is happening. Normally errors result in the Django-served (and nicely-styled) 500 error page, but just occasionally we see the ugly Internal Server Error page instead.
Does anyone have any idea why this is happening and what I can check/test/post here to stop this happening? Help really appreciated, thank you!
If Apache is showing you the 500 page, that suggests that Django threw an error while rendering the 500 page. For example, there could be a template tag on the 500.html template that Django was unable to render.
Have you looked in your Apache error logs? For Apache2 On Debian they are stored in /var/log/apache2/ by default. Your operating system may vary.
I know this behavior, had the same problem on Centos 5.3 with Python 2.5.
After I installed Python 2.7.2 and compiled the latest mod_wsgi (I think it was version 3.3) against it, those errors vanished. The problem is a bug in Python 2.5 as far as I remember in regards to memory allocation.
Be careful when using CentOS, as you can not update Python 2.4, youll have to install versions parallel. Updating Python will break CentOS system features like "yum".