I've got a django site running quite happily with django-cms but now I want to include some of my own fancy javascript using jQuery. I'm rather new to django, so my problems might stem from this.
Django-cms uses jQuery itself, and so if I add jquery to the header - things break rathter unsurprisingly. How do I add my own jQuery without affecting django-cms?
At the moment my javascript files are stored in the media root which I've defined in the projects settings.py and, as mentioned, I reference them in the header.
As I read this, it seems a silly question, but I'm still perplexed.
EDIT::Some Code
I have a media root defined:
MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
and in my base template the header includes
<script src="/media/javascript/jquery.js" type="text/javascript"></script>
<script src="/media/javascript/application.js" type="text/javascript"></script>
Javascript in application.js works, but it when the django-cms stuff is up it breaks. For example, trying to add a plugin to a placeholder results in:
Uncaught TypeError: Property 'type' of object function ( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context );
} is not a function
I assumed this was because the two jQuerys were conflicting with each other
::ANOTHER EDIT:: I should probably add that I'm using django to host the static files only because this is still in development...
django CMS is user friendly and has a very intuitive drag and drop interface. It's built around the needs of multi-lingual publishing by default, not as an afterthought: all websites, pages and content can exist in multiple language versions.
django CMS is a free and open source content management system platform for publishing content on the World Wide Web and intranets.
Django Admin is to CMS as printing lines out of a database is to a sales report. Sure, it can technically give them all the features they need... But its a bad user experience and definitely not for people who arne't tech inclined.
Well, linking the django-cms's bundled jQuery does fix everything...
Alas, it uses version 1.3.2 but I think I'll deal with that rather than try and upgrade django-cms for now.
A simple solution: keep your JQuery library in the header and place all other your JS at the boottom of the page, right before </body>
. In this case in admin mode, your jQuery lib will be overrided by admin's copy, and then all of your code will be added back to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With