Hi Im using Filebrowser for Django and also TinyMCE. I include TinyMCE in my admin text area editor by adding a admin template to folder media in my templates with filename base_site.html
Now when I add a image with filebrowser, tiny_mce adds a leading ../../../../ before /media/uploads/etc/image.jpg
Any ideas why? I guess its some URL thats not set correct. But im not sure if its tiny_mce or filebrowser.
TinyMCE has an option to avoid converting urls to what seems to be relative urls. You need to put the following on your configuration:
remove_script_host : false,
convert_urls : false,
Check out this thread: http://tinymce.moxiecode.com/punbb/viewtopic.php?id=642
Related
I have a django site onto which I have added wagtail following these instructions.
I have set up Social Media setting using these instructions
I have sucessfully added details on the admin page ad I can return and edit these details
However I cannot access them in a template
If I display
{{settings.site_settings.SiteSettings.facebook}}
I get '' (tested using {% if settings.site_settings.SiteSettings.facebook == '' ...)
However
{{settings.site_settings.SiteSettings}}
returns None
and
{{settings.site_settings}}
returns SettingsModuleProxy(site_settings)
What am I doing wrong?
The problem was simply that I had misspelt the SiteSettings class name in models.py (very red-face)
i have a problem. In my project i am uploading file, it gets saved perfectly fine. It is accessible. I save it to the static/assets/uploaded files, ten generate the name: time + original filename.
But in django admin page i can't access it:
(link that admin page gives me)
http://127.0.0.1:8000/admin/project/minipost/4/uploaded_files/1428326830_08_name.pdf/
The correct url would be:
http://127.0.0.1:8000/static/assets/uploaded_files/1428326830_08_name.pdf/
I have no idea how do i change or redirect or whatever the admin generated link to the correct one?
Thanks in advance.
The problem was indeed MEDIA_URL
I just had to set it correctly:
MEDIA_ROOT = '/home/work/django-work/workproject/static/'
MEDIA_URL = '/static/assets/'
I'm trying to put my Django site in a subpath, say www.example.com/mysite/ but I can't get it to work 100%.
I read up on the answer Django Apache Redirect Problem , where it is suggested to just change the site in the admin from www.example.com to www.example.com/mysite/, which is exactly what I want to do and it almost works. All urls in the main urls.py gets redirected properly, but everything in the includes drop the "mysite" directive when using the links in the templates (one example is {% url journal_index %} which after the change should go to www.example.com/mysite/journal but goes go www.example.com/journal/).
Hope this makes sense.
Cheers!
Try adding the FORCE_SCRIPT_NAME setting:
FORCE_SCRIPT_NAME = '/mysite'
I was going through the tutorial of Django - https://docs.djangoproject.com/en/1.3/intro/tutorial02/
At the end they asked us to change the name of default webpage template from "Django Administration" to anything else by following steps.
1) Copy base_site.html from default folder of django to the admin directory specified in TEMPLATE_DIRS.
Currently my TEMPLATE_DIRS looks like -
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
"/home/mysite/polls/mytemplates"
)
I have also copied the admin template directory to /home/mysite/polls/mytemplates
So the structure is something like this
/home/mysite/polls/mytemplates/admin
where admin folder contains base.html and base_site.html
I have edited the title in base_site.html file but still when i run django it shows me default template title.
Can someone tell me what am i missing?
Your template directory should not have your application name in it. Django will automatically add any directory called templates that is part of any app listed in INSTALLED_APPS. This is why your custom admin template isn't working.
The first thing you should do is rename /home/mysite/polls/mytemplates to templates:
mv /home/mysite/polls/mytemplates /home/mysite/polls/templates
Next, you should have:
TEMPLATE_DIRS = ('/home/mysite/templates',)
Then, your admin templates should be in /home/mysite/templates/admin/
As for the comma : a single string in parenthesis is just a string, but with a comma it becomes a tuple. The TEMPLATE_DIRS setting is a tuple, which is why you need that extra comma:
>>> a = ('hello')
>>> type(a)
<type 'str'>
>>> a = ('hello',)
>>> type(a)
<type 'tuple'>
I figured it out. The issue was with the single quote that i had in my site name. So had to enclose the entire site name in Double quotes instead of one
I'm new to django and recently I'm following this tutorial
to write a todo-list app.
In part 2 I should customize the admin's change_list template and add an image into it.
At first I use
<img class='btn' src='static/img/on.png'>
but it turns out to be invalid.
Can anybody figure out what's the problem is? Thanks a lot.
Here is my folder structure
todo-list
todo-app
img
----on.png
----off.png
templates
admin
----change_list.html
todo-list
you can't access the static file( images, css, js ) directly in django
to serve the static files you need to use {{ MEDIA_URL }} or {{STATIC_URL}} for that How do I include image files in Django templates?, and this link
this will helps u :)