Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Integrating normal HTML form with Django form
What I am trying to do is have a form that has this HTML: <form method="post" action=""> {% csrf_token %} <label>Pick a class:</label> <select id="schedClass" name="schedClass" > <option>Select one</option> {% for i in classes %} <option value="{{ i.id }}">{{ i.name }}</option> {% endfor %} </select> </select> {{ form }} <input type="submit" value="reload"> </form> The problem is that for some reason when I submit, the select schedClass doesn't appear in the link. I think it comes from the fact that it's integrated with a django form, but I have no idea. For clarification, what I am trying to do is have a form that creates an instance of a specific model, and one of the categories is schedClass which is a ManyToManyField, but I can't use a ModelForm since I need the items in the selections to be only ones that are also linked to the user with another ManyToMany. Is there anything to do? -
RecursionError at : maximum recursion depth exceeded while calling a Python object
I can't seem to find the problem in header.html which is leading to "RecursionError: maximum recursion depth exceeded while calling a Python object". base.html: {% load static %} <!DOCTYPE html> <html> <body> {% include 'header.html' %} {% include 'navbar.html' %} {% include 'dashboard.html' %} <div class="container-fluid"> {% block content %} {% endblock %} </div> {% include 'footer.html' %} </body> <!-- Bootstrap core JavaScript--> <script src="{% static 'vendor/jquery/jquery.min.js' %}"></script> <script src="{% static 'vendor/bootstrap/js/bootstrap.bundle.min.js' %}"></script> <!-- Core plugin JavaScript--> <script src="{% static 'vendor/jquery-easing/jquery.easing.min.js' %}"></script> <!-- Custom scripts for all pages--> <script src="{% static 'js/sb-admin-2.min.js' %}"></script> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script> </html> dashboard.html: {% load static %} {% extends 'base.html' %} <head> <title>:: Welcome to CrmNXT ::</title> <!-- Custom fonts for this template--> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet"> <!-- Custom styles for this template--> <link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet"> </head> <body id="page-top"> <!-- Page Wrapper --> <div id="wrapper"> <!-- Sidebar --> <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar"> <!-- Sidebar - Brand --> <a class="sidebar-brand d-flex align-items-center justify-content-center" href="#"> <div class="sidebar-brand-icon rotate-n-15"> <i class="fas fa-address-card"></i> </div> <div class="sidebar-brand-text mx-3">Welcome to NexCRM</div> </a> <!-- Divider --> <hr class="sidebar-divider my-0"> … -
Django keeps applying migrations
This is making me go insane: when I migrate, my django (3.1.1) completes the task, but seems to forgets about it. If I migrate again it will stop because it's trying to reapply the migrations. Example of the situation: I drop db.sqlite3 I drop everything inside app/migrations (excluded init) I run makemigrations: no problems. I run migrate: no problems. I run migrate again: fails (django.db.utils.OperationalError: table "django_content_type" already exists) Just to make sure I've executed "migrate --plan", confirming that it intends to apply the migrations it just performed. What am I missing here? Planned operations: contenttypes.0001_initial Create model ContentType Alter unique_together for contenttype (1 constraint(s)) auth.0001_initial Create model Permission Create model Group Create model User admin.0001_initial Create model LogEntry admin.0002_logentry_remove_auto_add Alter field action_time on logentry admin.0003_logentry_add_action_flag_choices Alter field action_flag on logentry contenttypes.0002_remove_content_type_name Change Meta options on contenttype Alter field name on contenttype Raw Python operation Remove field name from contenttype auth.0002_alter_permission_name_max_length Alter field name on permission auth.0003_alter_user_email_max_length Alter field email on user auth.0004_alter_user_username_opts Alter field username on user auth.0005_alter_user_last_login_null Alter field last_login on user auth.0006_require_contenttypes_0002 auth.0007_alter_validators_add_error_messages Alter field username on user auth.0008_alter_user_username_max_length Alter field username on user auth.0009_alter_user_last_name_max_length Alter field last_name on user auth.0010_alter_group_name_max_length Alter field name on group auth.0011_update_proxy_permissions … -
How to get date input from table created using for loop in django?
So I have passed a context from views.py to my html template. I have created a html table using 'For Loop' in the following way and also added a column with input date field. <table class="table"> <thead style="background-color:DodgerBlue;color:White;"> <tr> <th scope="col">Barcode</th> <th scope="col">Owner</th> <th scope="col">Mobile</th> <th scope="col">Address</th> <th scope="col">Asset Type</th> <th scope="col">Schhedule Date</th> <th scope="col">Approve Asset Request</th> </tr> </thead> <tbody> {% for i in deliverylist %} <tr> <td class="barcode">{{i.barcode}}</td> <td class="owner">{{i.owner}}</td> <td class="mobile">{{i.mobile}}</td> <td class="address">{{i.address}}</td> <td class="atype">{{i.atype}}</td> <td class="deliverydate"><input type="date"></td> <td><button id="schedulebutton" onclick="schedule({{forloop.counter0}})" style="background-color:#288233; color:white;" class="btn btn-indigo btn-sm m-0">Schedule Date</button></td> </tr> {% endfor %} </tbody> Now I would like to get that date element value in javascript, but its proving difficult since I am assigning a class instead of id(as multiple elements cant have same id). I tried in the following way but its not working. The console log shows no value in that variable. <script> //i is the iteration number passed in function call using forloop.counter0 function schedule(i){ var deldate = document.getElementsByClassName("deliverydate"); deldate2 = deldate[i].innerText; console.log(deldate2); //log shows no value/empty console.log(i); //log shows iteration number </script> -
How do I get all the input from the same form field in django? (The form field is in a loop in the HTML thus shows more than once)
I'm trying to get all the input from the same form field which displayed in the HTML twice since it's in a loop (as in this example). Is there a way I can do it? Below are the codes: HTML def home(request): nums = [[3, "", 2, 7, 5, 6, 1, 4, 9], [1, 4, 5, 2, 3, 9, 6, 7, 8], [6, 7, 9, 1, 4, 8, 2, 3, 5], [2, 1, 3, 4, 6, 5, 8, 9, 7], [4, 5, 6, 8, 9, 7, 3, 1, 2], [7, 9, 8, 3, 1, "", 4, 5, 6], [5, 2, 1, 6, 7, 3, 9, 8, 4], [8, 3, 7, 9, 2, 4, 5, 6, 1], [9, 6, 4, 5, 8, 1, 7, 2, 3]] context = {'nums': nums} if request.method == "POST": form = SForm(request.POST) context['form'] = form if form.is_valid(): num = form.cleaned_data.get('num') else: form = SForm() context['form'] = form context['range'] = range(9) return render(request, 's/home.html', context) Forms.py class SForm(forms.Form): num = forms.IntegerField(min_value=0, max_value=9, label=False) HTML.py {% block content %} <form method="POST" name="s_form"> {% csrf_token %} {% for row in nums %} <tr> {% for col in row %} {% if forloop.counter0|divisibleby:"9" %} <br> {% endif %} {% if … -
Error While using Qtest custom apis to create a test case
Hi I am working on of the product development where in I want to upload test cases remotely to the qtest tool with the help of the custom apis provided by the tool, I am able to login to the tool generate the authorization code, but when I call the api for uploading/creating a test case its not allowing me upload the test case I am following their official apis website to take the sample data and upload the same through postman by calling there apis but getting the below error My Post man body { "name":"An automation Test Case created via API", "properties":[ { "field_id":1695364, "field_value":710 }, { "field_id":1695363, "field_value":711 } ], "test_steps":[ { "description":"Open browser", "expected":"" }, { "description":"Access gmail.com", "expected":"Page is successfully loaded" }, { "description":"call another test case", "expected":"log in successfully", "called_test_case": { "id": 7372896, "approved": true } } ] } error in postman { "message":"null" } If Some one can please help me out with the problem -
What is the difference between request.GET.get('key', '') and request.GET.get('key)?
What is the difference between request.GET.get('key', '') and request.GET.get('key')? I thought dict.get() method's default option is None when it has not described. Then None and '' is different in Python grammar? -
category field it there in model as a foreignkey but then also it giving me this error
AttributeError: Got AttributeError when attempting to get a value for field category on serializer HelpTopicSerializer. The serializer field might be named incorrectly and not match any attribute or key on the QuerySet instance. Original exception text was: 'QuerySet' object has no attribute 'category'. class HelpTopicCategorySerializer(serializers.ModelSerializer): class Meta: model = HelpCategory fields = ('category', 'parent') class HelpTopicSerializer(serializers.ModelSerializer): category = HelpTopicCategorySerializer() #here category is foreignkey class Meta: model = HelpTopic fields = ('category', 'view_or_read', 'popular_topic', 'question', 'answer') @api_view(['GET']) @permission_classes((IsAuthenticated,)) @authentication_classes((TokenAuthentication,BasicAuthentication,SessionAuthentication)) def help_topic_list(request): help_topic = HelpTopic.objects.all() for i in help_topic: print(i.category) # try: # help_topic = HelpTopic.objects.all() # except HelpTopic.DoesNotExist: # return Response(status=status.HTTP_404_NOT_FOUND) if request.method == 'GET': print(help_topic, "ggggggggggggggggg") serializer = HelpTopicSerializer(help_topic) return Response(serializer.data) -
drf-yasg - How to customize persistent auth token?
I am using drf-yasg to generate open API, what I want is once I have added the token for authentication it should be persistent and should not expire when user refreshes the page. Currently if user refreshes the page the token gets lost and user again needs to enter the token again and again after any single change. -
How to get a testing http request in django testcase?
I'm working in a solution with only an GraphQL API, so all my logic are in forms. The save method of one of my forms receives the http request. I use the request to get some data for mailing. So, I'm trying to make a test case of this form but I don't know how to pass the request object. class SignUpForm(forms.ModelForm): ... def save(self, request, *args, **kwargs): ... How can I pass the request object to form in a test case? -
Best way to use image files with database data in Django?
I'm new to programming and to Django so forgive me if this is an easily-answerable question but I haven't managed to find any solid answers. I'm currently working on a tour booking website. I want to add several images to a tour in the Tour class, so that on the tour detail page the user can scroll through the photos. I'm referencing this page https://medium.com/ibisdev/upload-multiple-images-to-a-model-with-django-fd00d8551a1c for how to write the model, but this method is for users uploading files, so it doesn't explain how to use ones that I already have. How should I deal with these files? As the link explains, I'm hoping to use an image album class and then use that album in the Tour class, so that I can use several photos for each tour rather than just one image field. I've seen that you can put images in the database directly, but it seems like it's not the best solution. Should they be stored in the static folder? If so, how can they be associated with the correct tour in the Tour class? If they should be stored in the database, how can I call those images from the database and have them displayed in … -
I'm struggling with making search function with multi condition using django queryset
def influencer_board(request): user_input = [] index_list = [] influencer = Influencer_DB.objects.all() if request.method == 'GET': sns_type = request.GET.get('sns_type') #0 follower_num_min = request.GET.get('follower_num_min') #1 follower_num_max = request.GET.get('follower_num_max') #2 name = request.GET.get('name')#3 gender = request.GET.get('gender')#4 sns_id = request.GET.get('sns_id')#5 keyword = request.GET.get('keyword')#6 user_input.append(sns_type) user_input.append(follower_num_min) user_input.append(follower_num_max) user_input.append(name) user_input.append(gender) user_input.append(sns_id) user_input.append(keyword) for col in user_input: if col != "": index = user_input.index(col) index_list.append(index) influencer = Influencer_DB.objects for index in index_list: if index == 0: influencer = influencer.filter(sns_type=sns_type) if index == 1: influencer = influencer.filter(follower_num__gte = follower_num_min) if index == 2: influencer = influencer.filter(follower_num__lte = follower_num_max) if index == 3: influencer = influencer.filter(name=name) if index == 4: influencer = influencer.filter(gender = gender) if index == 5: influencer = influencer.filter(sns_id=sns_id) if index == 6: influencer = influencer.filter(keyword__icontains = keyword) return render(request,"influencer_board.html",{'influencer':influencer,"sns_type":sns_type,'follower_num_max':follower_num_max, 'followever':follower_num_min,'name':name, 'gender':gender,'sns_id':sns_id,'keyword':keyword}) return render(request,"influencer_board.html",{'influencer':influencer}) Like the code above, I get 7 search condition from user. Also if user inputs less than 7 conditions, still I want to filter Database with those conditions. However, it keep making enter image description here this error. the function seems to work properly because url "http://127.0.0.1:8000/influencer_board/GET?sns_type=%EC%9D%B8%EC%8A%A4%ED%83%80%EA%B7%B8%EB%9E%A8&follower_num_min=18000&follower_num_max=&name=&gender=&sns_id=&keyword= containing condition what I submitted but making 404 error. How can I solve this problem -
Why I can't pass the widget attr to form constructor in UserChangeForm in Django?
I have a form which inherited from UserChangeForm. I have given the form field a bootstrap class but why when i rendered it out there was not bootstrap class inside that field? # my model class CustomUser(AbstractUser): teacher_type = models.ForeignKey(Type, on_delete=models.CASCADE, blank=True) # my form class EditUserForm(UserChangeForm): class Meta: model = CustomUser fields = ['teacher_type',...] def __init__(self, *args, **kwargs): super(EditUserForm, self).__init__(*args, **kwargs) self.fields['teacher_type'].widget.attrs.update({'class': 'form-control'}) # view def home(request): template_name = "app/home.html" eForm = acc_forms.EditUserForm(instance=request.user) return render(request, template_name, {'eForm': eForm}) # template {{eForm.teacher_type}} When I inspected in browser I saw like this <select name="teacher_type" id="id_teacher_type"> <option value="1">Full</option> <option value="2">Time</option> </select> it supposed to has class="form-control" inside the select tag but why it doesn't? -
How to redirect to the ?next=url instead of the success_url in a generic class based view in django?
I'd like to know how to redirect to the ?next=url instead of the success_url in a generic class based view in django. the view class CategoryUpdateView(UpdateView): model = Category template_name = "categories/category_edit.html" fields = ('name', 'description', 'image') success_url = 'category_list' in the template <a href="{% url 'category_edit' category.id %}?next={% url 'another_url' %}">Add</a> After updating the category, I want to be redirected to the nex value in the link instead of the success_url. How can I do that? Thanks. -
How many spiders can we run in a scrapy?
I want to run many spiders with my scrapy. Does that make the crawling process slower or is there any limit for spiders to run? Is running many unlimited spiders makes the process slow ? Is there anyone who is experienced with Scrapy? -
Excel to django (with Image)
Is it possible to import excel with image to django ? I dont have any error when it comes in foreignkey, i Just wonder if is it possible with image. resources.py class CityResource(resources.ModelResource): category = fields.Field(attribute='category', column_name='category', widget=ForeignKeyWidget(MunicipalityCategory)) class Meta: model = City models.py class City(models.Model): image = models.ImageField(upload_to='image', null=True, blank=True, default='default1.jpg') city = models.CharField(max_length=500, blank=True) category = models.ForeignKey(MunicipalityCategory, on_delete=models.SET_NULL, null=True, blank=True, verbose_name="Municipality") here is the sample excel file -
django, I want to change array[0] of __ proto__ to an object
console.log(test) (4) [{…}, {…}, {…}, {…}] 0: {d_code: 1, name: "test1", position: "RB", code_id: 1} 1: {d_code: 2, name: "test2", position: "LB", code_id: 2} 2: {d_code: 3, name: "test3", position: "ST", code_id: 2} 3: {d_code: 4, name: "test4", position: "RW", code_id: 1} length: 4 __proto__: Array(0) I would like to change the above code like below. {01: Array(3), 02: Array(3), 03: Array(3), reset: Array(0), test: Array(1)} 01: (3) [{…}, {…}, {…}] 02: (3) [{…}, {…}, {…}] 03: (3) [{…}, {…}, {…}] reset: [] test: [{…}] __proto__: Object view.py class testDoctor(generics.ListCreateAPIView): queryset = DoctorList.objects.all() serializer_class = DoctorListSerializer def list(self, request): test = DoctorList.objects.values() return Response(test) How do I change 'proto'? I want to change it in view. -
django.db.utils.IntegrityError: NOT NULL constraint failed; Django TestCase
I'm attempting to create a model instance of the Photo model and adding a User to it for the below TestCase. Upon running the test, I get an IntegrityError: django.db.utils.IntegrityError: NOT NULL constraint failed: photos_photo.photographer_id. Not sure why I'm getting the error when every other field is automatically populated? test_forms.py class RedundantImageUpload(TestCase): @classmethod def setUpTestData(cls): cls.test_image = SimpleUploadedFile( "test_image.jpg", content=b'''GIF87a\x01\x00\x01\x00\x80\x01\x00\x00\x00\x00ccc, \x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00''', content_type="text/html" ) user = User.objects.create_user("User") form = PhotoForm({'title': "Image Title"}, {'source': cls.test_image}) form.save(commit=False) form.photographer = user form.save() cls.submitted_form = PhotoForm( {"title": "Image Title"}, {"source": cls.test_image} ) def test_image_upload_path_exists(self): with self.assertRaisesMessage(ValidationError, "Image already uploaded: test_image.jpg"): self.submitted_form.errors forms.py from django import forms from django.core.exceptions import ValidationError from django.core.files.storage import get_storage_class from .models import Photo class PhotoForm(forms.ModelForm): title = forms.CharField(strip=False, validators=[validate_title]) def clean_source(self): stored_user_uploads = get_storage_class()() file_name = self.cleaned_data["source"].name if stored_user_uploads.exists(file_name): raise ValidationError(f"Image already uploaded: {file_name}") return self.cleaned_data["source"] class Meta: model = Photo fields = ["source", "title"] models.py from django.db import models from django.conf import settings # Create your models here. class Photo(models.Model): source = models.ImageField(upload_to='uploads/%Y/%m/%d/') title = models.CharField(max_length=50) upload_date = models.DateField(auto_now_add=True) likes = models.IntegerField(default=0) photographer = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE ) def __str__(self): return self.title -
Django forms.ModelForm slugfield db_index=True
I have a slug field in my Model with db_index true... When a new record is added through my form, i want slug field to be filled with slugified text that i have coded in my model save() method. However, this never happens as i am stuck at form field level validation. I have tried many options like clean(), clean_field() etc but all of them runs only after slug field has something entered. Please help class Student(models.Model): ... slug = models.SlugField(max_length=100, db_index=True) -
I am not able to understand this error: TypeError: cannot convert dictionary update sequence element #0 to a sequence
I am getting stuck with the new_entry functionality , This is a project in the crash course for python book , I have tried to verify my code a number of times not able to figure out why I get this error TypeError: cannot convert dictionary update sequence element #0 to a sequence , please help me to resolve this issue , thanks!! **views.py** from django.shortcuts import render from django.http import HttpResponseRedirect from django.urls import reverse from .models import Topic from .forms import TopicForm from .forms import EntryForm # Create your views here. def index(request): return render(request, 'learning_logs/index.html') def topics(request): # display all the topics topics = Topic.objects.order_by('date_added') context = {'topics': topics} return render(request, 'learning_logs/topics.html', context) def topic(request, topic_id): # display entries pertaining to a topic topic = Topic.objects.get(id=topic_id) entries = topic.entry_set.order_by('-date_added') context = {'topic': topic, 'entries': entries} return render(request, 'learning_logs/topic.html', context) def new_topic(request): # fill a new topic if request.method != 'POST': # No data submitted , create a blank form form = TopicForm() else: # post data submitted , process data form = TopicForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('learning_logs:topics')) context = {'form': form} return render(request, 'learning_logs/new_topic.html', context) def new_entry(request, topic_id): # Enter a new entry into any topic … -
How to user tesseract in django to convert image in form request?
[![enter image description here][1]][1] ** [1]: https://i.stack.imgur.com/oXYwf.png ** -
Django: I'm almost positive my code is right but it's not working
Using the URLconf defined in lecture3.urls, Django tried these URL patterns, in this order: admin/ hello/ newyear/ tasks/ [name='index'] tasks/ add [name='add'] The current path, tasks/add/, didn't match any of these. I'm become frustrated because I'm very confident that my code is right. Here is my urls.py code from tasks directory: from django.urls import path from . import views urlpatterns = [ path("", views.index, name="index"), path("add", views.add, name="add") ] Here is my urls.py code from project directory: urlpatterns = [ path('admin/', admin.site.urls), path('hello/', include("hello.urls")), path('newyear/', include("newyear.urls")), path('tasks/', include("tasks.urls")) ] I don't think anything is wrong with the project directory because tasks works but tasks/add does not. -
Django getting related objects from M2M
For example, I have three Models in django: class Car(models.Models): range = models.DecimalField() speed = models.DecimalField() def __str__(self): return self.speed class Group_of_Cars(models.Models): name = models.CharField() starting_city = models. CharField() car = models.ManyToManyField(Car) def __str__(self): return self.name class Arrival_time(models.Models): Location_of_ArrivalPoint = models.CharField() Last_known_location_of_CarGroup = models.CharField() Group_of_Cars = models.ForeignKey(Group_of_Cars) def function(self): "Get speed of the "Car" in "Group_of_Cars" def __str__(self): return self. Location_of_ArrivalPoint This is an example of what I want to do, not my actual models. The idea is for the user to input a series of values for the type of "Cars" such as speed and range. I'd like "Cars" to be selected when defining parameters for "a Group_of_Cars". What I'm not sure how to do is how to get the speed of the car, for the Group_of_Cars for which I need to calculate an arrival time (Group_of_Cars consists of one type of car and I'd like 'Arrival_time' to be its own table). Thank you for any input. -
'Next' page - Django
I'm building an ecommerce and there is the following scenario: user is on the cart page and clicks on the checkout page. Two things may happen: If he is not logged in, he is redirected to the login page and if he has an account, then he goes to checkout page: Cart page -> Checkout page -> Login page -> Checkout page It's working perfectly. If the user has not previosly registered, the user clicks on a link to the register page and then he goes to checkout page: Cart page -> Checkout page -> Login page -> Register page -> Checkout page It's not working. Inside the login page there is a link to go to the register page and I tried to attach the 'next' parameter but after the user has registered, he is not going to the checkout page: <a href="{% url 'account:register' %}?next={{ next }}">Do not have an account? Register now!</a> Any help? Do I need to code something inside the views.register? I thought only the link could help me! Thank you! -
How to update django model based form(having choices option) records by using html form
I am trying to update my pre existing model**(ShiftChange)** and in model based form i have used CHOICES as shown below. from django.db import models SHIFT_CHOICES = ( ('9.00-6.00','9.0-6.0'), ('6.30-3.30', '6.30-3.30'), ('12.30-3.30','12.30-3.30'), VENDOR_CHOICES = ( ('genesys','Genesys'), ('rmsi', 'RMSI'), ('tcs','TCS'), ('Cognizant', 'Cognizant'), ('CTS', 'CTS.') ) class ShiftChange(models.Model): ldap_id = models.CharField(max_length=64) Vendor_Company = models.CharField(max_length=64,choices=VENDOR_CHOICES,default='genesys') EmailID = models.EmailField(max_length=64,unique=True) Shift_timing = models.CharField(max_length=64,choices=SHIFT_CHOICES,default='General_Shift') Reason = models.TextField(max_length=256) # updated_time = models.DateTimeField(auto_now=True) And to update i'm using html based form because i wanted to display content to end user(end user will click on update button and if he want he Can change value by selecting dropdown button). I have implemented Create,Retrieve and delete view and it is working fine but update operation is not working.Please find the html code which i am using. update.html <p>User information Update Form</p> <!-- <h5><span3>Note:</span3> For timing please use this format e.g 1.Morning Shift = <span2>6.30-3.30</span2> <br>2.Second Shift= <span1>3.30-12.30</span1><br>3.general Shift =<span4>9.00-6.00</span4></h5>--> <form method="post" class="post-form"> {%csrf_token%} Ldap ID: <input type="text" name="ldap_id" value="{{oneuser.ldap_id}}"><br><br> Email ID: <input type="email" name="EmailID" value="{{oneuser.EmailID}}"><br><br> Company Name:<select name="Vendor_Company" <option value="{{oneuser.Vendor_Company}}">Genesys</option> <option value="{{oneuser.Vendor_Company}}">RMSI</option> <option value="{{oneuser.Vendor_Company}}">TCS</option> <option value="{{oneuser.Vendor_Company}}">Cognizant</option> <option value="{{oneuser.Vendor_Company}}">CTS</option></form></select> <br><br> Shift Timing:<select name="Shift_timing" choices=VENDOR_CHOICES <option value="{{oneuser.Shift_timing}}">9.00-6.00</option> <option value="{{oneuser.Shift_timing}}">6.30-3.30</option> <option value="{{oneuser.Shift_timing}}">12.30-3.30</option></div></select> <br><br> <!-- Shift Timing: <input type="text" name="Shift_timing" value="{{oneuser.Shift_timing}}"><br><br>--> Reason/justification for Change: …