Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
my qustion is about django gives an error while running the server
raise ImproperlyConfigured("The %s setting must be a list or a tuple. " % setting) django.core.exceptions.ImproperlyConfigured: The INSTALLED_APPS setting must be a list or a tuple. -
Dynamic Links and Data Updation in Django 1.11
I have tried a lot but was unable to find the desired solution. My Problem I have a list generated using a for loop in the HTML template. The code for this purpose is in my "dashboardhometemplate.html" file and is as : {%for item in device_alias_list%} <li> <a href=href="#" aria-expanded="false"><i class="fa fa-bar-chart"></i><span class="hide-menu">{{item}}</span></a> {% endfor %} My Database consist of two tables as : from django.db import models class device_parameter_data(models.Model): # id = models.AutoField(primary_key = True) Device_Id = models.CharField(max_length=10) Age = models.IntegerField(null = True) updated_time = models.DateTimeField(auto_now=True, null = False) def __str__(self): return self.Device_Id class device_user_data(models.Model): User_Name = models.CharField(max_length=150) Device_Id_Data = models.CharField(max_length=10, primary_key = True) Device_Alias_Data = models.CharField(max_length=20) def __str__(self): return self.User_Name + '(' + self.Device_Id + ')' My views.py is: from django.shortcuts import render,redirect from django.views import View from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth import login from dashboardhome.models import device_parameter_data from dashboardhome.models import device_user_data class DashboardHomeViewClass(View): def get(self, request, *args, **kwargs): device_user_objects = device_user_data.objects.filter(User_Name = request.user.username) device_alias_list = [] device_id_list = [] for device in device_user_objects: device_alias_list.append(device.Device_Alias_Data) device_id_list.append(device.Device_Id_Data) context_logged = {'device_alias_list': device_alias_list} return render(request, "dashboardhometemplate.html", context_logged) Now what I want to do is: As soon as the user clicks on the list item then I want to pass the … -
Binary image storage in Django models
I want to load an image using ImageField, convert it to binary or base64 and save in the database just the code. I want to save the binary / base64 in the database, not the image. I want to use "bytea" (PostgreSQL) I do not want to save the image or the directory in the bank. My teacher wants to use Binary Data Typing in this project. I need help, please. class Trap_Image(models.Model): date = models.DateField('publication date') trap = models.ForeignKey(Trap, on_delete=models.CASCADE) image = models.ImageField() # missing binary or base64 part def __str__(self): return self.id class Meta: verbose_name = 'Image' verbose_name_plural = 'Images' -
How to create more than one formset in one CreateView?
I have two models: class Recipe(Model): title = CharField(blank=True, max_length=255) slug = SlugField() user = ForeignKey(get_user_model(), on_delete=CASCADE) categories = TaggableManager() class Meta: ordering = ['id'] def save(self, *args, **kwargs): self.slug = slugify(self.title, allow_unicode=True) return super(Recipe, self).save(*args, **kwargs) def get_absolute_url(self): return reverse("recipes:detail", kwargs={"pk": self.pk}) class RecipeStep(Model): recipe = ForeignKey(Recipe, on_delete=CASCADE, related_name="steps") ingredients = ManyToManyField(Ingredient) title = CharField(blank=True, max_length=255) slug = SlugField() def save(self, *args, **kwargs): self.slug = slugify(self.title, allow_unicode=True) return super(RecipeStep, self).save(*args, **kwargs) And I needed to make it so that when creating a Recipe model it was possible to create a RecipeStep model: For this I did 2 ModelForm and inlineformset: class RecipeForm(forms.ModelForm): class Meta: model = Recipe fields = ['title'] class RecipeStepForm(forms.ModelForm): class Meta: model = RecipeStep fields = ['title'] RecipeInlineForm = inlineformset_factory( Recipe, RecipeStep, form=RecipeStepForm, extra=1, can_delete=False, can_order=False ) I create a new Recipe with CreateView: class RecipeCreateView(LoginRequiredMixin, CreateView): model = Recipe form_class = RecipeForm def form_valid(self, form): form.instance.user = self.request.user context = self.get_context_data() inlines = context['inlines'] if inlines.is_valid() and form.is_valid(): self.object = form.save() for inline in inlines: inline.instance.recipe = self.object inline.save() return super(RecipeCreateView, self).form_valid(form) else: return self.render_to_response(self.get_context_data(form=form)) def form_invalid(self, form): return self.render_to_response(self.get_context_data(form=form)) def get_context_data(self, **kwargs): context = super(RecipeCreateView, self).get_context_data(**kwargs) if self.request.POST: context['form'] = RecipeForm(self.request.POST) context['inlines'] = RecipeInlineForm(self.request.POST) … -
Trouble deploying Django app with gunicorn and nginx
I started this process trying to deploy with uwsgi, but ran into problems and so after reading from some sources that gunicorn would be the better way to go, I tried with that. Hopefully that didn't complicate things. I have all the preliminaries out of the way. I have Django app built, virtualenv installed, gunicorn installed, nginx installed. When I run command - gunicorn Hellfish.wsgi (Hellfish is project name) there is no response at first from the terminal (I guess that is normal processing speed?), but eventually I get this output: --- Logging error --- Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 996, in emit self.flush() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 976, in flush self.stream.flush() RuntimeError: reentrant call inside <_io.BufferedWriter name='/Users/whodini/desktop/who/web/Hellfish/logs/gunicorn-error.log'> Call stack: File "/Users/whodini/Desktop/who/Web/Hellfish/env/bin/gunicorn", line 11, in <module> sys.exit(run()) File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 61, in run WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/app/base.py", line 223, in run super(Application, self).run() File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run Arbiter(self).run() File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/arbiter.py", line 203, in run self.manage_workers() File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/arbiter.py", line 545, in manage_workers self.spawn_workers() File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/arbiter.py", line 616, in spawn_workers self.spawn_worker() File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process() File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/workers/base.py", line 134, in init_process self.run() File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 124, in run self.run_for_one(timeout) File "/Users/whodini/Desktop/who/Web/Hellfish/env/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 83, in … -
How to remove image url in DJANGO admin ImageField
[https://i.stack.imgur.com/SVoxO.png][1] [https://i.stack.imgur.com/fRvaP.png][2] I am new to programming and Django i am using generic views and I want to remove this current path tag from Django admin how to do it? -
Django CreateView filter foreign key in select field
I need some help with Django 2 and Python 3. I'm using a CreateView to add new reccords in my database, but I need to make a filter in "Aviso" form page to make the select field (field "turma") to show only "turmas" that the "representante" is the current user. This is my model: class Turma(models.Model): nome = models.CharField(max_length=120, blank=False, null=False, help_text='Obrigatório.') alunos = models.ManyToManyField(User, help_text='Obrigatório', related_name='alunos_matriculados') data_cadastro = models.DateField(auto_now_add=True) representante = models.ForeignKey(User, on_delete=models.PROTECT, blank=False, null=False) colegio = models.ForeignKey(Colegio, on_delete=models.PROTECT, blank=False, null=False, help_text='Obrigatório.') class Aviso(models.Model): data_final = models.DateField(auto_now=False, auto_now_add=False, blank=False, null=False, verbose_name="Data Final") comentarios = models.TextField(null=True, blank=True) ultima_modificacao = models.DateField(auto_now=True) data_post = models.DateField(auto_now_add=True) turma = models.ForeignKey(Turma, on_delete=models.PROTECT, null=False, blank=False) materia = models.ForeignKey(Materia, on_delete=models.PROTECT, null=False, blank=False) This is my view: class AvisoCreateView(LoginRequiredMixin, CreateView): #Cadastro de Aviso template_name = 'form.html' model = models.Aviso login_url = '/login/' success_url = reverse_lazy('visualizar_aviso') fields = [ 'turma', 'materia', 'tipo_aviso', 'comentarios', 'data_final' ] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['titulo'] = 'Cadastrar aviso' context['input'] = 'Adicionar' return context Thank you. -
Passing Parameter To Django Admin Index Page
I am new in django and i am try to pass parameter to admin/index.HTML page but i don't know how to pass parameter to build in page . -
Can django channels scale to handle big traffic?
I want to use django channels on an existing project to support websockets, but i'm having doubts about scalability i know daphne server can only handle so much opened connections 1-how many simultaneous connection can one daphne insurance handle? 2-can it scale using a load balancer to be able to handle big traffic (let's say 100k simultaneous websocket connections)? -
installed django-cors-headers still cross origin images error occuring
cors-header using pip on Django 2.0.6 . Still same origin error is occuring. I installed a chrome extension Allow-Controll-Allow-Origin:* when I enable all things are fine. My setting files are MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_METHODS = ( 'DELETE', 'GET', 'OPTIONS', 'PATCH', 'POST', 'PUT', ) CORS_ALLOW_HEADERS = ( 'accept', 'accept-encoding', 'authorization', 'content-type', 'dnt', 'origin', 'user-agent', 'x-csrftoken', 'x-requested-with', ) still in browser I am getting Failed to load https://s3.amazonaws.com/django/Events/Test1/1.jpg: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8002' is therefore not allowed access. And this 19:367 Uncaught Error: InvalidStateError: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'arraybuffer'). at XMLHttpRequest.xhr.onreadystatechange (19:328) -
How to generate django session_data?
I can't find a place in source code where is generated a dict for session_data. I need to understand how to generate a user hash in this dict. -
ModuleNotFoundError: No module named 'snowpenguin'
(venv) E:\Studia Materialy\Semestr 4\IO\l02-nr-6-cyber-mechanik-l02team- master>python manage.py makemigrations L02 Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "C:\Users\keray\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\keray\venv\lib\site-packages\django\core\management\__init__.py", line 357, in execute django.setup() File "C:\Users\keray\venv\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\keray\venv\lib\site-packages\django\apps\registry.py", line 89, in populate app_config = AppConfig.create(entry) File "C:\Users\keray\venv\lib\site-packages\django\apps\config.py", line 116, in create mod = import_module(mod_path) File "E:\Programowanie\Python\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'snowpenguin' Can't run "python manage.py runserver" because of this problem ,python 3.7, Django 2.0.7 . I have tried many version of python, and django, i have reinstall bootstrap. -
python3 turtle when i save my file
i m new to turtle library and i have a problem that confused a lot i can work with turtle in realtime but when i write a program and i save it i cant run it. i have written below code: from turtle import * turtle.Pen(9999999) penup() for i in range(16): write(i,align='center') forward(25) goto(0,-5) x=0 right(90) for i in range(16): pendown() forward(400) penup() x+=25 goto(x,-5) but it doesnt work at all it gave me this error: Traceback (most recent call last): File "C:\Users\Nobody\Desktop\main.py", line 1, in <module> import turtle File "C:\Users\Nobody\Desktop\turtle.py", line 3, in <module> turtle.speed(9999999) AttributeError: module 'turtle' has no attribute 'speed i think it doesnt import turtle at all pls help me -
Django administration add user returns Server Error (500)
I have deployed my django application to a CentOS server and everything is working fine. I can see the list of users and groups from the Django Administration page. I was able to add/edit users as well before. But now, when I'm trying to add new user, an Server Error (500) is returned. Is there any limitations about the number of users can be added using Django Admin page? -
How to assemble different serializers to a Json response in Django RFW?
This is my serializers.py, class MalbSerializer(serializers.ModelSerializer): class Meta: model = malb fields = ('zoning', 'zoningdesc', ) class MasrSerializer(serializers.ModelSerializer): class Meta: model = masr fields = ('solddate', 'soldprice', ) class MataSerializer(serializers.ModelSerializer): class Meta: model = mata fields = ('assessyear', 'landvalue', ) class TotalSerializer(serializers.ModelSerializer): LandBuilding = serializers.SerializerMethodField() SalesRecord = serializers.SerializerMethodField() TaxAssessment = serializers.SerializerMethodField() def get_LandBuilding(self, number): queryset_lb = malb.objects.filter(maid=number) serializer = MalbSerializer(queryset_lb, many=True) return serializer.data def get_SalesRecord(self, number): queryset_sr = masr.objects.filter(maid=number) serializer = MasrSerializer(queryset_sr, many=True) return serializer.data def get_TaxAssessment(self, number): queryset_ta = mata.objects.filter(maid=number) serializer = MataSerializer(queryset_ta, many=True) return serializer.data class Meta: fields = ('LandBuilding', 'SalesRecord', 'TaxAssessment', ) I want to assemble these three serializers to one serializer in TotalSerializer, But it has an error: Class MaidExtraSerializer missing "Meta.model" attribute I don't know add which models to here, because I have already add models in MalbSerializer, MasrSerializer, MataSerializer. So How can I do to show MalbSerializer, MasrSerializer, MataSerializer together in TotalSerializer? -
Django: how to create an instance of the model based on the data from the json file?
In the project there is a model with existing instances in the database. class Instagram(models.Model): userid = models.CharField(max_length=255, unique=True) username = models.CharField(max_length=50, blank=True, null=True) full_name = models.CharField(max_length=50, blank=True, null=True) avatar = models.URLField(max_length=255, blank=True, null=True) bio = models.CharField(max_length=255, blank=True, null=True) ..... ..... There is another model, so far without instaces class InstagramDemographicsAnalitics(models.Model): instagram = models.ForeignKey(Instagram, related_name='demographics') age_group = models.CharField(max_length=10) gender = models.CharField(max_length=10, default='female') viewer_percentage = models.DecimalField(default=0, max_digits=5, decimal_places=2) It is necessary from the file statistic.json, which is in the same folder with the project, to take the data for the corresponding userid and on their basis create the instances of the model InstagramDemographicsAnalitics. I have no idea how to do this. I really need advice with a sequence of actions and if possible code example. -
Total blogs by a user
Can someone suggest me the correct way to get the total count of blogs by a user. I am trying this method but its not working. Also, how to fetch it from my quertyset in view ? Thanks models.py class Blog(models.Model): author = models.ForeignKey(User, on_delete = models.CASCADE, related_name='blogs') created_date = models.DateTimeField(default=timezone.now) def num_blog(user): num_blog = Blog.objects.filter(author=user).count() return num_blog -
Heroku deployed django site giving application error
I am trying to deploy a Django application on Heroku. The deployment and push the changes is successful. But when opened it is giving application error, check your logs for details. This is the log details on my terminal. This is log details on Heroku. 2018-07-04T17:21:45.827547+00:00 heroku[web.1]: State changed from crashed to starting 2018-07-04T17:21:51.960062+00:00 heroku[web.1]: Starting process with command `gunicorn zoomtail.wsgi --log-file -` 2018-07-04T17:21:53.000000+00:00 app[api]: Build succeeded 2018-07-04T17:21:53.804826+00:00 heroku[web.1]: Process exited with status 127 2018-07-04T17:21:53.758720+00:00 app[web.1]: bash: gunicorn: command not found 2018-07-04T17:21:53.822387+00:00 heroku[web.1]: State changed from starting to crashed 2018-07-04T17:22:39.313982+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=peaceful-olympic-84671.herokuapp.com request_id=2f38b8b0-9220-4f00-baa9-df9d2f1c54f7 fwd="106.206.63.203" dyno= connect= service= status=503 bytes= protocol=https 2018-07-04T17:22:40.055033+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=peaceful-olympic-84671.herokuapp.com request_id=3e5fb340-96f6-44c7-ad0a-3be4815fa5dc fwd="106.206.63.203" dyno= connect= service= status=503 bytes= protocol=https I'm guessing the problem is with gunicorn since it says bash: gunicorn command not found. But I have installed it, added it in Procfile and requirements.txt, tried out the methods in similar stackoverflow questions but to no avail. Please help. -
YoutubePlugin of ckeditor with Django
Acutually I'm working on a Django website and I used CKEditor to input the rich text which worked well. But when I tried to add the youtube plugin into the default setting of ckeditor, there is always an 404 error said can't find the js file. Don't know it's the setting fault or what. I followed https://github.com/django-ckeditor/django-ckeditor#installation to install ckeditor. And downloaded YoutubePlugin from https://ckeditor.com/cke4/addon/youtube. I unzip the youtube folder into /myproject/staticfiles/ckeditor/ckeditor/plugins. Here is my settings. STATIC_URL = '/static/' STATIC_ROOT = 'staticfiles/' CKEDITOR_CONFIGS = { 'default': { 'skin': 'moonocolor', 'toolbar_Basic': [ ['Source', '-', 'Bold', 'Italic'] ], 'toolbar_YourCustomToolbarConfig': [ {'name': 'document', 'items': ['Source']}, {'name': 'clipboard', 'items': ['Undo', 'Redo']}, {'name': 'editing', 'items': ['Find', 'Replace']}, {'name': 'basicstyles', 'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']}, {'name': 'paragraph', 'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']}, '/', {'name': 'insert', 'items': ['Image', 'Flash', 'Youtube', 'Table', 'HorizontalRule']}, {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']}, {'name': 'colors', 'items': ['TextColor', 'BGColor']}, ], 'tabSpaces': 4, 'height': 300, 'width': '100%', 'extraPlugins': 'youtube', }, } And the models.py class Post(models.Model): STATUS_CHOICES = ( ('draft', 'Draft'), ('published', 'Published'), ) title = models.CharField(max_length=250) slug = models.SlugField(max_length=250, unique_for_date='publish') author = models.ForeignKey(User, related_name='blog_posts', on_delete=models.CASCADE) body = RichTextUploadingField(blank=True, null=True,) publish … -
Django model design - ManyToManyField or ForeignKey: opted option
To deal with the 2 options (ManyToManyField or ForeignKey) in a project, to be honest, I use the first that comes to my mind. Let's say we have the following models where a Project can have multiple Assignments. 1st option: class Project(models.Model): title = # class Assignment(models.Model): project = models.ForeignKey(Project,on_delete=models.CASCADE, related_name='assignments') With ForeignKey, when deleting a project, all the assignments related will be also deleted (That's perfect) 2nd option: class Project(models.Model): assignments = models.ManyToManyField("Assignment") class Assignment(models.Model): # fields With ManyToManyField, when deleting a project, if I need to delete all the assignments related, I have to use signal From the point of view of performance and clarity, what is the option opted for? -
Store fixed data in Django: dictionary or sqlite?
I'm working in a project that retrieves some data from a rest service. One of the retrieved fields is a department number that need to be searched in a set of data in order to get the department name. That set of data has been given to me in a csv file (at least is not excel) with 1200 records. The dataset is fixed and will not be updated (let's assume that's true) and the project doesn't have a database. So I'm looking for the best alternative for storing this set: could be a hard coded dictionary or sqlite, what do you think? is there a better alternative? -
django: getting objects with ids from querryset
I have these models (names are changed): class Blog(models.Model): created_dtm = models.DateTimeField() updated_dtm = models.DateTimeField() title = models.CharField(max_length=200, null=True, blank=True) creator = models.ForeignKey(Authors, on_delete=models.CASCADE, null=True, blank=True) class BlogAuthor(models.Model): blog = models.ForeignKey(Blog, on_delete=models.CASCADE) author = models.ForeignKey(Author, on_delete=models.CASCADE) class Meta: unique_together = ('blog', 'author') and I need to get all Blogs(and its details) in which author is involved. The problem is that each Blog can have more than one author. Now I can get QuerrySet of Blog's ids using this: BlogAuthor.objects.filter(author=request.user).values_list('blog_id', flat=True) and then try getting every single Blog one by one using cycle for, but is it possible to get list of Blogs with one querry? -
Run bash script with Django
I'm really new in django. I need to run a bash script when I push a button in html, and I need to do it with Django Framework, because I used it to build my web. I'd be grateful if anybody could help me -
Is it good to use JSON Field to store user defined fields?
I am developing a document management system using django and mysql. Each document consists of user defined fields. My Implementation: ParentDocument: id = 1 title="My First Document", description="Just testing", custom_keys_constraints= {"name": {"data_type":"string","min_length":5, "max_length":12}, "age" : {"data_type":"integer", "min": 18, max: 56},} ChildDocument: parent = F("ParentDocument")(1) custom_fields_data= {"name": "Spirit", "age" : 23,} See that the custom_fields_data of ChildDocument consists of data aligning with the constraints imposed by ts ParentDocument. Is this the right way to implement custom fields? Does this cause any performance issue during querying? I would also like to keep a change log of each and every document. How to implement this? -
Django iniline widget - Refresh inline widget every time the "Add another" button is clicked
I am using the jsoneditor (https://github.com/josdejong/jsoneditor) plugin as a widget for all JSON fields, but when the jsoneditor widget is added after clicking the "Add another [model]" button, the widgets render and other init functions, including the JS files, are not called/loaded properly, therefore the html loads, but the functionality doest work properly. What i want to know is how can i reload the entire jsoneditor/inline widget that is added after "Add another" button is clicked. I am succcesfully calling the following JS functions when an inline is added and removed: (function ($) { $(document).on('formset:added', function (event, $row, formsetName) { console.log('Formset added'); }); $(document).on('formset:removed', function (event, $row, formsetName) { console.log('Formset removed'); }); })(django.jQuery); But i want to know from within the javascript above itself, how do i reload the jsoneditor widget added. Here is the widget for reference: class JSONEditorWidget(django.forms.Widget): template_name = 'django_json_widget.html' class Media: css = {'all': (_STATIC_URL + 'dist/jsoneditor.min.css',)} js = (_STATIC_URL + 'dist/jsoneditor.min.js',) def render(self, name, value, attrs=None, renderer=None): context = { 'data': value, 'name': name } return django_safestring.mark_safe(django_loader.render_to_string( self.template_name, context) )