I've included the TinyMCE editor into my program and it's showing up, but says I need to add a API key. I've tried doing this but can't figure out where:
{% extends "blog/base.html" %}
{% load crispy_forms_tags %}
<head>
<script src="https://cdn.tiny.cloud/1/<KEY>/tinymce/4/tinymce.min.js" referrerpolicy="origin"></script>
</head>
{% block content %}
<div class="content-section">
<form method="POST">
{% csrf_token %}
{{ form.media }}
<fieldset class="form-group" id = #mytextarea>
<legend class="border-bottom mb-4">Add Law</legend>
{{ form|crispy }}
</fieldset>
<div class="form-group">
<button class="btn btn-outline-info" type="submit">Finish</button>
</div>
</form>
</div>
{% endblock content %}
This is my form.html template.
Here is my settings.py:
TINYMCE_DEFAULT_CONFIG = {
'cleanup_on_startup': True,
'custom_undo_redo_levels': 20,
'selector': 'textarea',
'theme': 'silver',
'plugins': '''
textcolor save link image media preview codesample contextmenu
table code lists fullscreen insertdatetime nonbreaking
contextmenu directionality searchreplace wordcount visualblocks
visualchars code fullscreen autolink lists charmap print hr
anchor pagebreak
''',
'toolbar1': '''
fullscreen preview bold italic underline | fontselect,
fontsizeselect | forecolor backcolor | alignleft alignright |
aligncenter alignjustify | indent outdent | bullist numlist table |
| link image media | codesample |
''',
'toolbar2': '''
visualblocks visualchars |
charmap hr pagebreak nonbreaking anchor | code |
''',
'contextmenu': 'formats | link image',
'menubar': True,
'statusbar': True,
}
TINYMCE_JS_URL = 'https://cdn.tiny.cloud/1/<KEY>/tinymce/5/tinymce.min.js'
and finally my models:
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
from django.urls import reverse
from ckeditor.fields import RichTextField
from tinymce.models import HTMLField
class Law(models.Model):
identifier = models.CharField(max_length=15)
title = models.CharField(max_length=100)
description = models.TextField(max_length=400)
definitions = models.TextField()
content = HTMLField(blank=True, null=True)
date_posted = models.DateTimeField(default=timezone.now)
writer = models.CharField(max_length=100)
signed = models.DateField()
proposed = models.DateField()
author = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse('law-detail', kwargs={'pk': self.pk})
I can't seem to figure out where to put my API key. I've tried everywhere and can't seem to figure out an area for it. Any help is appreciated.
You can sign up for a free API key at tiny.cloud . Note that new accounts come with a 30-day trial of all of TinyMCE's commercial plugins, and trial access to Tiny's Support channel. After these thirty days, those commercial entitlements are removed, but the API key will continue to serve the open source, community edition of the Editor.
Once you have an API key, it goes in the place of <KEY>
in the URL you call to load TinyMCE:
https://cdn.tiny.cloud/1/<KEY>/tinymce/5/tinymce.min.js
For more information, check out: https://www.tiny.cloud/blog/how-to-get-tinymce-cloud-up-in-less-than-5-minutes/
Note, that if you are still within your 30-day trial, you have access to Tiny's Support channel, whom can assist you with these and other matters relating to installing, configuring and utilizing Tiny Cloud in your projects.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.