django-views

Django cannot add null data from url to database

Django cannot add null data from url to database Question: I create model like this which it should recieve null value without error class ReceiveData(models.Model): api_key=models.ForeignKey(DeviceKey,on_delete=models.CASCADE) field1= models.FloatField(null=True) field2= models.FloatField(null=True) field3= models.FloatField(null=True) I use is_float to check type of data before add to database. def is_float(element: any) -> bool: #If you expect None to be …

Total answers: 1

Better alternative for passing complex object from template to views.py on POST call

Better alternative for passing complex object from template to views.py on POST call Question: In views.py on GET call, I create a random list of questions (its a complex object, list of dictionaries) and I send that list to the template (HTML) file using return render(request, ‘some_page.html’, args). I show one question at a time …

Total answers: 1

Django Not Found: /media/ , GET /media/ HTTP/1.1" 404 2679

Django Not Found: /media/ , GET /media/ HTTP/1.1" 404 2679 Question: I am currently building a project which i have to use media. Since i have used media before i copy pasted everyting from my other project and altough the original is working my current project is not. I can upload and select fotos thru …

Total answers: 2

ColumnFormFormSet objects has no attribute ‘save’

ColumnFormFormSet objects has no attribute ‘save’ Question: I want to create 30 fields in the design.html, after I successfully added that using django formset When I try to submit the form instead of saving the field to the database, it throws me an error saying ‘ColumnFormFormSet’ object has no attribute ‘save’ how can I solve …

Total answers: 1

How to hash stored passwords in mysql using pbkdf2_sha256 using Django

How to hash stored passwords in mysql using pbkdf2_sha256 using Django Question: I have list of user passwords stored as plain text. I think I need a script to run over the stored passwords and hash them. I’m new to Django and not sure where to start or how. I created login and creating accounts …

Total answers: 1

rtsp stream with django

rtsp stream with django Question: I’m trying to put a url based on my views.py but it returns the error: Reverse for ‘transmition’ not found. ‘transmition’ is not a valid view function or pattern name. project urls.py: from django.contrib import admin from django.urls import path, include from django.conf.urls.static import static from django.conf import settings from …

Total answers: 1

Filter queryset based on related object's field value

Filter queryset based on related object's field value Question: I have two models: class PartUse(models.Model): … imported = models.BooleanField() class PartReturn(models.Model): partuse = models.ForeignKey(PartUse) … imported = models.BooleanField() class PartUseListView(ListView): model = PartUse def get_queryset(self): if self.request.GET.get(‘show_imported’, None): qs = self.model.objects.all() else: qs = self.model.objects.filter(Exists(PartReturn.objects.filter( imported=False, id__in=OuterRef("partreturn")))) return qs I want to filter QuerySet for …

Total answers: 1

How to save fingerprint data in django

How to save fingerprint data in django Question: So I have a project where I have a model called Beneficiary where I need to store the fingerprint. This is the model: class Beneficiary(models.Model): image=models.ImageField(upload_to=’home/images/’,blank=True,null=True) name = models.CharField(max_length=200) gender=models.CharField(max_length=6,choices=GENDER_CHOICES,default=’male’) dob=models.DateField() registration_date=models.DateField() I want to save the fingerprints of the beneficiaries in the model. I am using …

Total answers: 1

django UniqueConstraint violation_error_message message not handled

django UniqueConstraint violation_error_message message not handled Question: I have this model: class DataMapping(models.Model): company = models.ForeignKey(Company, on_delete=models.CASCADE) location = models.ForeignKey(Location, null=True, blank=True, on_delete=models.CASCADE) department = models.ForeignKey(LocationDepartment, null=True, blank=True, on_delete=models.CASCADE) catagory = models.ForeignKey(CompanyCategory, on_delete=models.CASCADE) reason = models.ForeignKey(ReasonForProcessing, on_delete=models.CASCADE) class Meta: constraints = [ UniqueConstraint( name=’unique_data_map’, fields=[‘company’, ‘location’, ‘department’, ‘catagory’, ‘reason’], condition=Q(location__isnull=False), violation_error_message="This data map has already …

Total answers: 2