django-forms

Not able to update an item in Django

孤街浪徒 提交于 2021-01-07 01:43:48
问题 I am trying to update the Bar Information for users by getting their details and setting the Bar instance. But every time I click on the link on my dashboard it redirects me to the dashboard which is what I used for the else statement if it is not a post method. view.py def UpdateUserBar(request): user = request.user.id bar = Bar.objects.get(user_id=user) form = UpdateBar(instance=bar) if request.method == 'POST': form = UpdateBar(request.POST,request.FILES, instance=bar) if form.is_valid():

Using formsets for my fileupload does not work when doing an update class based view only on create in django

倖福魔咒の 提交于 2021-01-06 03:51:51
问题 I have used as many examples online as I could cobble together in an attempt to get my two simple models to have the ability to do an inline formset allowing me to add many files to a technial drawing. This is not working, I can only add one file for the Create and the update only updates the Technical_Entry model, not a file...which in of itself acts funny. The UI ona create shows one spot to add a file, then save the entire record and its child record. That works. The update, the UI shows

Using formsets for my fileupload does not work when doing an update class based view only on create in django

若如初见. 提交于 2021-01-06 03:50:12
问题 I have used as many examples online as I could cobble together in an attempt to get my two simple models to have the ability to do an inline formset allowing me to add many files to a technial drawing. This is not working, I can only add one file for the Create and the update only updates the Technical_Entry model, not a file...which in of itself acts funny. The UI ona create shows one spot to add a file, then save the entire record and its child record. That works. The update, the UI shows

Using formsets for my fileupload does not work when doing an update class based view only on create in django

岁酱吖の 提交于 2021-01-06 03:48:12
问题 I have used as many examples online as I could cobble together in an attempt to get my two simple models to have the ability to do an inline formset allowing me to add many files to a technial drawing. This is not working, I can only add one file for the Create and the update only updates the Technical_Entry model, not a file...which in of itself acts funny. The UI ona create shows one spot to add a file, then save the entire record and its child record. That works. The update, the UI shows

How to use RelatedFieldWidgetWrapper in django 3

一笑奈何 提交于 2021-01-06 02:46:34
问题 What should I put in rel and admin site? This is the field in my form: tutor_temporal = forms.ModelChoiceField(queryset=Tutor_temporal.objects.all(),label='Tutor No Registrado', required=False, widget=RelatedFieldWidgetWrapper(widget=forms.Select(attrs={'class': 'input is-small is-rounded '}),rel=Tutor_temporal._meta.get_field('id').rel,admin_site= admin_site)) The problem is that when I try that, throws this AttributeError: 'AutoField' object has no attribute 'rel', because apparently is

How to use RelatedFieldWidgetWrapper in django 3

放肆的年华 提交于 2021-01-06 02:46:30
问题 What should I put in rel and admin site? This is the field in my form: tutor_temporal = forms.ModelChoiceField(queryset=Tutor_temporal.objects.all(),label='Tutor No Registrado', required=False, widget=RelatedFieldWidgetWrapper(widget=forms.Select(attrs={'class': 'input is-small is-rounded '}),rel=Tutor_temporal._meta.get_field('id').rel,admin_site= admin_site)) The problem is that when I try that, throws this AttributeError: 'AutoField' object has no attribute 'rel', because apparently is

'module' object is not iterable when running django website to the server

不想你离开。 提交于 2021-01-04 12:31:45
问题 i wanted to run my django website to their server so i open cmd and go to manage.py directory : C:\Users\computer house>cd desktop/newproject then i type this code : python manage.py runserver but i got this error : Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03BE5A08> Traceback (most recent call last): File "C:\Users\computer house\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 542, in url_patterns iter

'module' object is not iterable when running django website to the server

℡╲_俬逩灬. 提交于 2021-01-04 12:31:32
问题 i wanted to run my django website to their server so i open cmd and go to manage.py directory : C:\Users\computer house>cd desktop/newproject then i type this code : python manage.py runserver but i got this error : Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03BE5A08> Traceback (most recent call last): File "C:\Users\computer house\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 542, in url_patterns iter

django Javascript dropdown

耗尽温柔 提交于 2021-01-04 09:11:17
问题 Am new to programming in Python and Javascript and I have been learning Python for few months now and love it. I have been playing with django which is cool I was wondering how I can make this model work with a Iavascript. I'll like someone to explain as much as the code involved as I just what to have a full understanding of the process from django to Javascript. I want to dynamically is CarModel.objects.filter(make ='somename') or just 'somename'. This is a test model am using since its

Django ForeignKey field required despite blank=True and null=True

我只是一个虾纸丫 提交于 2021-01-04 05:31:42
问题 I am using Django REST Framework and I have a MyNodel with a related MyOtherModel in a many-to-one relationship: models.ForeignKey(MyModel, related_name="my_other_models", blank=True, null=True) Although blank=True, null=True , when I try to post a MyModel JSON without a my_other_models field I get a "this field is required" error. 回答1: In your serializer, you need to add required=False . field = MyModelSerializer(required=False) 来源: https://stackoverflow.com/questions/40237969/django