Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Keep structure of Blocks in sync when translating a StreamField in Wagtail
To implement translatable fields with Wagtail I followed the instructions from the official docs doubling the text fields for each language and then using django's TranslatedField for access in templates. For the editing interface, we customize the tabs (as explained in the docs) having a separate tab for each language with the corresponding fields. This is a nice solution because of the natural synchronization of the page hierarchy in each language (no need to keep parallel page trees in sync for each language). The problem I have is when I want to keep the sequence of blocks within a StreamField in sync while the user (editor) is modifying the sequence within a tab of a given language. In other words, if I have a tab "Content [en]" and another "Content [es]" each having a StreamField called "body", how can I keep the sequence of blocks in body within "Content [es]" in sync while the user (editor) appends blocks to body in "Content [en]"? Having this, if the editor appends blocks and puts content in the english tab and then changes to the spanish tab, he only needs to change the contents to spanish ones, because the sequence of blocks is … -
Foreign key not rendering in template
I'm building a commenting system, which is working fine but i'm now trying to integrate voting. So I made another model to handle that and I tried to pair it using ForeignKey. Not too familiar with ForeignKey but i've looked at some other answers here to see how to render it in the template. I tried that using the nested for loop in my template below but {{ j.user }} doesn't render anything. Can anyone tell me what I'm doing wrong? models.py class Comment(models.Model): destination = models.CharField(default='1', max_length=12, blank=True) author = models.CharField(max_length=120, blank=True) comment_id = models.IntegerField(default=1) parent_id = models.IntegerField(default=0) comment_text = models.TextField(max_length=350, blank=True) timestamp = models.DateTimeField(default=timezone.now, blank=True) def __str__(self): return self.comment_text class CommentScore(models.Model): user = models.ForeignKey(User) comment = models.ForeignKey(Comment) upvotes = models.IntegerField(default=0) downvotes = models.IntegerField(default=0) views.py ... comment_list = Comment.objects.filter(destination=id) score = CommentScore.objects.all() context = { 'score': score, 'comment_list': comment_list, } return render(request, 'article.html', context) template {% for i in comment_list %} <div class='comment_div'> <h3>{{ i.author }}</h3> {% for j in comment_list.score_set.all %} {{ j.user }} #nothing comes up {% endfor %} <p>{{ i.comment_text }}</p> </div> {% endfor %} -
login form keeps telling my username already exists django
So I am trying to make a login form for a django website using a forms.py file to generate a form in my html. I have already made a registration form using the same methods and that works fine but for some reason my login form keeps working like a registration form and saying that my username already exists. i assume it is just a litle mistake but I can't figure out what it is exactly. forms.py from django.contrib.auth.models import User from django import forms class LoginForm(forms.ModelForm): password = forms.CharField(widget=forms.PasswordInput) class Meta: model = User fields = ['username', 'password'] models.py class LoginFormView(View): form_class = LoginForm template_name = 'intranet/login_form.html' def get(self, request): form = self.form_class(None) return render(request,self.template_name,{'form': form}) def post(self,request): form = self.form_class(request.POST) if form.is_valid(): username = request.POST.get['username'] password = request.POST.get['password'] user = authenticate(username=username,password=password) if user is not None: if user.is_active: login(request,user) return redirect('werknemers_list') return render(request, self.template_name, {'form': form}) login_form.html <h1>Log in</h1> <form method="post"> {% csrf_token %} {{ form.as_p }} <input type="submit" value="log in" /> </form> -
Error loading templatetags from a Django application
I'm trying to load the templatetags included with the django-tagging application (django-tagging templatetags docs don't specify what the load statement should be) but I'm getting a TemplateSyntax error reminding me to load or register the tag - which I'm pretty sure I've done. Here's the relevant section of my template 1 {% extends "base_tags.html" %} 2 3 {% load staticfiles %} 4 {% load coltrane_tags %} 5 {% load tagging_tags %) 6 7 <div class="row"> 8 9 {% block content %} 10 <div class="col-md-9"> 11 {% tags_for_model coltrane.Entry as entry_tags %} 12 {% for obj in entry_tags %} 13 {{ obj }} 14 {% endfor %} The error message is: Invalid block tag on line 11: 'tags_for_model', expected 'endblock'. Did you forget to register or load this tag? Looking at the django-tagging module I can see the templatetags code: <PythonVirtualEnv>/site-packages/tagging/templatetags/tagging_tags.py The tag I'd like to use is registered in this file: register.tag('tags_for_model', do_tags_for_model) So from my perspective it's both registered and loaded - is there anything obvious that I'm missing? -
Is it possible to use django as a proxy for websoxket
I have a service (written in erlang) that accepts websocket connection from my django application. Django serves the page and the js script that makes the calls to the erlang service. Now I want to go through the django server also for websocket connection and messaging. That is to use django as a proxy that forwards websocket connection and messages from the client to the Erlang service and sends back responses from the erlang service to the client. Optionally django should also check request authorization before forwarding them. Is that possible? -
Django - cannot retrieve just one record in multi-part filter on model with multiple relations
I can't seem to isolate a single record from this query: subcust = OwnerCustom.objects.get(carcustom=ncset, owner=sset) This is the error: OwnerCustom matching query does not exist Here's the relevant models: class Car(models.Model): car_name = models.CharField(max_length=50) class CarCustom(models.Model): car = models.ForeignKey(Car, models.PROTECT) class Owner(models.Model): car = models.ForeignKey(Car, models.PROTECT) class OwnerCustom(models.Model): owner = models.ForeignKey(Owner, models.PROTECT) carcustom = models.ForeignKey(CarCustom, models.PROTECT) And the code: car_queryset = Car.objects.filter(car_name="fancy car") for nset in car_queryset: owner_queryset = Owner.objects.filter(car=nset) for sset in owner_queryset : carcustom_queryset = CarCustom.objects.filter(car=nset) for ncset in carcustom_queryset: subcust = OwnerCustom.objects.get(carcustom=ncset, owner=sset) -
py3.6 win10 - error installing virtualenv
Just installed Py3.6, made sur pip is installed and tried to install virtualenv with: pip install virtualenv And this is the result: pip install virtualenv Collecting virtualenv Using cached virtualenv-15.1.0-py2.py3-none-any.whl Installing collected packages: virtualenv Exception: Traceback (most recent call last): File "c:\program files\python36-32\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "c:\program files\python36-32\lib\site-packages\pip\commands\install.py", line 342, in run prefix=options.prefix_path, File "c:\program files\python36-32\lib\site-packages\pip\req\req_set.py", line 784, in install **kwargs File "c:\program files\python36-32\lib\site-packages\pip\req\req_install.py", line 851, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "c:\program files\python36-32\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files isolated=self.isolated, File "c:\program files\python36-32\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files clobber(source, lib_dir, True) File "c:\program files\python36-32\lib\site-packages\pip\wheel.py", line 323, in clobber shutil.copyfile(srcfile, destfile) File "c:\program files\python36-32\lib\shutil.py", line 115, in copyfile with open(dst, 'wb') as fdst: PermissionError: [Errno 13] Permission denied: 'c:\\program files\\python36-32\\Lib\\site-packages\\virtualenv.py' Same thing happened when I tried: pip install virtualenvwrapper-win Any ideas? -
Use uuid as foreign Key in a model in Django with Django Rest Framework
I don't know if the title of the post is right. I'll explain what I want to do and you could tell me what's the best way. I want to have an "id" (Int) as Primary Key and a "uuid" (uuid) as field in my User model. So, I want to link the tables with the "id", because it's faster, but I want that the front end just see the "uuid" and never the "id", because is a bit safer. My problem is that I've a "message" model. It looks so: class Message(models.Model): created = models.DateTimeField(auto_now_add=True) type = models.CharField(_('type'), choices=MESSAGE_TYPE, default='Invitation', max_length=100) content = models.TextField(_('content'), blank=False) sender = models.ForeignKey(User, related_name='sender_message', verbose_name=_("Sender"), ) recipient = models.ForeignKey(User, related_name='receiver_message', null=True, blank=True, verbose_name=_("Recipient")) url_profile_image = models.URLField(_('url_profile_image'), max_length=500, blank=True, default='') class Meta: ordering = ('created',) And as you can see, "sender" and "recipient" are linked to my User with a ForeignKey. But that ForeignKey returns as the user Id. { "url": "http://127.0.0.1:8000/users/messages/4/", "id": 4, "type": "invitation_accepted", "content": "Sure", "sender": 4, "recipient": 1, "url_profile_image": "" } 4 is the id of the "sender" and 1 is the id of the "recipient". But I would like that the front end just see the "uuid" of the sender … -
Django pickle object saved for calculations on request
I am making a small demo django application where there are some calculations for which I need to retrieve a complex object. I have saved the object to a file using Pickle. Now I want to keep the object in memory so that it is not retrieved for every request. Where can I load the object so that it remains there and is available for any request. There are some parameters passed with requests that are needed for calculation. The object is not related to Models. -
Django 1.10 Template Tags + importing Models gives App's Not Loaded Yet Error
When Using app_tags.py, I'm getting errors about my App Registry not being loaded yet. If I use import django, django.setup() -- there seems to be an infinite loop and my gateway just times out. Ultimately I'm wanting to be able to pass variables to my django admin that lists django-models at this url: http://domain.com/admin/app/ Anyone know how I can get the tags working, or how to properly import my models into the custom app_tags? from django import template from web.models import Payments register = template.Library() @register.assignment_tag def getDailyPayments(arg): paymentsCount = Payments.objecs.filter(paymentDate__gte='').count() return paymentsCount -
Unable to make a field unique
I am trying to make a field-team-name unique such that no two different users can make a team name of identical name but on entering the data ,the identical team names are also getting accepted team_name = models.CharField(max_length=100,unique=True) On entering python manage.py migrate --settings=settings.dev the error is Operations to perform: Apply all migrations: account, accounts, admin, auth, authtoken, challenges, contenttypes, hosts, jobs, participants, rest_framework_expiring_authtoken, sessions, sites Running migrations: Applying hosts.0002_auto_20170118_1748...Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute output = self.handle(*args, **options) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle fake_initial=fake_initial, File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration state = migration.apply(state, schema_editor) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 204, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 495, in alter_field old_db_params, new_db_params, strict) File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/db/backends/postgresql/schema.py", line 117, in _alter_field new_db_params, strict, File "/home/rishav/EvalAI/venv/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 678, in _alter_field self.execute(self._create_unique_sql(model, [new_field.column])) File … -
django, object is not saved to database
Here is my models.py from django.db import models from django.contrib.auth.models import User class Post(models.Model): title = models.CharField(max_length=64) content = models.TextField() created_at = models.DateTimeField(auto_now_add=True, editable=False) author = models.ForeignKey(User) class Meta: app_label = "app" Here is forms.py, which contains the form for object creation from django import forms from django.utils.translation import ugettext, ugettext_lazy as _ from app.models import Post class NewPostForm(forms.Form): title = forms.CharField( label=_("Title"), widget=forms.TextInput(attrs={'size': 64}), required=True ) content = forms.CharField( label=_("Content"), widget=forms.Textarea(attrs={'cols': 66}), required=True ) def __init__(self, request, *args, **kwargs): super(NewPostForm, self).__init__(*args, **kwargs) self.request = request def save(self): data = self.cleaned_data post = Post(title=data["title"], content=data["content"]) post.save() Here is views.py from django.contrib.auth.decorators import login_required from django.shortcuts import render, redirect, HttpResponse from django.contrib.auth import logout as auth_logout from django.views.generic import View from app.forms import NewPostForm from app.models import Post def index(request): posts = Post.objects.all() return render(request, 'index.html', {'posts': posts}) @login_required def profile(request): if request.method == "POST": form = NewPostForm(request) if form.is_valid(): form.save() else: form = NewPostForm(request) return render(request, 'profile.html', {'form': form}) def logout(request): auth_logout(request) return redirect('/') I have two pages, on /profile user can create a post. This post was supposed to be saved in database, then this post would appear on /. When I create a new post via form and … -
Django REST - cannot create model with relationships
I created a code for my related models: class Player(models.Model): # Basic first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) # Enums GOALKEEPER = 'GOALKEEPER' DEFENDER = 'DEFENDER' MIDFIELDER = 'MIDFIELDER' FORWARD = 'FORWARD' POSITION = ( (GOALKEEPER, 'Goalkeeper'), (DEFENDER, 'Defender'), (MIDFIELDER, 'Midfielder'), (FORWARD, 'Forward') ) position = models.CharField(max_length=50, choices=POSITION, default=GOALKEEPER) class PlayerDetail(models.Model): # Basic height = models.FloatField(default=0.0) weight = models.IntegerField(default=0) # Relationships player = models.ForeignKey(Player, related_name='player_detail') Then, I have done a serializers for every model: class PlayerDetailSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = PlayerDetail fields = ('weight', 'height') class PlayerSerializer(serializers.HyperlinkedModelSerializer): player_detail = PlayerDetailSerializer(many=True) class Meta: model = Player fields = ('id', 'first_name', 'last_name', 'position', 'player_detail') My create method looks like this: def create(self, request): serializer = PlayerSerializer(data=request.data, many=True) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) return Response('Player cannot be created', status=status.HTTP_400_BAD_REQUEST) Well, I send a JSON request to this simple API. The object I send is: { "first_name": "Player1", "last_name": "Player1", "position": "DEFENDER", "player_detail": { "weight": 80, "height": 180 } } In result I only see 400 bad request and Player cannot be created. I don't know why it is wrong. I think my relationship is define good. What is a good way to create connected objects via JSON? -
Django ModelForm validate if input exists in model
I have a model Linea with only one field named numero, wich is a charset (the values of numero are supposed to be numbers) . I want to do a form where the user can search for a value of numero. If the number that the user inputs exists in the database the view will redirect to a template that shows information about that value of numero, but if the value that the user search is not in the database it will throw an error. I'm very new in Django, and I've searched the way to do it but I can't achieve it. forms.py from django import forms from .models import Linea class LineaForm(forms.ModelForm): class Meta: model = Linea fields = ('numero',) models.py from __future__ import unicode_literals from django.db import models class Linea(models.Model): numero = models.CharField(max_length=2) def __str__(self): return self.numero views.py from django.shortcuts import render, redirect, reverse from .forms import LineaForm from django.http import HttpResponseRedirect import googlemaps from datetime import datetime def lineas(request, template="bustopaplineas.html"): if request.method == "POST": form = LineaForm(request.POST) if form.is_valid(): numero = form.save(commit=False) linea_numero = str(numero) return redirect('lineas_detalles', linea_numero=linea_numero) else: form = LineaForm() return render(request, 'bustopapp/lineas.html', {'form': form}) Thanks in advance. -
Django Form - How to add button with onclick event
I am using Django Form wizard to create multi step forms, using default form wizard template. In one step I am using formset to show multiple forms. On this page, there are multiple fields such as title, release, date, screens etc. I want to show a button with onclick event when say title is not present. On click of this button, I want to open another tab with the specified Url. It is my understanding that there is no built-in buttonField in Django. I was looking at this I want a button on my website that will execute a python script post. Was wondering if there is any other way of doing this? If I have to go with the answer, I am not sure if I can use the default template for this form. Please suggest what is a sound way to create a button conditionally on the form and handle its on-click event to redirect to a page in a new tab. wizard_form.html {% extends "admin/base_site.html" %} {% load i18n %} {% block content %} {% if wizard.form.forms %} {% for form in wizard.form.forms %} {{ form.media }} {% endfor %} {% else %} {{ wizard.form.media }} {% … -
assign edit permission for specific page to specific user
I'm looking for a way in Wagtail 1.8 to give a specific user edit and preview permissions on a specific page once it's created, so I can create the first version of a document for them and then they can add content, tweak, and preview until they're happy with it. One way to do that would have been to assign ownership of the page to them, but that field is read-only. Error is django.core.exceptions.FieldError: 'owner' cannot be specified for ArticlePage model form as it is a non-editable field I can give the user edit and preview permissions for all documents by assigning them to an appropriate Group (e.g., the predefined Editor role) with the right permissions, but I'd rather avoid that if I can. -
Openshift horizontal scaling of Django REST App using SQLite DB
I run a Django REST application on Openshift using one small, non-scaling gear. As database i use SQLite. I wonder if hor. scaling is also possible with SQLite, or only with MongoDB, MySQL etc. which use their own cartridge and are put into their own gear when scaling? -
Enable favicon on Apache 2 with SSL
I have Django app and can serve favicon via it. But it is not recommended so I did it using Apache. After moving from HTTP to SSL in Apache configs I cannot access the favicon on the server anymore. The part of responsible config looks like: <VirtualHost *:443> DocumentRoot /home/ubuntu/project/project/ Alias /favicon.ico /home/ubuntu/project/static/favicon.ico Alias /static/ /home/ubuntu/project/static/ <Directory /home/ubuntu/project/static> Require all granted </Directory> </VirtualHost> Folder exists and favicon is located in it. When I am trying to access favicon.ico I get 403: Forbidden You don't have permission to access /favicon.ico on this server. How can I solve it? Updates: I have found here that Aliases are ignored with SSL, so probably I should serve favicon differently. -
Populate Django ManyToManyField Options Based on Other Field in Admin
I am having problems filtering options for a ManyToManyField on the Django Admin Add screen based on input to another field on the same form. I am new to Django and have been unable to use any of the generic fixes described elsewhere because they are all slightly different than my situation. Here is my situation: I have three models in my project: Class, Student, and AttendanceRecord. In the Django Admin, when adding an attendance record, I would like to change the options for the field Absent_Students based on the selection made for the field Associated_Class. So, for example, if Associated_Class "CS 450" is selected, the options for Absent_Students should change to only students whose class_list includes CS 450. Here are my models: from __future__ import unicode_literals from django.db import models from django.contrib.auth.models import User from django.utils.encoding import python_2_unicode_compatible import random, string # Create your models here. #This is the model for a student @python_2_unicode_compatible class Student(models.Model): pass Student_First_Name = models.CharField(max_length=200) Student_Last_Name = models.CharField(max_length=200) Student_ID_Number = models.CharField(max_length=200) Student_Class = models.ForeignKey('Class', null=True) def __str__(self): return self.Student_Last_Name + ',' + self.Student_First_Name # This is the model for a class @python_2_unicode_compatible class Class(models.Model): class Meta: verbose_name_plural = "Classes" Class_Name = models.CharField(max_length=200) Student_List = … -
Django client login redirect loop
New to django and attempting to solve current problems with company web portal. When logging into the site with a staff account the login works fine, but using a client account returns the ERR::TOO_MANY_REDIRECTS. def user_login(request): # Like before, obtain the context for the user's request. context = RequestContext(request) form = AuthenticationForm() # If the request is a HTTP POST, try to pull out the relevant information. if request.method == 'POST': # Gather the username and password provided by the user. # This information is obtained from the login form. username = request.POST['username'] password = request.POST['password'] # Use Django's machinery to attempt to see if the username/password # combination is valid - a User object is returned if it is. try: user = authenticate(username=username, password=password) except LockedOut: messages.error(request, 'You have been locked out because of too many login attempts. Please try again in 10 minutes.') # If we have a User object, the details are correct. # If None (Python's way of representing the absence of a value), no user # with matching credentials was found. else: if user: # Is the account active? It could have been disabled. if user.is_active: # If the account is valid and active, we … -
Call a Javascript function in django template?
I have made an function named foo(). It is inside my functions.js file. How can I use the foo() function in my django template? -
Upload a file in a python subprocess
I'm working on a Django project (Django 1.10, Python 3.4.3), where I am trying to upload a file in a python subprocess. I need to upload the file and calculate some sums on it as I upload it and we want the system to still be usable while it is doing that, so we thought putting those tasks in a subprocess would work. Right now, I'm working on just getting the file uploaded. FIRST ATTEMPT: app/views/UploadView.py class NewUploadView(TemplateView): template_name = "../templates/simulation/upload.html" @transaction.atomic def post(self, request): if request.method == 'POST': if not request.FILES['input_file']: return HttpResponseBadRequest("No 'input_file' is provided") else: sim_name = self.request.POST.get(u"name", None) p = Popen(["/.virtualenvs/env/bin/python3.4", "manage.py", "load_simulation", str(request.FILES['input_file'], str(sim_name)]) p.communicate() # Redirect to appropriate page HttpResponseRedirect(reverse('home.display_simulations'))` app/management/commands/load_simulation.py import csv import os from django.conf import settings from django.core.management.base import BaseCommand from website.apps.home.models import Simulation, Location, Data, SimulationModel class Command(BaseCommand): help = 'Upload csv data file and save objects in database' def add_arguments(self, parser): parser.add_argument("my_file", type=str) parser.add_argument("simulation_name", type=str) def handle(self, *args, **options): """ Upload data file :param args: :param options: :return: """ my_file = options["my_file"] simulation_name = options["simulation_name"] # Save the simulation object, with the data_file simulation = Simulation.objects.create(name=simulation_name, data_file=my_file) simulation.save() filename = os.path.join(settings.MEDIA_ROOT, "simulation_files", simulation.getfilename()) file_obj = open(filename, 'r') dictreader = … -
nested plugins django-cms more that 2 lvl
I have problem. I have code like this: from cms.models.pluginmodel import CMSPlugin from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool class WidgetPluginBase(CMSPluginBase): module = 'Widgets' cache = False def render(self, context, instance, placeholder): context[self.code] = instance return context class PluginParent(WidgetPluginBase): model = CMSPlugin name = 'Section' code = 'pluginparent' allow_children = True child_classes = ['PluginChild'] render_template = 'widgets/placeholders/parent.html' plugin_pool.register_plugin(PluginParent) class PluginChild(WidgetPluginBase): model = CMSPlugin name = 'PluginChild' code = 'pluginchild' allow_children = True child_classes = ['PluginChildChild'] require_parent = True parent_classes = ['PluginParent'] render_template = 'widgets/placeholders/child.html' plugin_pool.register_plugin(PluginChild) class PluginChildChild(WidgetPluginBase): model = CMSPlugin name = 'PluginChildChild' code = 'pluginchildchild' allow_children = False require_parent = True parent_classes = ['PluginChild'] render_template = 'widgets/placeholders/pluginchildchild.html' plugin_pool.register_plugin(PluginChildChild) But when I add PluginChild on PluginParent I cannot add PluginChildChild to PluginChild. Also i cannot click settings and edit buttons on PluginChild. Does anyone know why I can not do anything with a plugin PluginChild? -
Django TinyMCE editor is disabled in firefox
I did everything the documentation says, including the followings: The editor loads up, displays well. But in FireFox, the text input is disabled. You can't click it. Nothing could be typed. settings.py INSTALLED_APPS = ( ... 'tinymce', ... ) In project's url.py: url(r'^tinymce/', include('tinymce.urls')), Settings.py TINYMCE_DEFAULT_CONFIG = { 'mode' : "textareas", 'theme': 'advanced', 'relative_urls': False, 'theme_advanced_buttons1': 'bold,italic,underline,bullist,numlist,|,link,unlink,image','quote' 'theme_advanced_resizing': True, 'theme_advanced_path': False, } TINYMCE_SPELLCHECKER = True TINYMCE_COMPRESSOR = True in models.py: class Post(models.Model): ... content = models.TextField() ... forms.py: from django import forms from django.contrib.auth.models import User from homepage.models import Post from tinymce.widgets import TinyMCE class PostForm(forms.ModelForm): --- content = forms.CharField(widget=TinyMCE(attrs={'cols': 50, 'rows': 30})) --- and also added {{ form.media }} -
How can I use `django-rest-knox` with `django-rest-auth`?
I'd like to use django-rest-auth to easily make use of the registration and social auth features of django-allauth in my API. I'd also like to use django-rest-knox, as it provides a token per device, rather than per user. When creating a user via django-rest-auth, it tries to create and return a token. This fails, as it needs to use django-rest-knox to generate the token, but I'm unclear on how to do this. Is it possible to get these two packages working together? Thanks!