I've created a Django site that uses Bootstrap from Twitter. I've tested the site on the latest versions of Chrome, FireFox and Safari. It looks really nice. And then we have Internet Explorer (play failure music... wonk, wonk, woooonk). It seems to work ok, but it doesn't look near as nice (e.g. no rounded corners, etc). What I would like is to detect IE and then redirect them to a page that tells them that IE users may experience issues and that it is strongly recommended to use a more-compliant browser. But, unfortunately, I can't force them to not use IE. So, I need to add a flag saying that they've been show the page. Does anyone know of an app/middleware for doing something like this? I've done some googling, but really haven't found anything.
I don't think it would be terribly hard to write, but I would rather not re-invent the wheel.
Version information: Django 1.3.1; Bootstrap 2.0.2 and jQuery 1.7.2
If there's nothing at http://djangosnippets.org that does this (and I doubt there is, TBH), write it - because like you say, it's not hard - and contribute it
Related
I've an idea and want to implement it.
But I'm not sure if it's gonna work. So, wanted to get your inputs.
I would like to take screenshots of a url.
Say, when I open a web-site www.espncricinfo.com , I would like to take screenshot of that page and save locally. This saved image can be converted to GIF later on.
Can this be achieved through python ? Any suggestions/inputs to make it ?
Updated
And also is it possible to capture screenshot in headless-browser ?
Any possibilities to launch the browser in headless mode (non-GUI) and then take the screenshot of particular area of web-page ?
To take a screenshot using python:
import pyscreenshot as ImageGrab
im = ImageGrab.grab()
im.save('path/to/image/folder/image_name.png')
im.show()
Yes and no, if you send a request with urllib you will get the HTML in return, which is step one to displaying a webpage. But you have to build that webpage from that with a browser engine, otherwise all you will see is a bunch of text.
There are some python libraries that can do this, such as pywebkitgtk, but those are probably not going to give you the best experience and support.
Another thing you could try is to use crod and firefox/chrome/whatever and then use python to automate the process.
Oh, and by the way, I strongly recommend upgrading to python3
I know it is a bit to late now, but just saw this question and in case anyone else is looking for a mighty tool, to do screenshots and also use headless browsers with python... I just want to recommend to look more deeply into https://www.seleniumhq.org/. There are many tutorials on youtube available. However, this is IMHO the most accurate framework to execute your task, IMHO. To make screenshots, you can then define the screen resolution etc.
I want to create a pretty simple site with a few pages using Django. I guess I could use Wordpress. But there is some custom stuff (like a special kind of calendar app) that I rather do in Python than PHP.
I came across simple-pages which seems like a nice middle way between flat-pages and a fullblown Django CMS (which just seems overkill). It can automatically generate menus. But it seems like it hasn't been updated in a long time. Is it deprecated or is it stable? Or do flat-pages have the same functionality these days?
Honestly, It would be super easy to build your own small custom CMS since you know python. It would only take a few models and not a lot of time - the result being something better customized for your needs.
I've used some of these examples before - and they work ok, but I always find myself having to add something more.
One idea is to check out what sub-applications some of these things are using - maybe import only what you really need.
But I almost always find myself spending a LITTLE extra time to build out my own schema/structure for simple pages Then using a nice admin skin like grappelli when handing it over to clients (you get SORT of that wordpress feel (sort of))
Lots of admin customization that can make it easy for clients (and You) to work with static pages.
I have installed FaLang component to use multi-language support everything is working fine except the alias structure. When we are switching the language the URL not get changes as per the added alias conversion added into admin section. I tried almost all activities enabling both plugins but still the problem is as it is.
I believe Shaz is correct, there is no solution within FaLang at this time.
I asked the developer about this in Feb 2012 and he mentioned he was still working on it, but currently, with FaLang v 1.1.7 it still doesn't happen.
Initially I was really excited when FaLang appeared, but now I'm not so sure. I work on a lot of multilingual sites, and I don't want to get get stranded with multilingual Joomla 2.5 sites as has happened to me with many Joomla 1.5 sites I developed with JoomFish.
I know many well respected developers like FaLang, but FWIW I now favour the native language capabability built into Joomla 2.5. It's not perfect, but for now they have my confidence that it will improve.
Unfortunately this doesn't solve your problem, but if you need an introduction to how it works, here is one good link:
[http://bit.ly/LpPoV2][1]
and another one
http://www.youtube.com/watch?v=gnhVVtyejPg
Initially I found the process a bit cumbersome, but once I got used to it, it's works quite well ... and yes, the aliases work as you would expect.
Good luck!
Does anyone here use django-grappelli here ?
I would like to read some experience of developers or users, if there are common mistake to avoid or why you use or do not use grappelli.
Thanks for sharing
I'm using grappelli as well. I'd be content with django's normal admin, but if you need to present the backend to someone else grappelli is much more appealing.
The current grappelli version 2.1 is working quite good with django 1.2. The only problems you(sometimes) run into is that 3rd party apps have sometimes some problems, which you can solve in most cases quite easily with changing the custom templates they are coming with (in most cases it's just other names for css classes etc, sometimes there are some js incompatibilities as well, which you can solve easily!
The actual version of grappelli also has a nicer html/css framework which enables you to easily use their styles/ui elements in your own templates. Have a look at http://grappelliproject.com/ for that (it's not totally valid for the actual version but gives you a small impression on what to expect!)
According to the developers, grappelli should soon work together with the marvellous django-admin-tools,which offer you drop down menus within the admin and a customizable index dashboard! Installation is not quite complicated, just do not forget to pass the adminmedia folder to manage.py! All in all I think it's quite recommendable (also check out django-filebrowser and medman if you dont know them yet, which come from the same developers and work very well together with grappelli)!
I have used Grappelli several places and suggest using it, if you are using admin for anything more than a "database debugging" purpose.
From django 1.1.1 onwards, you can create multiple instances of admin, so generally, I keep the main admin to examine the data as it is, and another instance of it for using purpose, with grappelli.
A minor issue is that,
On the dev server, it is hard to ask django to use a different admin media folder, and the easiest way is to use the command line parameter, as it is documented.
I started using django-grappelli recently and will like to point out 2 cases that newbies like me have a high chance of wasting time on:
For Django==1.6, use grappelli==2.5 and not the current latest 2.6. Also for Django==1.5/1.4 use grappelli==2.4.The official docs clearly mention it but many may overlook it and later wonder why it is not working.
In INSTALLED_APPS setting, if grappelli is not placed above django default apps it will not work. I used to think that order is not of importance for INSTALLED_APPS but this made me change my mind.
Suppose you are running a Django site, and have a legacy PHP forum to support and integrate into your site, since current Django forum solutions are not mature enough.
What is the best way to do this?
Currently I have a simple view, which renders a very simple template which extends my site's base template, and the content area has nothing but an <IFRAME> which holds the forum as its src. A small jQuery function is used to maximize the <IFRAME>'s height (once it finishes loading) so as to contain 100% of the forum content.
But all of this sounds pretty awkward. How would you go about this?
There are a few options. None are ideal (but mixing two platforms never is!)
Use iframes as you've suggested (bad as the address in the address bar is always that of the django page and if somebody copes a link off the forum, it will be the PHP forum, not the django holder)
Use iframes but instead of using the same src all the time, parse the URL and append the relative bit onto the src of the iframe. ie if django sees /forum/this-url, set the src to http://forum-address/this-url and make sure all your links target parent. This has the advantage of showing the correct link in the address bar at all times (rather than it always being /forum/). You'll need to hack your forum for this to work.
Proxy the content and inject it into the page properly. You'll need to pass cookies and it might get really messy but in most terms, this is a great way to integrate things because your links will always be correct. You'll need to butcher your forum theme to strip out everything outside and including the <body> tags.
Theme your forum in the same way as the Django site. This would give best performance but you might have issues if you use dynamic stuff in your django template. An option to get around this is by having the django template cache things to memcache and using php-memcache to pull them out into your forum template.
I have done both 3 and 4 in the past. I used 3 for a very simple form (so didn't have to deal with cookies and sessions as you will). I used 4 for integrating a FluxBB forum into a Wordpress install. Both PHP but it would be uber bloat to load FluxBB inside Wordpress. I cached the dynamic template things into memcache and pulled them out in the forum template.
For this, I would probably suggest going with #4. It's a pain in the arse having to maintain two themes but it's by far the fastest performing solution.
When I read the question summary I immediately thought that you would need some kind of script, which could be linked to a signal via the Dispatcher in Django, to syncronize the user database from your Django site to the forum. This would keep the authentication side of things in check - but you still need to do one of the things that Oli has suggested, to make them look the same.
Themeing will probably be the least hassle-free route, but that's not to say it will be easy!