Category : django-views

The entire error is django.db.utils.IntegrityError: (1062, "Duplicate entry ‘6’ for key ‘auth_user.PRIMARY’") I’m getting this error when using Django to create a sign-up page with raw SQL queries. It comes up when trying to insert values into the ‘auth_user’ table that is created by Django. The model in question is ‘User’ from ‘django.contrib.auth.models.’ and I’m ..

Read more

What is the difference between request.POST.get and request.GET.get in Django. I understand that when you use request.POST.get, you are trying to get data from front-end. In what situations will you require request.GET.get I know the difference between POST and GET, but in this context are there any additional differences? Source: Python..

Read more

I have been asked to perform a simple task where I can do the following User can register and login as a doctor or patient Doctor has many clinics. clinic include (name, price, date, start_time, end_time) Patients can reserve doctor clinics Display doctors and patients reservations Use Python, django, django rest framework and relational database ..

Read more

This is challenge page When we go to ide page using the challenge button on the bottom and then click on submit button there then data is getting stored in database and function is running fine. But when I click on accept button and go to ide page and then click submit then data is ..

Read more

I have had headache over why my import does not include the manytomany fields with it, instead it shows none upon import .Here is my resources.py class ImportStudentsResource(resources.ModelResource): klass = fields.Field(widget= ManyToManyWidget(Klass)) stream = fields.Field(widget=ManyToManyWidget(Stream)) gender__name = fields.Field(attribute = ‘gender’,column_name=’gender’, widget=ForeignKeyWidget(Gender, ‘name’)) school__name = fields.Field(attribute = ‘school’,column_name=’school’, widget=ForeignKeyWidget(School, ‘name’)) class Meta: model = Students fields ..

Read more

This is the error I am getting when I click on submit button from django.conf.urls import url,include from django.urls import path,re_path from . import views app_name = ‘challengeide’ urlpatterns = [ path(‘challengeide/<int:sr_no>’, views.show, name=’show’), url(‘challengeide/’, views.qtn,name=’test’), path(‘#’, views.submit_button,name=’submit_button’), url(‘challenge/’, views.challengeide, name=’challengeide’), ] This is my URL code <form method="POST" action="{% url ‘challengeide:submit_button’ %}" name="mybtn123">{% csrf_token ..

Read more

I run the test via Client(). post, but request.POST does not contain the passed dictionary test.py from django.test import TestCase from django.test.client import Client class AccountTests(TestCase): def setUp(self): self.email = ‘[email protected]/com’ self.name = ‘John’ self.mobile = "+799999999" def test_user_login(self): c = Client() response = c.post(‘/login-otp/’, {’email’: self.email, ‘name’: self.name, ‘mobile’: self.mobile}, follow=True) views.py def login_otp(request): ..

Read more

<form action=""> Sort By: <select name="ordering"> <option value="price">Price:Highest to Lowest</option> <option value="-price">Price:Lowest to Highest</option> </select> <button type="submit">submit</button> <form> trying to submit these values in a get request. Tried doing a get_ordering function on a class List View: class GarageListView(ListView): model = Vehicles template_name = ‘garage/garage.html’ context_object_name = ‘cars’ ordering = [‘-price’] def get_context_data(self, **kwargs): context ..

Read more

I am attempting to create an auction listing with categories that are linked to it. The listing is its own model while the category is a model which i foreign key to as shown here class Categories(models.Model): category = models.CharField(max_length=32) def __str__(self): return self.category class Listings(models.Model): owner = models.CharField(max_length = 20) title = models.CharField(max_length = ..

Read more