django-tinymce modern theme - django

I'm having issues getting the modern theme to work with django-tinymce. Both the simple and the advanced themes render correctly, but when I switch to the modern theme nothing renders and I get a 404 error for /static/tiny_mce/themes/modern/editor_template.js in the console
I am attempting to do all of this in the django admin. The error is coming from /static/tiny_mce/tiny_mce.js which is interesting because I don't have anything installed in that directory. I'm using /static/js/tinymce as my TINYMCE_JS_ROOT in settings.py. When switching between simple and advanced theme, everything works correctly.
I've tried to copy a version of editor_template.js in the exact location it's looking, but I still get the 404. It's like it wipes out /static/tiny_mce if it exists and replaces it with something, but I can't figure out how/where it's getting that from.
I'm using an install of TinyMCE 4.1.3 from http://www.tinymce.com/download/download.php and django 1.6.5

I've been struggling with TinyMCE recently, as well. I'm using TinyMCE v4 and Django 1.6. I went down the django-tinymce/django-flatpages-tinymce route because I had these working on another project. Some how it wasn't working for this new project. I did some research and decided to just go straight TinyMCE, no Django applications (eg, no django-tinymce or django-flatpages-tinymce).
This method cuts down on all configuration in Django, and it can be completely handled within the tinymce.init call. I found this much easier than dealing with Django's settings files, overriding models, etc. Just simply find the template you want TinyMCE to spice up and add the init call there.
The example here for full featured example really helped me:
http://www.tinymce.com/tryit/full.php
This use the modern theme...
I simply added this to whichever change_form.html template for whatever model I was needing the rich editor. For instance for flatpages:
admin/flatpages/flatpage/change_form.html
Or custom model in app:
admin/custom_app/model_name/change_form.html
I know this is exactly an answer to your question, but I think it's worth thinking about and might help you ultimately get what you need.
Also, I should note, it looks like only modern theme is available for TinyMCE v4:
http://www.tinymce.com/wiki.php/Tutorial:Migration_guide_from_3.x

Related

Adding non-CMS (Django) page to Wagtail menu

I may not be understanding something obvious, but I'm struggling to add a (top-level) menu item to my Wagtail based menu that hooks to a page rendered by an included app that doesn't know about Wagtail. Ideally, it is just a normal Django TemplateView with standard urlconf, though I may need to add some custom code.
If I use the custom URL in the menu editor, I get a not found from Wagtails core.serve. I've looked at snippets, wagtail hooks, RoutablePageMixin, and the custom URL in the menu editor and none seem like it accomplishes what I'm trying to do.
It may well be that I'm simply misunderstanding the docs, but is there a simple example of someone doing this? The closest I've found so far is https://www.caktusgroup.com/blog/2016/02/15/wagtail-2-steps-adding-pages-outside-cms/. I've also searched https://docs.wagtail.io/en/v2.4/advanced_topics/third_party_tutorials.html to now avail. Any guidance appreciated.
Thx,
--Don
Hope this is useful, but it seems that my problem was not the mixing of Wagtail and non-Wagtail items - it was in my URLConf - Wagtail.core.serve occurred before the Django url I was trying to reach and was trying to respond. Once I reordered the URLConf appropriately, I am getting the view as I wanted.
Sigh...

how can I use IntelliJ live edit with django templates?

I like the IntelliJ 'live edit' feature but it doesn't work for Django templates because obviously they are just a bunch of variables and its not finding the CSS files. Is there some way of working 'live' on Django templates? (or any other templating system for that matter).
Similarly I tried to use Chrome devtools autosave but it also didn't work, presumably it wants me to open an html file locally (i.e. file://).
And using chrome inspector to edit stuff is a pain because you have to copy and paste your changes - unless I'm missing something?
I am using IntelliJ 12.0.4 Ultimate with the Python plugin (this is more or less equivalent to PyCharm) to work on Django templates. It doesn't look like the Live Edit functionality works as per usual, indeed because the template has to be rendered to HTML first by Django.
One alternative is to assign a keyboard shortcut to the "View | Reload in Browser" menu item.
Another alternative is to use a Chrome plugin such as ChromeReload: You can set this to reload a specific page at a specific interval.

django on apache - admin page links are VISIBLE but not CLICKABLE

