Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
The submit button is not functioning in html, even though i gave onclick element
$("#btn1").click(function(){ $(".btn1").show(); $(".btn1").attr("disabled",true); }); }); function getanswer() { document.getElementById(useranswer).innerHTML = ""; var e = document.getElementsByTagName('input'); for(i = 0; i<= e.length ; i++) { if(e[i].type == 'radio') { if(e[i].checked) { document.getElementById(useranswer).innerHTML += "Q" + e[i].name + "Answer you selected is :" + e[i].value+ "<br/>"; } } } } This is script code for the below html line <tr> <td><label id="correctanswer" class="ans" value="{{Result.correctanswer}}" style="display: none; color:green;"><br>{{Result.correctanswer}}<br></label></td> </tr> And the submit button is not working if i click on that. <input type="submit" value="submitanswer" id="btn1" onclick = " getanswer();" > Can anyone help me out with this, what is problem going on. Whenever the submitanswer is clicked it is not functioning. What i expected is : it should jump to getanswer function and display the following propertys. Please help me with this. And i am working with Django framework. I am using this function to validate the user answers. Thank you. -
Django makemigrations ignoring blank=False or null=False
from django.db import models # define a custom field class CustomCharField(models.CharField): def __init__(self, *args, **kwargs): print(kwargs) # test code defaults = {'null': True, 'blank': True} defaults.update(kwargs) super().__init__(*args, **defaults) # use custom field in a model class class FooModel(models.Model): bar_char = CustomCharField('bar char', null=False, blank=True) and run makemigrations # python3 manage.py makemigrations {'verbose_name': 'bar char', 'blank': True} # this is printed because of the 'test code'. I expected bar_char is non-nullable and blankable, but it is nullable and blankable in this case, null=False parameter is ignored. (if blank=False, it would be ignored.) In short, False set null or blank parameter is ignored. why is that happended? am I missing something? or is it Django's bug? -
How to proper test signals.py in Django?
I want to know that is my signal test was correct ? the test coverage with "django-nose" of signals.py still 0% This is my signals.py @receiver(post_save, sender=User) def create_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) @receiver(post_save, sender=User) def save_profile(sender, instance, **kwargs): instance.profile.save() This is my test.py class TestSignals(TestCase): def test_create_profile_signal_triggered(self): handler = MagicMock() signals.create_profile.send(handler, sender='test') form = UserCreationForm() form.cleaned_data={'username':'oatty111','email':'oatty@mail.com','password1':'test123', 'password2':'test123','first_name':'Michael','last_name':'Jordan'} form.save() signals.create_profile.send(sender='test',form_date=form) handler.assert_called_once_with(signal=signals.create_profile, form_data=form, sender='test') This is my forms.py class UserRegisterForm(UserCreationForm): email = forms.EmailField() class Meta: model = User fields = ['username','email','password1','password2','first_name','last_name'] -
how can I render the column of excel file to template?
I have a model that has two objects. The first object contains Excel files and the second contains the name of the Excel file. I created a template that shows the names of Excel files. When the user clicks on the file name, I want to show him objects name and below it a special column of contents inside the Excel file. my model is: class charts(models.Model): excel= models.FileField(null=True, blank=True) name = models.CharField(max_length=40) model manager: def get_by_id(self, ch_id): qs = self.get_queryset().filter(id=ch_id) if qs.count() == 1: return qs.first() else: return None views.py for show detail: def chart_detail(request, *args, **kwargs): ch_id= kwargs['ch_id'] chare = charts.objects.get_chart(ch_id) if MineralSpectrum is None: raise Http404 context = { 'a': chare, } return render(request, 'chart_detail.html', context) chart_detail.html: {% block content%} <p>{{ i.name }}</p> <p> 'here I want to show the x columns of excel inside database related to i.name' </p> {% endblock%} this is an example for explain my problem. -
How to use a variable as name in a Django Form?
In a table, each row contains an ID number and a dropdown. I want the user to choose a value in each row's dropdown, and then submit all that and display it on the next page. On the next page I call request.POST.get() so each dropdown needs to have a unique HTML name. Currently I have the following which works for displaying the info: class Dropdown(forms.Form): def __init__(self, mylistTuples): super(Dropdown,self).__init__() self.fields['dropdown'] = forms.CharField(label="", widget=forms.Select(choices=mylistTuples)) dropdown = forms.CharField() I think I want something like the following, but I don't quite understand how the self.fields['name'] relates to the variable name. class Dropdown(forms.Form): def __init__(self, mylistTuples, my_id): super(Dropdown,self).__init__() self.fields['dropdown_'+my_id] = forms.CharField(label="", widget=forms.Select(choices=mylistTuples)) dropdown?? = forms.CharField() I also tried the following without success: class Dropdown(forms.Form): def __init__(self, mylistTuples, my_id): super(Dropdown,self).__init__() self.fields['dropdown_'+my_id] = forms.CharField(label="", widget=forms.Select(choices=mylistTuples)) self.my_id = my_id globals()['dropdown_'+self.my_id] = forms.CharField() In the next page's view, request.POST.items() will allow me to loop through my results. -
Issue while rendering view with Django 3.1.3 using render function that works fine with Django 2.2
#Code of Django View: check Output here!! def studiolist_page(request,*args,**kwargs): studiomaster={'studio_master_key':StudioMaster.objects.all()} studiolist_all=StudioDetails.objects.filter(studio_status=10) city_query=request.GET.get("cty") studio_type_query=request.GET.get("s_type") genre_query=request.GET.get("gnre") baseprice_query=request.GET.get("price") studiolist={'studio_list_key':studiolist_all} print(6) x=len(studiolist.get('studio_list_key')) if x==0: y='Sorry!! No Studios Available Here !!' else: y=str(x)+' Fresh Studios Served !!' messages.success(request,y) return render(request,'studiomaster/studiocard_list.html',studiolist,studiomaster) I also have tried changing the template to find if its an issue with html, but the result is same, So I assume that it might be something to do with the View handling itself. To my surprise this works fine in Django 2.2 but loads html code on the browser when being rendered so the template is being called but the loading has some abnormal behaviour . Any help here is greatly appreciated. -
Exception occurred processing WSGI script [Django + Apache2]
I'm getting some errors deploying a Django app with Apache2. One error I see in my logs says Exception occurred processing WSGI script I'm not sure if my permissions are right or if maybe I am confused about the difference between sites-available and sites-enabled Here's the full error log: [Sat Nov 14 04:51:24.181106 2020] [wsgi:error] [pid 407301:tid 140682895165184] [remote XXX.XX.XX.XXX:52895] mod_wsgi (pid=407301): Failed to exec Python script file '/srv/example/example/wsgi.py'. [Sat Nov 14 04:51:24.181150 2020] [wsgi:error] [pid 407301:tid 140682895165184] [remote XXX.XX.XX.XXX:52895] mod_wsgi (pid=407301): Exception occurred processing WSGI script '/srv/example/example/wsgi.py'. [Sat Nov 14 04:51:24.181178 2020] [wsgi:error] [pid 407301:tid 140682895165184] [remote XXX.XX.XX.XXX:52895] Traceback (most recent call last): [Sat Nov 14 04:51:24.181205 2020] [wsgi:error] [pid 407301:tid 140682895165184] [remote XXX.XX.XX.XXX:52895] File "/srv/example/example/wsgi.py", line 12, in <module> [Sat Nov 14 04:51:24.181246 2020] [wsgi:error] [pid 407301:tid 140682895165184] [remote XXX.XX.XX.XXX:52895] from django.core.wsgi import get_wsgi_application [Sat Nov 14 04:51:24.181270 2020] [wsgi:error] [pid 407301:tid 140682895165184] [remote XXX.XX.XX.XXX:52895] ImportError: No module named django.core.wsgi /etc/apache2/sites-enabled/example.conf <VirtualHost *:80> ErrorLog ${APACHE_LOG_DIR}/example-error.log CustomLog ${APACHE_LOG_DIR}/example-access.log combined WSGIApplicationGroup %{GLOBAL} WSGIDaemonProcess example processes=2 threads=25 python-path=/srv/example WSGIProcessGroup example WSGIScriptAlias / /srv/example/example/wsgi.py Alias /robots.txt /srv/example/static/robots.txt Alias /favicon.ico /srv/example/static/favicon.ico Alias /static/ /srv/example/static/ Alias /media/ /srv/example/media/ <Directory /srv/example/example> <Files wsgi.py> Require all granted </Files> </Directory> <Directory /srv/example/static> Require all granted </Directory> <Directory … -
getting error while using model form in django
path('', include('farmingwave.urls')), File "F:\farm\lib\site-packages\django\urls\conf.py", line 34, in include urlconf_module = import_module(urlconf_module) File "C:\Users\Mohit\AppData\Local\Programs\Python\Python39\lib\importlib_init_.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 790, in exec_module File "", line 228, in call_with_frames_removed File "F:\farm\fwave\farmingwave\urls.py", line 3, in from . import views File "F:\farm\fwave\farmingwave\views.py", line 3, in from .forms import ContactForm File "F:\farm\fwave\farmingwave\forms.py", line 3, in from django.forms import contactForm ImportError: cannot import name 'contactForm' from 'django.forms' (F:\farm\lib\site-packages\django\forms_init.py) -
Tracking Recent Actions in Django Admin Panel to send notification
When there is a change in admin panel, the logs are automatically registered to django_admin_log table. I want to trigger an action to send a notification or trigger an action on such changes. so far I have tried (in <app_name>/admin.py) using the LogEntry provided by django @admin.register(LogEntry) class LogEntryAdmin(admin.ModelAdmin): date_hierarchy = 'action_time' list_filter = [ 'user', 'content_type', 'action_flag' ] search_fields = [ 'object_repr', 'change_message' ] list_display = [ 'action_time', 'user', 'content_type', 'action_flag', 'change_message' ] but this doesn't get executed on each action change. The logs that we see in Recent Actions tab on django admin panel, exact same thing is needed here. But I am not able to figure out how to trigger an action on such changes. One way to keep track of django_admin_log table but this will never be efficient since I have to go through the table every time. Any idea on how to achieve this. -
Django 3, request.POST didnt save when i filter the user with request.user
im trying to filter the user that only display the current user login. after im found the solution how to filter the user but didnt save to db forms.py class EnrollmentForm(forms.ModelForm): def __init__(self, user, *args, **kwargs): super(EnrollmentForm, self).__init__(*args, **kwargs) self.fields['user'].queryset = User.objects.filter(username=user) class Meta: model = Enrolled fields = ['schedule', 'user'] views.py def StudentEnroll(request): if request.method == 'POST': form = EnrollmentForm(request.POST) if form.is_valid(): form.save() return redirect('student-schedule') else: form = EnrollmentForm(request.user) return render(request, 'main/student_enroll.html', {'form': form}) -
Validating Entered Data with custom constraints in Django Forms in __init__
In my project, the user is entering data in a settings page of the application and it should update the database with the user's settings preference. I read this answer by Alasdair and how using the __init__() will allow to access the user's details. I was wondering if it's possible to return data from __init__() so I can validate the entered data before calling the save() function in the view? This is what I tried (and did not work). I am open to going about this in a better approach so I appreciate all your suggestions! Forms.py class t_max_form(forms.ModelForm): side = None def __init__(self, *args, **kwargs): side = kwargs.pop('side', None) super(t_max_form, self).__init__(*args,**kwargs) if side == "ms": self.fields['hs_max_sessions'].widget.attrs.update({'class':'form-control', 'readonly':True}) self.fields['ms_max_sessions'].widget.attrs.update({'class':'form-control mb-3'}) elif side == "hs": self.fields['hs_max_sessions'].widget.attrs.update({'class':'form-control'}) self.fields['ms_max_sessions'].widget.attrs.update({'class':'form-control', 'readonly':True}) else: self.fields['hs_max_sessions'].widget.attrs.update({'class':'form-control'}) self.fields['ms_max_sessions'].widget.attrs.update({'class':'form-control'}) #Trying to validate the data here valid_session_count = settings.objects.first() if(side == "ms"): input_sessions = self.fields['ms_max_sessions'].widget.attrs['readonly'] if(input_sessions > valid_session_count.max_sessions): self.add_error("ms_max_sessions", "You have entered more than the limit set by the TC. Try again") elif(side == "hs"): input_sessions = self.cleaned_data['hs_max_sessions'] if(input_sessions > valid_session_count.max_sessions): self.add_error("hs_max_sessions", "You have entered more than the limit set by the TC. Try again") else: input_sessions = self.cleaned_data['ms_max_sessions'] + self.cleaned_data['hs_max_sessions'] if(input_sessions > valid_session_count.max_sessions): self.add_error("hs_max_sessions", "You have entered more than … -
Given an encrypted string in the database, can somebody help me crack this password?
I have uploaded an application on heroku following a course in udemy. The lesson asked me to download an example database uploaded by them and link it with my own application. The application has a sign in page which authenticates itself with auth_user in the database. However, the password is encrypted. as such, i am stuck at the sign in page. I cannot create a new account for the application or write columns into the database, and the author of the udemy course has been uncontactable thus far. Querying the database yielded the account information. However, the password has been encryted, and i have no way of decrypting it. Can anyone help me with this? the password is: pbkdf2_sha256$30000$GBQUIvjRTK1b$JACrwzhRoiSXovL1Sf2A7LiWjZgmUlvTz3thWBRxMfs= this is the account information -
django ORM: get all the fields of model with positive value in one field
I am trying to query all the objects in a model that have a positive value in one particular field. I have not been able to find anywhere whether there is a way to use greater than signs in django. I have tried doing by sorting the column that interests me and removing the 0 values in that column in order to the overcome the greater than. First it seems over complicated, and second it does not work. here is the query: count_orders = replenishment.objects.order_by(F('StockOnOrder')).desc().exclude('StockOnOrder' = 0) I also need to count the positive rows in this field and it does not work either as following: count_orders = replenishment.objects.order_by(F('StockOnOrder')).desc().exclude('StockOnOrder' = 0).count() I am wondering if by chance this is the proper way to do it, or if there is something more intuitive and simple. -
Getting data from related tables using Django ORM
Using the Django ORM, how does one access data from related tables without effectively making a separate call for each record (or redundantly denormalizing data to make it more easily accessible)? Say I have 3 Models: class Tournament(models.Model): name = models.CharField(max_length=250) active = models.BooleanField(null=True,default=1) class Team(models.Model): name = models.CharField(max_length=250) coach_name = models.CharField(max_length=250) active = models.BooleanField(null=True,default=1) class Player(models.Model): user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.DO_NOTHING ) number = models.PositiveIntegerField() age = models.PositiveIntegerField() active = models.BooleanField(null=True,default=1) Note that this Player model is important in the application as it's a major connection to most of the models - from registration to teams to stats to results to prizes. But this Player model doesn't actually contain the person's name as the model contains a user field which is the foreign key to a custom AUTH_USER_MODEL ('user') model which contains first/last name information. This allows the player to log in to the application and perform certain actions. In addition to these base models, say that since a player can play on different teams in different tournaments, I also have a connecting ManyToMany model: class PlayerToTeam(models.Model): player = models.ForeignKey( Player, on_delete=models.DO_NOTHING ) team = models.ForeignKey( Team, on_delete=models.DO_NOTHING ) tournament = models.ForeignKey( Tournament, on_delete=models.DO_NOTHING ) As an example of … -
Using Validators in Django not working properly
I have recently learning about Validators and how they work but I am trying to add a function to my blog project to raise an error when a bad word is used. I have a list of bad words in a txt and added the code to be in the models.py the problem is that nothing is blocked for some reason I am not sure of. Here is the models.py def validate_comment_text(text): with open("badwords.txt") as f: CENSORED_WORDS = f.readlines() words = set(re.sub("[^\w]", " ", text).split()) if any(censored_word in words for censored_word in CENSORED_WORDS): raise ValidationError(f"{censored_word} is censored!") class Comment(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE) content = models.TextField(max_length=300, validators=[validate_comment_text]) updated = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now=True) -
Updating and Deleting Comments for Posts in Django
I have added a Comment system to posts in a Blog Project and I am trying to add an option to update and delete the comments by the users. I am trying to use the same concept as creating a Post and building a Class Based Views for these comments, creating a commment is working fine and it is appearing correctly, the only obstacle I am facing is the slug, when a user clicks on update or delete it is showing an error Cannot resolve keyword 'slug' into the field. Choices are content, created, id, post, post_id, updated, user, user_id which makes sense since there is no Slug in the comment Model. My question is how do refer back to the same page post.slug in the template without getting this error Here is the models.py class Post(models.Model): slug = models.SlugField(blank=True, null=True, max_length=120) ------------------------------------------------------------ class Comment(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE) content = models.TextField(max_length=300, validators=[validate_comment_text]) updated = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now=True) Here is the views.py class PostCommentCreateView(LoginRequiredMixin, CreateView): model = Comment form_class = CommentForm def form_valid(self, form): post = get_object_or_404(Post, slug=self.kwargs['slug']) form.instance.user = self.request.user form.instance.post = post return super().form_valid(form) def form_invalid(self, form): return HttpResponseRedirect(self.get_success_url()) def get_success_url(self): return reverse('blog:post-detail', … -
Django pagination python dictionary
I hope you well. I’m developing a web using python and Django. I will love to paginate my dictionary “image_set_list” in order to see one element in one page, I mean, one element per page. The problem is that when I get the page, the result is None and pagination is not working. This is my view.py from django.shortcuts import render from django.http import HttpResponse import json from pathlib import Path import os from django.core.paginator import Paginator def detection_detail(request): # data planogram, bounding_boxes with open('detection/data.json', 'r') as json_file: data = json.load(json_file) # data image planogram image_name_location = data['image'] image_planogram = os.path.basename(image_name_location) # data product images with open('detection/data_product_images.json', 'r') as json_file: data_product_images = json.load(json_file) data_product_image = {x["id"]: x for x in data_product_images} images_reference = [] list_images = [] for product in data['bounding_boxes']: product_id = product['class'] product_ids = product['class_list'] image_p = data_product_image[product_id]["image_file"] image_p_list = [data_product_image[id]["image_file"] for id in product_ids] images_reference.append(image_p) list_images.append(image_p_list) image_set_list = {images_reference: list_images for images_reference, list_images in zip(images_reference, list_images)} #PAGINATION!! paginator = Paginator(image_set_list , 1) page = request.GET.get('page') print('page', page) #result is -> None set = paginator.get_page(page) context = { 'list_images': list_images, 'images_reference': images_reference, 'image_planogram': image_planogram, 'image_set_list': image_set_list, 'image_p_list': image_p_list, 'set': set} return render(request, "detection/detection_detail.html", context) And this is my … -
django how to use range inside of kwargs
I am trying to filter my queryset between two dates and I can't seem to figure out why this isn't working. Here is my code kwargs = { '{0}__{1}'.format(arg1, 'exact'): arg2, '{0}__{1}'.format('deleted', 'isnull'): True, '{0}__{1}'.format('event_date', 'range'): {date1, date2} } table = GeTable(Ge.objects.filter(**kwargs)) I want to be able to filter my queryset to only records between date1 and date2. Can someone point me in the right direction? -
Defining GOOGLE_APPLICATION_CREDENTIALS on elasticbeanstalk env breaks S3 connection
I have a django app deployed using elasticbeanstalk. I installed firebase admin sdk which requires GOOGLE_APPLICATION_CREDENTIALS field to be filled with path to credential. The problem is that right after I define GOOGLE_APPLICATION_CREDENTIALS on elasticbeanstalk console, Django's connection to S3 all breaks. What is happening and how to fix this? -
Page not found (404) Request Method:
please help me. I don't know why can't see the detail of product when i click a product. both first list work good just when i need to see detail of product in second list(filtered list) an 404 error shows. thanks here is my code below: my urls: from django.urls import path from . import views app_name = 'shop' urlpatterns = [ path('', views.HomeView.as_view(), name='home'), path('categories/<category>/', views.ProductListView.as_view(), name='product-list'), path('categories/<int:pk>/', views.ProductDetailView.as_view(), name='product-detail'), ] views: from django.shortcuts import render, get_object_or_404, get_list_or_404 from django.views import generic from .models import Category, Product class HomeView(generic.ListView): model = Category template_name = 'home.html' class ProductListView(generic.ListView): template_name = 'product_list.html' def get_queryset(self): self.category = get_object_or_404(Category, title=self.kwargs['category']) return Product.objects.filter(category=self.category) class ProductDetailView(generic.DetailView): model = Product template_name = 'product_detail.html' product_list.html {% extends 'base.html' %} {% load static %} {% block title %} Welcome | Global Market {% endblock %} {% block content %} {% for product in product_list %} <a href="{% url 'shop:product-detail' product.pk %}"> <div class="card bg-light mb-3" style="max-width: 18rem;"> <div class="card-header">{{ product.title }}</div> <img class="card-img-top" src="{{ product.image.url }}" alt="{{ product.title }}"> <div class="card-body"> <p class="card-text">{{ product.description }}</p> </div> </div> </a> {% endfor %} {% endblock %} product_detail.html {% extends 'base.html' %} {% load static %} {% block title %} Welcome … -
Django - use middleware to block debug data on some cases
I'm using Django in debug mode in dev environment. When some views fail, it returns the debug page (not debug_toolbar, just the page with list of installed apps, environment variables, stack trace, ...) In my middleware, I have some cases (specific URLs, specific users, ...) where I want to remove this data and just return the raw response. How should I do that? currently my best idea is to just: response.data = {} return response But I'm not sure if it's the proper way to do that, whether it covers all cases and so on. I just want to use a middleware to control in some cases and avoid the DEBUG mode for them. -
Right Approach to Schedule a job in Django/Python
If you have built an application using Django 3 and MySQL 8. How would you schedule a job with "Right Approach" and why? I am guessing by using the inbuilt sched module. What are the merits and demerits of using sched, cron and APScheduler? -
Django Accessing Parent Data in templates from child data
So I've been search and trying to solve this question for hours and hours and I cant' seem to find an answer. I have 2 different models flights and Destinations. The Destination is the Parent model, A flight can only have one destination but the Destination can have many flights (one to many relationship). I would like to access this parent model on the details page of of the flight model. This details page is generated via the url routing and the slug of the flight. Here is what I have for the for the models, views and templates. models: class Flight(models.Model): title = models.CharField( null=True, max_length=60, blank=True) slug = models.SlugField(max_length=100, null=True, blank=True) flight_destination = models.ForeignKey(Destination, null=True, blank=True, on_delete=models.SET_NULL) class Destination(models.Model): title = models.CharField( null=True, max_length=60, blank=True) featuredimage = models.ImageField(null=True, blank=True, upload_to ='media/') slug = models.SlugField(max_length=100, null=True, blank=True) Each of these classes has an id for its primary key and I've connected all my flights to the correct destination. Here is what I have for my view. def flight_detail(request, slug): return render(request,"flight/detail.html",context= {'flight': Flight.objects.get(slug=slug), 'destination': Destination.objects.filter(id= Flight.objects.get(slug=slug).flight_destination_id)}) Here is the template but it which doesn't throw an error but it displays nothing <h3 class="pb-3"> {{ destination.title }} </h3> I feel … -
How do I properly use javascript axios .get() function to call get_queryset() function in Django viewset?
I followed a youtube guide to implement a React/Redux frontend that uses javascript axios to make requests to a Django REST framework backend. I've been adding a lot of my own work to it. Here is the original github repository if you think you need it to answer my question, although you shouldn't: Link To Github I have a new method I use to get what I call eventdefinitions. Sometimes I want all of the eventdefinitions that are in the database, but sometimes I only want some of them. In the original guide, the only way I was taught to get data, was to get all of the data, and so to get all eventdefinitions, I would do the following: In javascript, I use the following method which implements axios: // GET EVENT DEFINITIONS export const getEventDefinitions = () => (dispatch, getState) => { axios .get("/api/eventdefinitions/", tokenConfig(getState)) .then((res) => { dispatch({ type: GET_EVENTDEFINITIONS, payload: res.data, }); }) .catch((err) => dispatch(returnErrors(err.response.data, err.response.status)) ); }; In my urls.py file I set up the url_patterns for the /api/eventdefinitions/ url: from rest_framework import routers from .api import ... EventDefinitionViewSet, ... router = routers.DefaultRouter() ... router.register('api/eventdefinitions', EventDefinitionViewSet, 'eventdefinitions') ... urlpatterns = router.urls The EventDefinitionViewSet in … -
Django add dataframe as Excel file inside model
Django I have multiple dataframes And I want to add download links in html to down load those dataframes as Excel files