Django 1.5 bug with template "extends"? - python

I'm trying to figure out what is wrong with my code. As far as I can tell it may be a bug with Django 1.5. I am running on windows. The templates, css, etc.. are being found no problem. Semantically everything is being outputted to source correctly. The problem is some sort of quirk when the browser renders the page, possibly a development server quirk.
The issue is very difficult to explain so I made a video and put it on YouTube. The quirk only occurs if the the template has an "extends" in it.
Video showing the quirk

As you say in the comments, the problem is with chrome as far as I know the Inspect Web code is different from the View Source code, a blog's post about this, maybe this can happen because a chrome's bug or I do not know if Jquery makes and inject or something like this, I do not think that this is a django's bug. So i think that you do not have to worry of all about this.

The answer to this question turns out to be the Visual Studio editor I was using. The html layout page was being saved with BOM turned on. You have to manually turn this off in Visual Studio. Basically it was saving the page in a way Chrome did not understand completely.

Related

Authenticating a Minecraft Microsoft account with Python

What even am I doing
So, as Minecraft Java has been slowly switching over to using Microsoft based accounts instead of solely Mojang accounts, I have been trying to put together an authentication method for a small launcher project I've been working on.
The First Issue.
I've been following a piece of documentation here, which had instructions on what GET and POST requests to send to which URLs, and how to parse them, etc. It's worked pretty well, except for The First Issue.
It was a dark and stormy night, and the Microsoft Authentication URL used Javascript for redirects, so the Requests library I was using in Python could not follow the redirects. There might be a way to parse the HTML content and find the redirections or something, but that is way above my head, because I am still new to even Python.
So I looked around for a solution that would let me follow the JavaScript redirects, and the best solution (in concept) looked to be using a headless browser. This led me down a long path until I came face to face with The Second Issue.
The Second Issue.
I looked around for a headless browser that I could use, and I found a couple:
Selenium, or
PyQT WebEngine or WebKit
(I know there are lots of others but I chose these and used them for examples)
From here, the issue isn't so much an issue to fix, but the issue of I don't know what I'm doing.
I looked into Selenium, and it looked promising, but the fact that I had to download a WebDriver confused me in terms of how I would package that, since this is going to be used for a distributed application.
I then looked into PyQT WebEngine, and it just confused me in all respects, so basically I just need some info on maybe how to use it. I also don't need to have to use PyQT to launch a window, or design my UI, or anything else. I already am planning to use Kivy for the GUI. I just need a headless browser or some other solution to follow Javascript redirects when sending a POST request to a certain URL.
So,
From here I just want to ask advice on which route I should take, since there seems to be a broad amount of options I could use. I've already mentioned what I need, so any advice on how or what I should use, in terms of headless browsers, libraries, etc.
Also if anyone has any other suggestions for how to authenticate a Microsoft account, please let me know.
I'm almost done
If there is anything I could answer or clarify, just let me know. I will highly appreciate all advice or suggestions.
Thanks,
Pyrotex7
Well to resolve this - I just went with PyQt in the end after messing around for a while.

Can I use html&css in kivy and python3?

I am currently developing an embedded multi-touch kivy program with python 3.52 in linux. Kivy is good, but I find GUI developing is quite difficult in some way, and animations are often quite laggy.
Also, I found that the program gets quite slow if I put many widgets in a single page. My program contains a lot of widgets so I am also thinking implementing a webview could help.
So I am looking for html and css views in particular screens for better look and feel (and maybe improvement of animation by using transition?).
I've found Cefpython, but it says it works only for python 2.7 and says it is not stable. And it seemed like it is just getting url from the internet not bringing html and css from a file system. (Correct me if I am wrong.)
Actually, I don't even need a function as a browser, and all I need is html & css for UI/UX development for couple of screens.
My embedded system doesn't always support internet(meaning it should work without internet). So I can't put any url in it. Once again, I am only trying to use them for styling. Is there a good way of doing it? Or there is no such thing that I want?
Or is there any other recommendation?
No, unless you are willing to implement html and css parsers and a web renderers, of course. I would say it's better to find why you find it difficult to do certain things with kivy, and how to remedy that. I've yet to find an UI/layout/template that is easier to do with the web technologies than with kivy, but i'm way more profficient at kivy than at web front end, so i might be biased.

