view.py not updating in Django with wsgi - django

My django application has recently started exhibiting this behaviour in live.
When I check out a new release and expand it into the appropriate directory (replacing the existing version), the new versions of the files are not picked up.
I've tried restarting apache many times and have ps -ef | grepped for rogue apache / wsgi processes, but can't find anything wrong.
If I introduce errors directly into views.py (like changing the spelling of a method) then it doesn't complain, even after restarting the server.
but if I delete views.py altogether, then it does complain that it can't find the file.
The functionality that I've changed is to do with the emailing of some data.
The emailing is still happening whenever I refresh the page, but the formatting that I've introduced is not being invoked.
Also, I've asked it to forward to a new thankyou page, but it's continuing to forward me back to the form. (and still emails the form content)
any ideas?

Have you removed all .pyc files that might be left over from the previous versions of your view.py?

Related

Django Admin Styling corrupted

I recently made some changes to my django site, one big one being upgrading from Django 2.2 to 3.1. Now my admin site styling is all messed up. I can't figure out what went wrong or how to fix. Any pointers would be appreciated!
See image of what it looks like after update....
The main home page for admin looks fine, but when I click on one of the models to view, the formatted is definitely not correct.
Also, some not all, of my images on the site are saying 404 not found...
It looks like your browser is caching the CSS / JS from the old version, you can clear your cache and reload. In chrome use ctrl + shift + r to reload.
I was facing the same problem, First I thought it was a Cache issue but it wasn't.
I checked the page source and found a css file being applied to the page which wasn't even present on my drive.
In my case the file was:
static/admin/css/nav_sidebar.css
So I created new file in static/admin/css named nav_sidebar.css,
then copy pasted the code which I got from page source and
added "display:none;" in the #nav-sidebar section(line:34) and [dir="rtl"] #nav-sidebar section(line:45 in my case).
You can find the Original code here by using Google Chrome's inspect tool.
Where to find the code
I had the same issue after bumping django from v3.0 to v3.1. I run python manage.py collectstatic to update css which solved my issue
I was experiencing the same styling as the OP's screenshots.
I had upgraded incrementally from 2.2 -> 3.0 -> 3.1 -> 3.2. I only experienced the styling issues in 3.2
The issue was that there were legacy admin styles committed to the repo in the static folder. To resolve, all I did was delete the committed admin styles, and Django then appeared to use its own styling
I was upgrading from 3.0 to 3.2 and I tried a couple of the answers here without luck. At the end, the following procedure solved it for me:
manually delete the content of the directory STATIC_ROOT (see in settings.py what you named the folder)
run the command python manage.py collectstatic This will repopulate the directory with the newst files
hard refresh your page (ctrl + F5)
I think the other answers here are necessary, but I'll add one more: You might have to bust caches in your server itself. In our example, nginx was configured to provide really long caches to our static files, so we just had to reset it to make changes come through.
Ok maybe I am late to the party but it may help others,
What works for me is:
Set STATIC_ROOT in settings.py (I guess it should be already there as project is old one)
Comment STATIC_DIR in STATICFILES_DIRS list (otherwise it will give error) and run python manage.py collectstatic
Clear browser cache.

I can't sign into the Django admin login page

I have started multiple Django projects with like four different tutorials. Every single time I try "python manage.py createsuperuser", the admin login page just loads and loads and never goes anywhere. I want to make it absolutely clear that I haven't touched a thing in the code and everything is default code. I migrated everything before login. I've tried deleting the database and re-migrating. None of that works. Can someone help me? I have made around 10-15 accounts and NONE of them work. The page just keeps loading indefinitely and never goes anywhere. I've looked at EVERY stackoverflow post and no answers work. I started a virtualenv, downloaded Django, didn't touch the code, made migrations, I followed every tutorial TOO THE LETTER(!!!) and this is what I keep getting. The current tutorial hasn't changed in default code and he signed in with no problems. I'm assuming if he did, I can...I don't think putting code in is necessary since it's all virgin code, never touched. I didn't even make any apps yet.
I've tried deleting database and re-migrating
changing the password of current superuser
deleting the entire project and following everything the instructor said (TO THE LETTER!!!)
I have made 10-15 superuser accounts and none work
This sounds similar to a problem I was seeing. I wrote a question for it here (no answers yet): Django local dev server hangs with chrome after form submission. Works in firefox
Are you using windows and the chrome browser? Try using firefox to access the admin page and login. That worked for me. I'm still trying to figure out why Chome doesn't work, though. Like you, I created a brand new project from scratch; sometimes Chrome works and most of the time it doesn't. I've also found that hitting the stop button while the browser is sitting there thinking, then refresh, makes the logged in admin page show up.

Django Install Not Visible - No Errors