I have just deployed a django site, and upon changing the value my DEBUG variable to 'False' causes my admin page links to change from active links to simple text.
An attempt to go directly to what I know should be the URL causes a 'TemplateDoesNotExist'.
I am sure it's not a permissions issue with Apache, I feel it is something to do with my admin configuration though I have no idea what.
I figured it out. Here is a reference for anyone else who might find themselves with this problem.
I was using what must be a deprecated method of defining my Admin models - I put them all in models.py, instead of creating a separate admin.py file for each application.
When learning django, there are plenty of tutorials floating around that recommend or give examples that use this method. Apparently this is no longer a good idea (at least not as of Django 1.4). It could probably be wrangled into working with some template hacking, but it is is probably cleaner and definitely simpler to just follow the latest conventions and create the admin.py file.
I thought I was saving time by just cramming it all into one file "for now" but without some of the magical debug-only template loading, this solution failed.
Hope this saves someone some frustration!
I know this question's been already solved.
But in my case, coming from django 1.7 to a server that runs django 1.6, I had to add
admin.auto_discover()
to my urls.py.
Well, I had added this line to the end of urls.py and django admin was all characters !
Moving it to top up the file, above definition of urlpatterns, fixed the issue.
Hope this helps :)

Opencart module development - Inject javascript/html code in some pages

I'm a beginner on Opencart and just started developing a module for Opencart which it must inject some lines of javascript and html code in these pages:
- Cart Page
- Product Page
- Confirmation Order Page
- Register form page
The official documentation doesn't have informations about how can i do that, I've tried to find a good documentation about OpenCart but I didn't find anything.
I need help. How can I do that?
Diggin necro topics;) :
The easiest way i think:
upload/catalog/view/theme/[themename]/template/product/product.tpl - here you can add your custom html for product page
[your theme name, you shouldnt overwrite default theme because it can cause damage after update]
It depends on where you're trying to insert the HTML/JavaScript.
Doing things the proper way in OpenCart, you're limited to the column-left, column-right, content-top, and content-bottom positions.
The files you'll need to create are:
admin/controller/module/mymodule.php
admin/language/english/module/mymodule.php
admin/view/template/module/mymodule.tpl
catalog/controller/module/mymodule.php
catalog/language/module/mymodule.php
catalog/view/theme/default/module/mymodule.php
To learn how to do this the first time, it's easiest to replicate an existing stock OpenCart module (preferably a simple one, such as information). Once you've replicated it you'll need to go through each of those files and replace any references to "information" with "mymodule".
After that, if you've done it properly, you should be able to navigate to Admin > Extensions > Modules and see your module in there. Then install it, use the "Add module" button to position the module on all the relevant layouts, hit save and hey presto you have a working module on the front-end.
To modify the front-end output, just edit catalog/view/theme/default/module/mymodule.php
If you want to insert your HTML somewhere other than the 4 available positions OpenCart gives you, position your module in the content-bottom position and use JavaScript/jQuery to inject some HTML where you want.
If this is for your own personal website then as Pawel S suggested it would be easiest to simply modify the relevant view files (ie. catalog/view/theme/[themename]/template/product/product.tpl), however if you're making a module which you plan to distribute then this should be a last resort.
Hope that helps!
I realize this is probably long dead by now, but if you're creating a module that needs to modify existing controllers, languages, models or views the correct tool to use is vQMod.
vQMod allows you to modify existing code on the fly using XML.
https://code.google.com/p/vqmod/

Django templating - listing available data to display

This is such a basic issue that I can only assume I'm looking at it completely the wrong way but...
I'm new enough to Django and I've taken the responsibility of redesigning a django application. The functionality is pretty good but the layout of things need to be styled and displayed a bit better.
My problem is this.
If in designing templates for for a PHP application and I want to see what attributes each of my objects have I can do a print_r (or a prettier inequivalent) and see exactly what data I can play with.
In django from the template level this doesn't appear to be possible which is baffling to me. Surely the idea of seperating design from business logic etc with MVC should also extend to have different people working on each level. If that is the case the a design person should have a way to display all variables available?
Use the django debug toolbar: http://github.com/robhudson/django-debug-toolbar
It requires minimal configuration after you install it and it will show you all kinds of useful information including the context for all the templates that were rendered, which is what you need.
To install it, in settings.py you put 'debug_toolbar', in INSTALLED_APPS and then add the following setting:
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TOOLBAR_CALLBACK': lambda request: return DEBUG,
}
See the documentation for more details.
Once it is installed you should see a little tab DJDT on the right-hand side of your page. Clicking on it opens the toolbar and the template information is under Templates.
Django has a debug tag for this purpose.