I am working on a custom markup formatter for Django and I wanted to interface it with MarkItUp.
It is successfully being called when I save the field, which is of type MarkupField, but when I try to preview this field from the Admin interface using the default settings, all I get back in the preview box is plaintext.
I am using the MarkItUp version from here: http://bitbucket.org/carljm/django-markitup/src
Here are my settings:
MARKITUP_FILTER = ('util.wookie.formatter.wookie', {})
JQUERY_URL = 'js/lib/jquery.js'
In urls, I have the following line:
(r'^markitup/', include('markitup.urls')),
Any ideas?
Is something serving the assets from both the MARKITUP_MEDIA_URL the JQUERY_URL locations?
Related
So, i have this problem when im trying to create my "company", when i didnt have user authentication the view worked just fine. Now i've added django allauth, and this screen appears to me:
enter image description here
So i will leave here my model and my view to create the company
Im just a begginner so sry for my bad explanation
enter image description here
enter image description here
The URLS : https://prnt.sc/K-lKvmfuQtvR
It looks like the problem is with the way your url is setup. Do you have a screenshot of the urls.py as well so we can see how you setup your url mapping. (OP added this screenshot: prnt.sc/K-lKvmfuQtvR)
Your companies/<pk>/ endpoint is catching your "create_company" value and storing it as a variable. Try moving your companies/create_company path above your companies/<pk>/ like so
path('companies/', listing_companies),
path('companies/create_company/', company_create),
path('companies/<pk>', retrieve_companies),
path('companies/<pk>/update/', company_update),
path('companies/<pk>/delete/', company_delete),
Alternatively rename companies/create_company/ to create_company/ like so
path('companies/', listing_companies),
path('companies/<pk>', retrieve_companies),
path('create_company/', company_create),
path('companies/<pk>/update/', company_update),
path('companies/<pk>/delete/', company_delete),
The end goal in either case is simply to make sure your paths are not capturing your "create_company" and storing it as that variable that it is passing along to your path's method.
How can we add custom classes to wagtail dashboard buttons like 'View Live', 'Edit' Buttons for contents created. When I browse through the core files I noticed core wagtail hooks for admin page like below (I know we are not supposed to edit the core files)
if page.live and page.url:
yield PageListingButton(
_('View live'),
page.url,
attrs={'target': "_blank", 'rel': 'noopener noreferrer', 'title': _("View live version of '{title}'").format(title=page.get_admin_display_title())},
priority=30
)
If I add 'class':'custom-class' to attrs value then the default class disappears and custom-class appears
What is the right way to do this
Edit (On further investigation)
Using wagtail hooks
I created a new wagtail app to register the hook so that I was able to register the button without altering the core files, but now I have two buttons(Duplicate), but I was expecting to edit the existing button's class attrs values
from wagtail.core import hooks
from wagtail.admin import widgets as wagtailadmin_widgets
from wagtail.admin.widgets import Button, ButtonWithDropdownFromHook, PageListingButton
#hooks.register('register_page_listing_buttons')
def page_listing_buttons(page, page_perms, is_parent=False):
if page.live and page.url:
yield PageListingButton(
('View live'),
page.url,
attrs={'target': "_blank", 'rel': 'noopener noreferrer', 'title': ("View live version of '{title}'").format(title=page.get_admin_display_title())},
priority=30
)
This portion of the documentation should address your need.
When I don't provide any of the translatable properties through my submit form, then I get no validation checking, even when I have implemented:
/**
* #Assert\Valid
*/
protected $translations;
In config.yml I have:
default_locale: cs
required_locales: [cs]
All topics about this problem were giving importance on the #Assert/Valid on $translations property, which I have implemented (I have even tried validation.yml configuration).
Now I realise, that I forgot to add, that I am displaying and submiting the form through Easy Admin bundle. I am not building the form myself. Just configuring Easy Admin settings for my entity. Maybe there's some glitch.
Please refer the following answer link related to same question:
Collection array name fields validation:
A2Lix form validation for translations field
try adding required option to your easy admin type settings
- { property: 'translations', type: 'a2lix_translations', type_options: { required: true} }
I dynamically create campaign from my website using mailsnake in django framework. Want to add the data and images directly into campaign for that i add the html data into the sections like postcard_heading00, postcard_image, std_content00.
Write the code as below:
mailsnake = MailSnake('apikey')
template_option = {'list_id':xxxx, 'subject':'testing', 'from_email':'xxxxx', 'from_name':'Test', 'to_name':'', 'template_id':54457, 'inline_css':True, 'generate_text': True, 'title':'testing' }
template_content = {"html_postcard_heading00":"<h1>Testing</h1>","html_std_content00":"<h1>Testing</h1>","html_postcard_image":"<img src='image_path'>"}
and pass this content to
campaignCreate(type='regular',options = template_option,content=template_content)
method.
Campaigns creates properly, but the content still not added into the campaign.
Can please anybody tell me why this happens?
Problem is because of Repeatable section. Repeatable section having different way to add data.
Change the template content as below.
template_content = {'html_repeat_1:0:postcard_heading00':postcard_heading[0],
'html_repeat_1:0:postcard_image': postcard_img,
'html_repeat_1:0:std_content00': std_content[0]}
I done this way and problem gets solved.
Right away: yes I know about INTERNAL_IPS.
I'm about to have my django app opened up at work integration and testing. I know there will be debugging and plenty modifications and/or optimizations to be made so I'd love to have the Django Debug Toolbar. However, I'd prefer to not have it up for all of my co-workers (who are the 'clients').
The reason the INTERNAL_IP setting doens't work for just me (btw: I have a static IP on my development computer) is that I am using Nginx as a reverse-proxy and serving with Gunicorn. Because of the reverse-proxy, using an internal_ip of 127.0.0.1 shows DjDT to any computer on the network and using that ip is the only way I've been able to see it myself.
What I'm looking for is either a way to get my IP or my login name to be the only one to access the toolbar. I once saw a thread about the user name limited access but I can't find it...
And as a side question- anyone know why the toolbar doesn't render in IE? For me it just shows as tables on the bottom of the page.
Try:
def show_toolbar(request):
return not request.is_ajax() and request.user and request.user.username == "yourusername"
DEBUG_TOOLBAR_CONFIG = {
'SHOW_TOOLBAR_CALLBACK': 'projectname.settings.show_toolbar',
# Rest of config
}
The accepted answer is no longer correct. Newer versions of the toolbar need the value of the SHOW_TOOLBAR_CALLBACK key to be a string with the full import path of the function. So if you're defining your callback function your settings.py file, you'd have to add:
DEBUG_TOOLBAR_CONFIG = {
'SHOW_TOOLBAR_CALLBACK': 'projectname.settings.show_toolbar',
}
If you face No .rsplit() Error. NEW SOLUTION:
Because SHOW_TOOLBAR_CALLBACK is now a dotted string path and not support a callable.
edit your settings.py:
def custom_show_toolbar(request):
return True # Always show toolbar, for example purposes only.
DEBUG_TOOLBAR_CONFIG = {
'SHOW_TOOLBAR_CALLBACK': 'your_project_name.settings.custom_show_toolbar',
}
In Django 4+ this username validation worked for me:
def show_toolbar(request):
return str(request.user) == "username" #... any other validations