I recently did a successful Django install, and everything went as expected. No errors. But, nothing shows up. It is as if I had never installed Django.
There are no errors. Checking Django/Python versions returns as expected. From the console, I can create new projects/apps, run migrations, create users, etc. Everything seems to work. Except, when I go to mydomain.com, it just loads the old site's index.html as if Django doesn't exist.
I realize the above question isn't a good question. I figured out my problem before posting the question and decided to post my answer below with the question for future reference should others have the same issue later.
After the fruitless task of deleting and recreating my project files, I eventually figured out what happened with my Django installation. I had never enabled Passenger. On the web host in this case, DreamHost, it is just a simple checkbox in the control panel to enable, but I never did.
Other than the fact that I should have remembered I need to do enable Passenger for Django to show up, a couple things should have tipped me off. There was no tmp folder with a restart.txt file. I manually added it (that file's important), but didn't stop to think about why it wasn't there. Also, the html files were loading without being in the public folder.
That gave me an hour or so of frustration today, so I thought others might google this later and find this useful. Searching for "Django site has no errors but still doesn't work" wasn't a fruitful avenue for me.

Django Not Reflecting Changes Made to App

I've written an app and have been testing it within a project. Any change I make to the project is reflected immediately. But when I make a change to the app and run the install script again, none of the changes are shown. I even look at the files in the site-packages directory and see that the change has been installed.
I've tried clearing the browser cache, restarting the browser, trying a different browser, shutting down and restarting the django server, re-sourcing the virtual environment, setting $PYTHON_PATH, and even restarted my system to no avail.
This has happened just recently, within the past hour. I was able to make django reflect the changes when I set $PYTHON_PATH and, afterword, re-sourcing the virtual env. But now that won't work, either.
I keep thinking it's a caching issue, but I'm not seeing anything on the django cache that would cause this problem.
I'm using lighttpd as the server backend if that's an issue.
If your using google chrome:
Open your site to the page where the changes are not reflecting.
press f12 to open inspect window, the developer tool in chrome.
Now left click on the reload button for a longer duration continuously, about one second long.
You will get three options Go for empty cache and hard reload in this case.
Done!

Can't Open Web forms for marketers Form Designer or Security Manager

I have had WFFM running on a Sitecore instance for a while, but it has recently stopped working. When I go to "Form Designer" on an existing form, I get the standard Sitecore "The requested document was not found" page.
Requested URL: /applications/modules/web
User Name: sitecore\admin
Site Name: shell
If the page you are trying to display exists, please check that an
appropriate prefix has been added to the IgnoreUrlPrefixes setting in
the web.config.
Note that the requested URL is stated as /applications/modules/web instead of /applications/modules/web forms for marketers.
A lot of development has occurred on this site recently, so I'm not sure when exactly this started happening.
Additional: info:
Folder and file permissions are correct.
I've tried reinstalling the WFFM package, and made sure that all the files are in place.
Several processors have been added to the HttpBeginRequest pipeline, but I removed them all to test if they were the cause - they weren't.
I haven't upgraded Sitecore since WFFM was working and the version is correct.
No errors are logged
EDIT
This also seems to be affecting the Sitecore Security Editor:
Requested URL: /appl
User Name: sitecore\admin
Site Name: shell
If the page you are trying to display exists, please check that an
appropriate prefix has been added to the IgnoreUrlPrefixes setting in
the web.config.
EDIT 2
Further investigation with this is making me think it is related to the Requested URL. I originally thought the the "Not found" page was displaying the requested url incorrectly. However, if I attempt to goto mysite.com/sitecore/shell/applications/fake folder with spaces/fake page with spaces I get this error message:
Requested URL: /applications/fake folder with spaces/fake page with
spaces
User Name: sitecore\admin
Site Name: shell
If the page you are trying to display exists, please check that an
appropriate prefix has been added to the IgnoreUrlPrefixes setting in
the web.config.
As you can see the Requested Url is correct in the error message. So in relation to my problem, I think maybe Sitecore is requesting the wrong URL in the first place.
Additionally if I go to the go the following url by typing directly into the browser, then the Security Editor opens as expected:
mysite.com/sitecore/shell/Applications/Security/User-Editor
This is quite old now but I thought I'd provide an update for anyone else who encounters the problem.
Unfortunately, Sitecore support weren't able to help beyond pointing out that setting the addAspxExtension attribute to 'true' in the link provider seemed to solve the problem. This may have been acceptable except that extensionless URLs were important to the customer.
In the end I had to amend my link provider so that addAspxExtension is set to 'true' in the web config, and then I set it to false inside the GetItemUrl method for specified sites only.
So now whenever the context site is 'Shell' or 'Admin' etc, the extensions are added by default, but switched off in my main website.
Of course, this is a work around. I still don't know how to actually fix the problem
So the first thing that I am going to tell you is that I suspect that there is something wrong with your site declaration for Sitecore Modules. In your web.config, there's a site declaration for "modules_shell" and "modules_website". Those are where the code files that run the modules are usually located... a shell folder to run the parts that run in the Sitecore shell and a web folder to run the part that is accessed by the externally facing site. Please check your site declarations (and the form.config file) to make sure that you're not in live mode or something like that. I would definitely say that this is where you should start looking.
The next thing is to say that your comments about Sitecore not serving a url in the /sitecore/shell directory is really not surprising. Sitecore processes all requests unless you specifically tell it to ignore requests (like setting it in the IgnoreUrlPrefixes in web.config), it's going to try processing it. Like going to /sitecore/shell/applications gives me a layout error because it doesn't have anything set to handle that request. Now your error suggests that there is something wrong with Site declarations.. however, even if they were all right, it still wouldn't work.