Category : django-views

So basically I want to be able to prefill a Charfield form field with a certain value in the init method. Here is my form: class UpdateForm(forms.ModelForm): #_____________________________________________________________ def __init__(self, *args, **kwargs): super(UpdateForm, self).__init__(*args, **kwargs) self.fields[‘form_field’].initial = "How are you doing?" self.fields[‘form_field’].widget = self.fields[‘form_field’].hidden_widget() #_____________________________________________________________ class Meta: model = form_model fields = ( ‘form_field’, ) ..

Read more

I am making an Auction website using Django. When is use Migrate command it gives an error "ValueError: Field ‘bid’ expected a number but got " ". The code of the models.py file is: from django.contrib.auth.models import AbstractUser from django.db import models from django.db.models.base import Model from django.db.models.deletion import CASCADE from django.db.models.fields import CharField from ..

Read more

I ask for theoretical advice/guide how to apporach this problem. I have build a djnago database of crypto currencys where clients can add their historical transactions. I also use an API which gets real time crypto prices in json format. I would like to show the price/value difference between their historical transactions and the current ..

Read more

I have authorized.html page which needs a admin login to view so when I go to http://127.0.0.1:8000/authorized/ it takes me to http://127.0.0.1:8000/admin/login/?next=/admin/%3Fnext%3D/authorized/, which is expected. I used the below code in view.py file to built this functionality: class authorizedView(LoginRequiredMixin,TemplateView): template_name = ‘home/authorized.html’ login_url = ‘/admin/’ But after the successful admin login it didn’t take me ..

Read more