Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
The current path, accounts/signup/index.html, didn't match any of these
After filling the signup form, I want to redirect my page to the post_list page of my blog. But I am getting the error as stated above. Below are my different files. accounts is app for managing the accounts and blog_app is app for managing other blog related activities. Blog is the root app. In Blog: urls.py: from django.contrib import admin from django.urls import path from django.conf.urls import url, include from django.contrib.auth import views urlpatterns = [ path('admin/', admin.site.urls), path('',include('blog_app.urls')), url(r'^accounts/',include('accounts.urls')), path('accounts/login/', views.LoginView.as_view(template_name='blog_app/login.html'),name='login'), path('accounts/logout/',views.LogoutView.as_view(template_name='blog_app/base.html'),name='logout'), ] In accounts: views.py: from django.shortcuts import render,redirect from django.contrib.auth.forms import UserCreationForm def signup_view(request): if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): form.save() # log the user in return redirect('blog_app:post_list') else: form = UserCreationForm() return render(request,'accounts/signup.html',{'form':form}) urls.py: from django.conf.urls import url from .import views app_name = 'accounts' urlpatterns = [ url(r'^signup/$', views.signup_view, name = "signup"), ] signup.html: {% extends 'base.html' %} {% block content %} <h1>Signup</h1> <form class="site-form" action="/accounts/signup/" method="POST"> {% csrf_token %} {{ form }} <input type="submit" value="Signup"> </form> {% endblock %} in blog_app: urls.py: from django.conf.urls import url from blog_app import views from django.urls import path app_name = 'blog_app' urlpatterns = [ url(r'^$', views.PostListView.as_view(),name='post_list'), url(r'^about/$', views.AboutView.as_view(),name='about'), url(r'^post/(?P<pk>\d+)$', views.PostDetailView.as_view(),name='post_detail'), url(r'^post/new/$', views.CreatePostView.as_view(),name='new_post'), url(r'^post/(?P<pk>\d+)/edit/$', views.UpdatePostView.as_view(),name='edit_post'), url(r'^drafts/$', … -
Why Django think OR is complex?
I read some model operation from Django's document, and find this I'm curious that OR in WHERE is just basic concept, why Django think it's a complex query? -
cannot add panel to openstack django horizon
I tried to add panel openstack compute panel group but it's not working I do manually python package because toe is not working here is my mypanel tree enter image description here panel.py from django.utils.translation import ugettext_lazy as _ import horizon from openstack_dashboard.dashboards.project import dashboard class Testpanel(horizon.Panel): name = _("Testpanel") slug = "mypanel.testpanel" permissions = ('openstack.project.compute', 'openstack.roles.admin') policy_rules = ((("compute", "context_is_admin"), ("compute", "compute:get_all")),) dashboard.Project.register(Testpanel) _12221_project_mypanel_test_panel.py from django.utils.translation import ugettext_lazy as _ import horizon from openstack_dashboard.dashboards.project import dashboard class Testpanel(horizon.Panel): name = _("Testpanel") slug = "mypanel.testpanel" permissions = ('openstack.project.compute', 'openstack.roles.admin') policy_rules = ((("compute", "context_is_admin"), ("compute", "compute:get_all")),) dashboard.Project.register(Testpanel) I can't not see mypanel on compute panel group /project dashboard What am I miss?? I just want to see mypanel name on dashboard -
How to create CRUDL API is using python for Automation Test Framework for servicenow?
I am trying to create a new python CRUDL API for the automated testing framework of ServiceNow using the fastAPI library in python. am stuck for the process. please help me with this task anyone -
Django template find <input> 'checked' attr use template tags
this is my template {% if field|is_checkbox_input %} <label {% if field.field.checked %}active{% endif %} {% if field.field.disabled %}disabled{% endif %}">{{ field }}</label> {% endif %} I wanna get the checked & disabled attribute {% if field.field.disabled %}disabled{% endif %} is working but {% if field.field.checked %}active{% endif %} not, what am i doing wrong? -
Djongo FAILED SQL: INSERT INTO \<TABLENAME>
I'm new to the Django Framework and I am using Djongo connector to connect to the MongoDB backend database. When I try to insert a large dictionary i run into a error and i am unable to insert the record in MongoDB. I will be adding a condensed version of the code here. My model.py is given below, i am using the binary field to store the dictionary. from djongo import models as MongoModel class QuickInsights(MongoModel.Model): ChartAttributesData = MongoModel.BinaryField(blank=True) This is what my view.py looks like. def Save(request): try: InsightDocument = QuickInsights.objects.create( ChartAttributesData=request.data.get("ChartAttributesData") MongoId = request.data.get("MongoID") UserID = request.data.get("UserID") ) InsightDocument.save() return Response(status.HTTP_200_OK) except ValueError as e: return Response(e.args[0], status.HTTP_400_BAD_REQUEST) My dictionary is roughly around 30K lines after beautifying/formatting. I can comfortably insert large data to MongoDB via it's shell, but i have an issue while doing the same from Django with the Djongo connector. Is it because of the Model Binary field or the Djongo connector cannot process it? -
Set azure blob in open edx MEDIA_ROOT and MEDIA_URL
I have installed open edx in two different machines, and access by the load balancer. I have configured the Scorm xblock https://github.com/raccoongang/edx_xblock_scorm in open edx. I want to upload scorm in azure blob so both machine access. My configuration in lms.env.json and cms.env.json "AZURE_ACCOUNT_KEY":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx", "AZURE_ACCOUNT_NAME": "myedx", "AZURE_CONTAINER": "edx", "DEFAULT_FILE_STORAGE": "openedx.core.storage.AzureStorageMedia", "MEDIA_ROOT": "https://myedx.blob.core.windows.net/edx/", "MEDIA_URL": "https://myedx.blob.core.windows.net/edx/", My sotorage class class AzureStorageMedia(AzureStorage): account_name = settings.AZURE_ACCOUNT_NAME account_key = settings.AZURE_ACCOUNT_KEY azure_container = settings.AZURE_CONTAINER expiration_secs = None location = 'media' file_overwrite = False My error resp = descriptor.handle(handler, req, suffix) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/xblock/mixins.py", line 89, in handle return self.runtime.handle(self, handler_name, request, suffix) File "/edx/app/edxapp/edx-platform/common/lib/xmodule/xmodule/x_module.py", line 1347, in handle return super(MetricsMixin, self).handle(block, handler_name, request, suffix=suffix) File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/xblock/runtime.py", line 1037, in handle results = handler(request, suffix) File "/edx/app/edxapp/edx_xblock_scorm/scormxblock/scormxblock.py", line 164, in studio_submit os.mkdir(SCORM_ROOT) OSError: [Errno 2] No such file or directory: 'https://myedx.blob.core.windows.net/edx/scorm' How to solve this error. -
How to go about implementing multi user payment with django
Hello guys I need help with this hope it's not too difficult but I am finding it difficult to implement, here it goes. I have an event app that I have built it's working as expected where I have users create event and tickets for the event can be paid or free. Getting the payment from a user buying ticket is not a problem. The problem I am facing is paying the event creators their money. how do I handle multiple payment solution to each users of the site. Suggestions will be great if there's already a solution out there I would love to be pointed towards it. Thanks. -
Query to send post request in django
I'm trying to create a Calorie Info API which saves calorie intake for a user. If it is a new user, then add an entry for the user id and item id. If the user already exists, If the item is new, then just map the item id and the calorie count with that user. If the item id is already mapped with that user, then add the items calorie count with that item for that user. Url: /api/calorie-info/save/ Method: POST, Input: { "user_id": 1, "calorie_info": [{ "itemId": 10, "calorie_count": 100 }, { "itemId": 11, "calorie_count": 100 }] } Output: - Response Code: 201 My model: class CalorieInfo(models.Model): user_id = models.IntegerField(unique=True) itemId = models.IntegerField(unique=True) calorie_count = models.IntegerField() How will my view look like if I need to input in database in this form ? -
NoReverseMatch error argument not found, Django newbie
Greetings fellow programmers, So I'm a bit of a newbie at posting questions on here, as well as Django in general, and coding for that matter, so looking for constructive criticism. I'm working on building my first from scratch app, a tinder clone, on Django. I've elected to go with a custom model, which has been kinda a pain creating but I wanted to customize the registration so I went with it. I'm stuck at a certain where I'm not sure what's going on. I've looked at similar posts and tried different solutions but it isn't working. The error I'm getting is, Reverse for 'profile' with arguments '('',)' not found. 1 pattern(s) tried: ['profile/(?P[0-9]+)/$'] I don't understand why the profile.id isn't being passed when I've put it in my url href tag. Here is my roots url.py from django.contrib import admin from django.urls import path, include from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('', include('dating_app.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) Here is dating_app/urls.py from django.urls import path from django.contrib.auth.views import LoginView from . import views app_name = 'dating_app' urlpatterns = [ #Home page path('', views.home, name='home'), #List of profiles path('profiles/', views.profiles, name='profiles'), #Individual profiles path('profile/<int:profile_id>/', … -
Django - Posting 2d list of multiple files results to single list
I have dynamic fields: <input type='text' name='names[]'> and <input type='file' name='images[]' multiple> which i will be posting to a view and be processed in batch by zipping the fields. The problem is when I post it, the images[] will be received as single list instead of 2d list. single list: images = [<file 1>, <file 2>, <file 3>, <file 4>] where it should be 2d list: images = [[<file 1>, <file 2>], [<file 3>, <file 4>]]. I need the images to be in 2d list since I will be using them on a zip. is there anyway I can do this without having different names for each <input type='file' name='images[]' multiple> row? template: <form action="__post_url_here__" method="POST" enctype="multipart/form-data"> <div> <input type="text" name="names[]" /> # has value of name 1 <input type="file" name="images[]" multiple /> # has value of [<file 1>, <file 2>] </div> <div> <input type="text" name="names[]" /> # has value of name 2 <input type="file" name="images[]" multiple /> # has value of [<file 3>, <file 4>] </div> ... ... </form> view: form_data = request.POST file_data = request.FILES names = form_data.getlist("names[]") images = form_data.getlist("images[]") print(names) # this results to ["name 1", "name 2"] print(images) # this results to [<file 1>, <file … -
What are the steps to make a ModelForm work with a ManyToMany relationship in Django?
How to call or implement many to many fields at the template? the only that i can think of right now is to make another form just specifically for IncomeSection. Thus the IncomeSection form will be call again in the view and pass it to the template. is there a way that i can put the same form as clientname? model.py class Taxcomp(models.Model): ClientName = models.CharField(_('Client Name'),max_length=50,blank = True, null= True) income = models.ManyToManyField(IncomeSection,blank=True) class IncomeSection(models.Model): Salary= models.CharField(choices=income.choices,max_length=512,null=True,blank=True) Bonus= models.CharField(choices=income.choices,max_length=512,null=True,blank=True) description = models.CharField(max_length=512,null=True,blank=True) form.py class taxCompForm(forms.ModelForm): class Meta: model = Taxcomp fields = ('__all__') view.py def taxcompute(request): msg = 'Tax Comp Successfully Updated' msgerror = 'Invalid inputs' data = request.session.get('session_data') clientname = data['client_name'] if request.method == "GET": form = taxCompForm(initial={'ClientName':clientname}) formc = ProfileUpdateForm() income_list = [] salary = [] bonus = [] taxcompobj = Taxcomp.objects.all() header_fields = [] income_obj = Taxcomp.objects.get(pk=1) print(income_obj) for income in income_obj.income.all(): incomeForm = taxCompForm(instance=income) if income.title == "Salary": salary.append(incomeForm) elif income.title == "Bonus": bonus.append(incomeForm) else: comission.append(**incomeForm**) salary.append(taxCompForm(initial={'title':'Salary'})) bonus.append(taxCompForm(initial={'title':'Bonus'})) context ={ 'form' :form, 'formc': formc, 'salaryform': salary, 'bonusform': bonus } else: form = taxCompForm(request.POST) if form.is_valid() : form.save() messages.success(request, f'{msg}') return redirect ('taxcompute') else: messages.error(request, f'{msgerror}') print(inputf.errors) return redirect ('taxcompute') return render (request,'taxcomp.html',context) taxcomp.html {%for bonus … -
Elasticsearch DSL Filter
I am having a problem with the elastic-search filter. I am trying to search for a text using elastic-search DSL filter, but I am facing issue with sorting. Search text: hello world Other string in the document: Hello there, hello world, hello everyone, hi hello, etc... Elasticsearch-dsl query is: MyDocument.search().filter(Q("match", title="hello world") | Q("match", original_title="hello world")).execute() Elasticsearch query is like this: { 'bool': { 'filter': [{ 'bool': { 'should': [{ 'match': { 'title': 'hello world' } }, { 'match': { 'original_title': 'hello world' } }] } }] } } The output is like hello everyone, hi hello, hello world, etc.. but I want hello world first. Thanks in advance! -
how to get count of rating in django rest framework
I have a model like that class UserRating(models.Model): product = models.OneToOneField(Product, on_delete=models.CASCADE, null=True) rate = models.PositiveSmallIntegerField() status = models.BooleanField(default=False) I rate this in a range of 1 to 4 where 4 is excellent, 3 is very good, 2 is good, 1 is bad and I should get the count of rating according to the number given by user. I am using SerializerMethodField like that is def get_excellent(self, obj): return models.UserRating.objects.filter(rate=4, status=True).count() def get_very_good(self, obj): return models.UserRating.objects.filter(rate=3, status=True).count() def get_good(self, obj): return models.UserRating.objects.filter(rate=2, status=True).count() def get_bad(self, obj): return models.UserRating.objects.filter(rate=1, status=True).count() but it is bad idea to do this because it goes to the db the four times. I am looking for better way of doing this. Is there any help please! Thanks in advance! -
How to check BASE_DIR in django?
I was running into a lot of file not found for webpack in my static folder, and I later realized that for some reason this particular project (which I'm using docker with) keeps trying to check another project folder's static folder for the files I would want. I'm not sure where this could've gone wrong other than the base_dir, but I never changed that setting. There was a while I was going between the projects and trying to run each one (the other project is basically the same thing but not on docker), was that possibly what's confusing the program? How can I solve it? -
How to count no of event by the a user
My model suppose i created a user named 'Ashu',and that user 'Ashu' created multiple sessions, i want to print that no of session by the user 'Ashu' class MyUser(AbstractBaseUser): email = models.EmailField( verbose_name='email address', max_length=255, unique=True) user_name=models.CharField(max_length=10,blank=True,null=True,unique=True) date_of_birth=models.DateField(null=True,blank=True) mobile_number=models.CharField(max_length=20,blank=True,null=True) address=models.CharField(max_length=100,blank=True,null=True) country=models.CharField(max_length=20,blank=True,null=True) joining_date=models.DateField(null=True,blank=True) Rating_CHOICES = ( (1, 'Poor'), (2, 'Average'), (3, 'Good'), (4, 'Very Good'), (5, 'Excellent') ) Rating=models.IntegerField(choices=Rating_CHOICES,default=1) is_active = models.BooleanField(default=True) is_admin = models.BooleanField(default=False) objects = MyUserManager() USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['date_of_birth'] def __str__(self): return str(self.user_name) def has_perm(self, perm, obj=None): return True def has_module_perms(self, app_label): return True @property def is_staff(self): return self.is_admin class Session(models.Model): Host=models.ForeignKey(MyUser,on_delete=models.CASCADE) game=( ('cricket','cricket'), ('football','football'), ('basketball','basketball'), ('hockey','hockey'), ('gym','gym'), ('baseball','baseball'), ) Sport=models.CharField(max_length=20,choices=game) SPORT=( ('Indoor','Indoor'), ('Outdoor','Outdoor'), ) Sports_category=models.CharField(max_length=10,choices=SPORT) SESSIONS=( ('General','General'), ('Business','Business'), ) Session_category=models.CharField(max_length=15,choices=SESSIONS) TYPE=( ('Paid','Paid'), ('Free','Free'), ) Session_type=models.CharField(max_length=10,choices=TYPE) Created=models.DateField(null=True,blank=True) Session_Date=models.DateField(null=True,blank=True) Location=models.ForeignKey(MyUser,related_name='street',on_delete=models.CASCADE) Player=models.CharField(max_length=100,blank=False) Start_time=models.TimeField(auto_now=False, auto_now_add=False) End_time=models.TimeField(auto_now=False, auto_now_add=False) Duration=models.CharField(max_length=30,blank=False) status=( ('1','Active'), ('2','UnActive'), ) Status=models.CharField(max_length=20,choices=status) Equipment=models.TextField() Duration=models.CharField(max_length=20,blank=False) Level=models.ForeignKey(IntrestedIn,blank=True,on_delete=models.CASCADE) GENDER=( ('Male','Male'), ('Female','Female'), ('Male and Female','Male and Female'), ('Other','Other'), ) Gender=models.CharField(max_length=20,choices=GENDER ,blank=True) Fee=models.CharField(max_length=50,blank=True,default='0') def __str__(self): return str(self.Host) MY VIEWSET class UserViewSet(viewsets.ViewSet): def create(self,request): try: user_name=request.data.get('user_name') mobile_number=request.data.get('mobile_number') address=request.data.get('address') country=request.data.get('country') joining_date=request.data.get('joining_date') if not all([user_name,mobile_number,address,country,joining_date]): raise Exception('All fields are mandatory') user=MyUser() user.user_name=user_name user.mobile_number=mobile_number user.address=address user.country=country user.joining_date=joining_date user.save() return Response({"response":'delivered'}) except Exception as error: traceback.print_exc() return Response({"message": str(error), "success": False}, status=status.HTTP_200_OK) class SessionViewSet(viewsets.ViewSet): def create(self, request): try: … -
Python Weasyprint causing High CPU usage, How do I queue rendering?
Please bear with me as i put these into words, I am running Weasyprint on Python Django Framework, I have have 15 page html to render to PDF. Rendering takes about 70% to 80% of my CPU when one user click button to render, so what happens is when two or three users render at the same time, it goes above 100% and cause my sever to crash, that I need to reboot the system to make it work again. My question is, Is there something I can use to queue users request for rendering? Instead of processing render requests at the same time, make them wait in a queue? -
ValueError: Cannot assign "<Truckdb: Truckdb object (1)>": "Quiz.truck_name" must be a "truck_name" instance
I am trying to create an instance in my app like this: Views.py new_quiz = Quiz.objects.create(owner=request.user, comments="Autogenerated", truck_type=truck_type_object, truck_name=chosen_truck_object) where chosen_truck_object is this: chosen_truck_object = Truckdb.objects.filter(display_name=chosentruck)[0] And Models.py class Quiz(models.Model): owner = models.ForeignKey(User, on_delete=models.CASCADE, related_name='quizzes') comments = models.TextField(max_length=256, blank=True) truck_type = models.ForeignKey(truck_type, on_delete=models.CASCADE, related_name='trucks') truck_name = models.ForeignKey(truck_name, on_delete=models.SET_NULL, null=True) How can I pass the truck_type and truck_name instance to the Quiz model in Quiz.objects.create ? -
How to apply django permisssions on django cms page?
I am trying to apply my django permissions on the cms page like this but it is not working. Is it possible to apply permissions like this on django cms page? If not how can I apply permissions on the cms page in a proper way ? <div class="item"> {% if perms.user_groups.add_image %} {% placeholder "Home Image" or %} <img src="{% static 'assets/images/1.png' %}" alt="" class="img-fluid"/> {% endplaceholder %} {% endif %} </div> -
django + ajax output errors to the form
I use ajax to submit the form. $(document).ready(function(){ $(document).on("submit", "#my_form", function(event) { event.preventDefault(); $this = $(this); $.ajax({ type: "POST", data: $this.serialize(), success: function(data) { console.log(data); if (data.result == 'success') { var parent=$("#my_form").parent(); parent.html(data.success); } else if (data['result'] == 'error') { } }, error: function(data) { console.log(data); } }); }); }); when the form is valid, everything works fine. But I'm don’t understand how to display errors on the form if the field is entered incorrectly. They are displayed in the browser console. I deduce the form in the template as follows: <form action="" method="post" autocomplete="off" id="my_form"> {% csrf_token %} <div class="contact-form" > <h1>{%trans 'Register' %}</h1> <div class="txtb">{{form.fio.label}} {{form.fio}}{{form.fio.help_text}}</div> <div class="txtb">{{form.phone.label}} {{form.phone}}{{form.phone.help_text}}{{form.errors}}</div> <div class="txtb"> {{form.date_visit.label}}{{form.date_visit}}</div> <div class="txtb"> {{form.captcha.label}}{{form.captcha}}{{form.errors}}</div> <input type="submit" value="{%trans 'subbmit' %}" class="btn" id="btn"> </div> </form> -
why i am unable to import 'django.contrib.auth.models'?
I am trying to import 'models' in my django project but i give me some error I am trying to import from django.contrib.auth.models import AbstractBaseUser from django.contrib.auth.models import PermissionMixin from django.contrib.auth.models import BaseUserManager in Virtual Studio code editor -
Profile Image Uploading For Django Not Working
Using python 3 and Django 3 When i try to upload an image,This error is showing : "Such details already exist". i just added image upload code to it. Before adding image upload code, there was no problem. Anybody know how to fix it ? Help is much appreciated. i Set the MEDIA DIR on the setting.py file Views.py def workerreg(request): if request.POST: district=request.POST.get("district") panchayath=request.POST.get("panchayathlist") wnamee=request.POST.get("wnamee") wphnu=request.POST.get("wphnu") wan=request.POST.get("wan") waddress=request.POST.get("waddress") wmail=request.POST.get("wmail") qul=request.POST.get("qul") uploaded_file_url="" if request.FILES.get("image"): myfile=request.FILES.get("image") fs=FileSystemStorage() filename=fs.save(myfile.name , myfile) uploaded_file_url = fs.url(filename) worker_exists="select count(*) from worker_reg where district='"+str(district)+"' and panchayath='"+str(panchayath)+"' and ward_no='"+str(wan)+"' or phone_no='"+str(wphnu)+"'" print("-------"+worker_exists+"-------") c.execute(worker_exists) exisist_data=c.fetchone() print(exisist_data) try: if exisist_data[0]>0: message="ashaworker already exisist" return render(request,"workerreg.html",{"message":message}) else: random_num=random.randrange(1000,10000,2) print("--------password---- "+str(random_num)) password="worker"+str(random_num) print(password) worker_insert="insert into worker_reg(`district`,`panchayath`,`worker_name`,`phone_no`,`ward_no`,`address`,`email`,`qualification`,'image')values('"+str(district)+"','"+str(panchayath)+"','"+str(wnamee)+"','"+str(wphnu)+"','"+str(wan)+"','"+str(waddress)+"','"+str(wmail)+"','"+str(qul)+"','"+str(uploaded_file_url)+"')" worker_login="insert into login(userid,username,password,status,usertype)values((select max(wrkr_id) from worker_reg),'"+str(wphnu)+"','"+str(password)+"','1','worker')" c.execute(worker_insert) conn.commit() c.execute(worker_login) conn.commit() msg="Congratulations!!! Government added you as ashaworker in the "+panchayath+" panchayath for ward number :"+wan+" Username :"+wphnu+" Password: "+password sendsms(wphnu,msg) message="Added Successfully" return render(request,"workerreg.html",{"message":message}) except: message="Such details already exisist" return render(request,"workerreg.html",{"message":message}) return render(request,'workerreg.html') upload.html {%if message%} <script> alert('{{message}}'); </script> {%endif%} <form action="#" method="post" enctype="multipart/form-data"> {% csrf_token %} <label style='position: relative; top: 10px;' for="file-upload" class="custom-file-upload2"> Select Photo </label> <input type="file" id="file-upload" name="image" required=""/> <br/> <br/><br/> <select name="district" id="district"> <option>--Choose District--</option> <option>Kasargode</option> <option>Kannur</option> <option>Vayanad</option> <option>Malappuram</option> <option>Kottayam</option> <option>Kozhikod</option> <option>Ernakulam</option> … -
i'm trying to make a table print page in django but when i pass multiple value through dict it's print only first value
**here is the views.py** **views.py** def inp(request): return render(request,'inp.html') def tab(request): num1 = dict() number =int (request.GET.get('num')) for i in range(1,11): num1[i] = number*i for key in num1: print(num1[key]) return render(request,'tab.html',{"result" : num1[key]}) here is inp.html **inp.html** <!DOCTYPE html> <html> <head> <title>table</title> </head> <h1>Enter The Number Which You Want For Table</h1> <body> <form action ="tab/" method="get"> Enter a Number:<input type = "text" name ="num"> <input type = "submit"> </form> </body> </html> here is tab.html tab.html <!DOCTYPE html> <html> <head> <title>output</title> </head> <body> your answer is {{result}}<br> your answer is {{result}}<br> your answer is {{result}}<br> your answer is {{result}}<br> your answer is {{result}}<br> your answer is {{result}}<br> your answer is {{result}}<br> your answer is {{result}}<br> your answer is {{result}}<br> your answer is {{result}}<br> </body> </html>`enter code here` It looks like your post is mostly code; please add some more details. It looks like your post is mostly code; please add some more details. - List item -
Django Rest Framework: filtering on relationships using hyperlink URIs
I'm using Django Rest Framework to create a simple API. I have two models with a foreign key relationship: class Article(models.Model): publisher = models.ForeignKey('Publisher', ...) class Publisher(models.Model): name = ... I am serializing them using hyperlink identifiers: { "url": "http://localhost:8000/api/1/article/1", "publisher": { "url": "http://localhost:8000/api/1/publisher/1", "name": "Publisher One" }, ... } I'd like to filter all articles against the publisher of a specific article, ideally something of this form: http://localhost:8000/api/1/article?publisher=http://localhost:8000/api/1/publisher/1 I tried creating a custom FilterClass, however url isn't an actual field on the model, so I'm uncertain how to reference it. If I extract the id from the URL and pass that through it works as expected, but I'd rather the client not need to know how to parse a hyperlinked identifier for the "real" identifier. I can add the id to the serializer as well but if that's the solution what even is the point of the HyperlinkedModelSerializer? -
Need 4 dropdowns which depends on user selection,according to each user selection respective dropdown will be shown
I want to create something like first user selects the bank and than user selects the district and than user selects the branch and than I display the ifsc code .I've made an example where first user selects the bank and than the district .How should I do it after district branch and than IFSC .So basically 4 dropdowns <select id="Bank_Detail" onchange="fun(this.value)" > <option value=''>select</option> <option value="sbi">SBI</option> <option value="axis">AXIS</option> </select><br/><br/> <select id="sbi_district"> <option value="north">North</option> <option value="south">South</option> </select> <select id="axis_district"> <option value="west">West</option> <option value="east">East</option> </select> <body onLoad="fun('')"> <select id="Bank_Detail" onchange="fun(this.value)" > <option value=''>select</option> <option value="sbi">State Bank Of India</option> <option value="axis">Axis</option> </select><br/><br/> <select id="sbi_district"> <option value="west">West</option> <option value="east">East</option> </select> <select id="axis_district"> <option value="north">North</option> <option value="south">South</option> </select> </body> <script> function fun(val) { if(val=="sbi") { $('#axis_district').hide(); $('#sbi_district').show(); } else if(val=="axis") { $('#sbi_district').hide(); $('#axis_district').show(); } else if(val=='') { $('#sbi_district').hide(); $('#axis_district').hide(); } } </script>