django-forms

How to resolve AttributeError: 'ModelFormOptions' object has no attribute 'concrete_model' in Django

為{幸葍}努か 提交于 2020-12-27 05:37:24
问题 I have been trying to post data in my Django application using ajax post. The data is getting saved but in the terminal I am coming up against the following error: AttributeError: 'ModelFormOptions' object has no attribute 'concrete_model' Here are the relevant codes intended to achieve my goal: Views.py: def saveMaterial(request): if request.is_ajax and request.method == "POST": form = CreateMaterialForm(request.POST) # It's a ModelForm mat_bom_list = CreateBomMatListFormset(request.POST,

How to resolve AttributeError: 'ModelFormOptions' object has no attribute 'concrete_model' in Django

余生颓废 提交于 2020-12-27 05:36:48
问题 I have been trying to post data in my Django application using ajax post. The data is getting saved but in the terminal I am coming up against the following error: AttributeError: 'ModelFormOptions' object has no attribute 'concrete_model' Here are the relevant codes intended to achieve my goal: Views.py: def saveMaterial(request): if request.is_ajax and request.method == "POST": form = CreateMaterialForm(request.POST) # It's a ModelForm mat_bom_list = CreateBomMatListFormset(request.POST,

How to resolve AttributeError: 'ModelFormOptions' object has no attribute 'concrete_model' in Django

北城以北 提交于 2020-12-27 05:36:46
问题 I have been trying to post data in my Django application using ajax post. The data is getting saved but in the terminal I am coming up against the following error: AttributeError: 'ModelFormOptions' object has no attribute 'concrete_model' Here are the relevant codes intended to achieve my goal: Views.py: def saveMaterial(request): if request.is_ajax and request.method == "POST": form = CreateMaterialForm(request.POST) # It's a ModelForm mat_bom_list = CreateBomMatListFormset(request.POST,

How to resolve AttributeError: 'ModelFormOptions' object has no attribute 'concrete_model' in Django

余生颓废 提交于 2020-12-27 05:36:21
问题 I have been trying to post data in my Django application using ajax post. The data is getting saved but in the terminal I am coming up against the following error: AttributeError: 'ModelFormOptions' object has no attribute 'concrete_model' Here are the relevant codes intended to achieve my goal: Views.py: def saveMaterial(request): if request.is_ajax and request.method == "POST": form = CreateMaterialForm(request.POST) # It's a ModelForm mat_bom_list = CreateBomMatListFormset(request.POST,

Image uploaded but not saved in media and database Django

别来无恙 提交于 2020-12-26 12:05:55
问题 Am creating a settings page where the user should be able to chang there image and biodata. But only the biodata gets updated when I print the request.FILES.GET("profile_picture") it prints the name of the photo I uploaded. why is it not uploaded and saved to the database? Models.py from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): profile_pic = models.ImageField(upload_to="images/", null=True ,blank=True) bio = models.TextField(max

Image uploaded but not saved in media and database Django

不羁岁月 提交于 2020-12-26 12:04:59
问题 Am creating a settings page where the user should be able to chang there image and biodata. But only the biodata gets updated when I print the request.FILES.GET("profile_picture") it prints the name of the photo I uploaded. why is it not uploaded and saved to the database? Models.py from django.db import models from django.contrib.auth.models import AbstractUser class User(AbstractUser): profile_pic = models.ImageField(upload_to="images/", null=True ,blank=True) bio = models.TextField(max

Inlineformset_factory saving parent without child and not displaying validation errors if child is none

倾然丶 夕夏残阳落幕 提交于 2020-12-15 05:19:09
问题 I am having 2 issues, one if you submit and click back and then submit again it duplicates the instance in the database - in this case Household. In addition it is saving the parent 'Household' without the child 'Applicants' despite me setting min_num=1 can someone point me in the right direction to resolve this issue. Many thanks in advance class Application(models.Model): name = models.CharField(max_length=100, blank=True, null=True) application_no = models.CharField(max_length=100, unique

in my django project i get a 'ModelFormOptions' object has no attribute 'concrete_model' error

五迷三道 提交于 2020-12-13 04:01:13
问题 I have added a form for my django rest project. However, I keep getting a 'ModelFormOptions' object has no attribute 'concrete_model' error. In my User class I have added a new field 'password' and I was trying to create a form. and call the serializer upon it. My Model: class User(models.Model): gender = models.CharField(max_length=10, blank=False, choices=GENDER) first_name = models.CharField(max_length=20, blank=False) last_name = models.CharField(max_length=20, blank=False) position =

in my django project i get a 'ModelFormOptions' object has no attribute 'concrete_model' error

孤街醉人 提交于 2020-12-13 04:00:45
问题 I have added a form for my django rest project. However, I keep getting a 'ModelFormOptions' object has no attribute 'concrete_model' error. In my User class I have added a new field 'password' and I was trying to create a form. and call the serializer upon it. My Model: class User(models.Model): gender = models.CharField(max_length=10, blank=False, choices=GENDER) first_name = models.CharField(max_length=20, blank=False) last_name = models.CharField(max_length=20, blank=False) position =

Dropdown select option to filter a Django list

…衆ロ難τιáo~ 提交于 2020-12-12 01:47:27
问题 Coming from Angular, this was easy to do, but I am not sure where to begin on creating a dropdown form that will filter from a list of objects. Basically, I have the code below, that will pull in and display all real estate listings; I would like to create a dropdown that will have 2 selections, 'Featured' and 'New Listing' and when a user selects one, the list will filter out and display only those listings that match. Thank you for your help. Here is my model from django.db import models