Django 1.2.3 compatible with python 2.5.2 ? Weird django behaviour

Well main question of the day will django work correctly under python 2.5.2 ?
So why i am asking this question?
First of all i have some test class written , nothing special which renders a page. The problem is that everytime i access this page i get random 3 different responses :
1)exceptions must be classes, instances, or strings (deprecated), not type
2) Http404
3) page renders normally .
And generally i can refresh until i get the result i want , well in my case normally rendered page. I am a little bit confused what even to think . Because my written class does pretty much nothing.Just a test class to test some things.
I run Django 1.2.3 under python 2.5.2 on Debian .
Also what i noticed . I use PyCharm 1.1.1 through remote host with auto upload every time change is made , it uploads but somehow changes are not always applied after initial upload . What i mean is that it feels like files are not compiled ~~ if u can say it this way ...
What's teh chance that it has basically nothing to do with python and django O_O and that are some other weird bugz ?
Yes, it is compatible:
http://docs.djangoproject.com/en/dev/releases/1.2/#python-compatibility
Post your class -- there could be thousands of reasons it's not working correctly.
PyCharm and your host not updating files on your host would have nothing to do with Python or Django, but rather PyCharm and how it's uploading to your host.
After a more thorough search i found this topic Restarting a Django application running on Apache + mod_python , which explains probably everything. Except i still don't really understand why mod_python sometimes does apply changes without apache being restarted sometimes i doesn't ..
By default mod_python decides when to reload, so you'll get what you get when you get it.
Maybe I am mistaken, but I thought there was a directive you could send that would explicitly force the python reload now. That should (in theory) help with achieving consistent but perhaps not ideal, behavior.
Off topic, this sounds like a good opportunity to enhance your app's logging so you'll have better breadcrumbs to follow next time things hang.

use of <$nopage> in python try-except block

I am seeing use of <$nopage> in some python scripts online and in a pdf file. I have googled for what it stands for. But could not get information about it. To be specific, in the PDF version of the book, Core Python Programming, I see this <$nopage> construct many times. But on the online version (Safari Books) of the same book, I do not see this construct. Can someone please tell me what this <$nopage> means? Thanks.
It means nothing in the context of Python at all. It's probably a mistake in the PDF rendering. I'm guessing it's a statement to prevent page breaks in the code.
Update: I finally found an example here:
http://raninho.com.br/~paper/Python/O%27Reilly%20-%20Core%20Python/237.html
That is indeed not python code, but most likely code to prevent page breaks. Pretend it's not there.

Python/Django plugin for Dreamweaver

Does a plugin exists for Python/Django into Dreamweaver? Just wondering since Dreamweaver is a great web dev tool.
I remember looking for a plugin too, but came across this stumbling block:
Designers are assumed to be comfortable with HTML code. The template system isn’t designed so that templates necessarily are displayed nicely in WYSIWYG editors such as Dreamweaver. That is too severe of a limitation and wouldn’t allow the syntax to be as nice as it is. Django expects template authors are comfortable editing HTML directly.
That being said, I found a Dreamweaver extension whilst having another quick look, so give it a try and let us know how it goes! From experience, the Eclipse solution offered by Paolo works very nicely, and the Komodo plugins look great, too. I know you are looking for a graphical editor, but emacs does a very nice job ;)
As far as I know there's no Django-specific IDE plugins out there.
However I use Eclipse with PyDev for my Django/Python needs and it is quite nice.
Found one from some guy named Beshr Kayali, but I can't try it myself, since I don't have Dreamweaver.
Beshir Kayali's plugin fails installation for DW CS5 and Extension Manager CS4.
Irony that it asks for DW CS4 or better, else "upgrade" Extension manager to CS3.
I could put some effort in to make this work, yet this is the sole review of the extension:
I allows you to insert 6 kinds of template tags; if, for, template variable, block, comment, and tags. You press a button and then get a dialog box asking you for some info with maybe a few options. It doesn't actually do too much from what I can tell, definitely skippable.

Categories