Questions tagged [django-forms]
Specific questions related to forms within the Django web framework.
18,839
questions
0
votes
0
answers
4
views
how to using cookies to get data from local storage - DJANGO
i was new in django. i want to get my data back from local storage, but i don't know how to get it. can someone explain me? my application using form NOT MODELS.
the application made using django, i ...
0
votes
0
answers
10
views
showing date from db in html date in django
How can i show date from db in django html template with input type date.
As You can see if we use input type 'date'. we can see the below widget showing in html. But if i want to it to show date ...
0
votes
1
answer
20
views
Django Form "'ForwardManyToOneDescriptor' object has no attribute 'all'"
Hey so I'm having quite some problems. In effect trying to add a form to a home-page with options for a user to select based on a DB object. Then once submitted the page will refresh, and the form can ...
1
vote
0
answers
17
views
Django CSRF not working on SSL(HTTPS), but working on local(linux), tried all things
Following is the Error i get :
403 : CSRF verification failed. Request aborted.
When Debug = True :
Reason given for failure:
Origin checking failed - https://example.com does not match any trusted ...
-1
votes
0
answers
20
views
The current path, register/, didn’t match any of these
Page not found (404)
Request Method: POST
Request URL: http://127.0.0.1:8000/register/
Using the URLconf defined in floshop.urls, Django tried these URL patterns, in this order:
admin/
[name='demo']...
0
votes
0
answers
7
views
How can I remove colon from {{field.lable_tag}}?
I want to remove the colon from field.lable_tag how can I do this
Here is my code
<div class="row">
{% for field in user_form %}
<div class=&...
0
votes
0
answers
7
views
Parent field name in not rendering in django while adding new data
I am working on one project where i am facing issue in field value rendering. I added one product and now i want to add the record of it means for how much rupee it cost etc. But the problem now is ...
0
votes
1
answer
21
views
designating/connecting a model to a user - django
Im trying to make a social media site and wanted to connect a user to work experience.
My current form is
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth....
0
votes
0
answers
12
views
How to use formset to get data from localstorage - DJANGO
i want to get data from local storage (because i don't use database), i use form NOT MODALS.
views.py :
def homepage(request):
form_class = Audio_store
form = form_class(request.POST or None)
...
0
votes
0
answers
15
views
how to pass file from local storage to html - django
so i want get my file from local storage to show in html using django. but i don't know how to get it. the file is audio mp3. i was using form NOT MODALS. i need reference of example code. if you need ...
0
votes
1
answer
27
views
deleting a post in django
hi ive read some of similar posts but couldn't find same problem.
i wrote a code to delete post and when i press delete it shows 404 error but when back to home post is still there
views:
def ...
1
vote
0
answers
30
views
when there is no Overlapping i am getting overlapping validation error
With thins code i can check overlappig but the problem when overlapping is not happening i am getting overlapping validation error. How i can solve this error.
form.py
for i in range(count):
...
0
votes
0
answers
26
views
form.is_valid() always returns False and form is not valid
i have a simple form for adding comments and in views i am checking it for validity. But it always returns False and i get error404 according to my code. I have several assumption, but it didn`t work. ...
1
vote
1
answer
36
views
How to use model's field's distinct values as select field's choices
My model looks like this.
class Student(models.Model):
user = models.OneToOneField(CustomUser, on_delete=models.CASCADE)
roll_no = models.CharField(max_length=32)
course = models.CharField(...
0
votes
1
answer
16
views
Django form fields not rendering in template
I am trying to render a simple Django Form on my index page. I have stripped it way back in an attempt to get it to work.
I can display other context elements when passing them in, and I know an ...
1
vote
1
answer
21
views
user login changes automatically in django
whenever I login in my admin panel, automatically my user site login changes to admin in django
I am using django's AuthenticationForm
from django.contrib.auth.forms import AuthenticationForm
this is ...
0
votes
2
answers
32
views
Django set initial pre-filled field value
I have two models:
class Budget(models.Model):
name = models.CharField(max_length=25)
quantity = models.DecimalField(max_digits=10, decimal_places=2)
date = models.DateField(default=now)
...
0
votes
1
answer
22
views
How to can change the format of date from year-month-date to date-month-year in Django Admin interface?
Am new in Django so any help will be appreciated,
I have a model that contain 3 fields , one of them is date , i want to change the display of date in Django Admin(now it's 2022-05-20 but i want it to ...
1
vote
1
answer
48
views
Render Form Elements Individually in Django
I'm trying to figure out how to render my form elements individually, since I think it's the best way for my file as I have several parent CSS classes.
I want to replace pretty much every label and ...
0
votes
0
answers
17
views
+100
How to style mixed django form better
I have theese two forms:
class InitialForm(Form):
trn = IntegerField(widget=NumberInput, required = False)
klient = ChoiceField(choices=KLIENTS, required = False)
class SecondForm(Form):
...
0
votes
0
answers
11
views
How can I filter a modelformset_factory?
I have been coding a personal project in which several user can post educational videos (each video has a language, a foreignkey). I tried to implement a function in which a user add a word to a video ...
0
votes
0
answers
13
views
how to get data (mp3) from local storage and can be played in html - DJANGO FORMS
i was new in django. i want to get my mp3 song what was i uploaded it and can be pass to html. how to get the song and return it? i build it with FORM not models.
forms.py :
from django import forms
...
0
votes
0
answers
7
views
change or set a spiecific field of an existing model by user
my first issue is that this model needs to be create on admin panel for each user, but i want it to create an account for each user who register auotomaticly..
but my main question is how to change ...
0
votes
1
answer
43
views
Are there any fields in a django model that the user doesn't fill in but the computer does? (CS50 Project 2)
I have created a django form that creates and saves comments to listings. I want the comment to only save to the listing that it is commented to (right now it saves to all the listings). Is there any ...
-1
votes
0
answers
18
views
How can i save subcategory to my database in django
I am having trouble in saving subcategory data as it is dependent dropdown so in value i need to add category id but if i add category_id the subcategory having id of that category_id is being saved ...
1
vote
1
answer
16
views
Django Formset - each form with different initial value from M2M-through relationship
I have to models which are connected by a M2M-Field realized by another Class ComponentInModule, so that I can add there the extra information, how often a component is in the module.
class Module(...
0
votes
1
answer
46
views
Passing Data into Forms Django
Hypothetically;
I have a simple system that has a list of choices on a screen. Each item has a button so you can add multiple supplementary items/information alongside the item selected but not change ...
0
votes
1
answer
17
views
Failure to save certain attributes from ModelForm to django database (Logic error)
I have a ModelForm called ListingForm. It takes data from a user but I have stopped some of the model attributes from appearing in this form as I want to feed data to those myself. I have put print ...
0
votes
0
answers
11
views
how to make audio player from local storage with DJANGO FORMS
so i want make audio player, the song it's form my local storage. i was new in django, so i have no idea to make it. i want make it using FORMS not models.
here's my form.py :
from django import forms
...
1
vote
3
answers
20
views
form doesn't appear - UnboundLocalError at / DJANGO FORM
my form doesn't appear at my website and its error now. this is my error message :
UnboundLocalError at / local variable 'form' referenced before
assignment Request Method: GET Request URL: ...
0
votes
2
answers
56
views
Django: Redirect from FormView to DetailsView upon submitting the form
Relevant FormView:
class addrecipe(FormView):
form_class = AddRecipeForm
model = Recipe
template_name = 'recipebook/addrecipe.html'
fields = '__all__'
extra_context = {
'recipe_list': Recipe....
1
vote
1
answer
19
views
Check Overlapping intervals integerfield validation django python
can anyone help me how to solve overlapping validation in django
moldel.py
start = IntegerRangeField()
end = IntegerRangeField()
form.py
class CheckForm(forms.ModelForm): def clean(self):
start=...
0
votes
0
answers
19
views
django edit and update multiple object of one form
I have one form for add information to table and in craete view I can copy the form as much I want and insert it to the table like this:
my form and can copy them
but when I want to edit and update ...
-1
votes
1
answer
18
views
Showing many to many field as checkbox in template with createview [duplicate]
View:
class addrecipe(CreateView):
model = Recipe
template_name = 'recipebook/addrecipe.html'
fields = '__all__'
Model:
class Recipe(models.Model):
name = models.CharField(max_length=50)
...
0
votes
1
answer
22
views
form doesn't appear and how to remove <li> in django forms
i have problem. why my form doesn't show except i clicked submit button. is that any problem with my code?
here's my html code :
<form method="POST" enctype="multipart/form-data"...
0
votes
1
answer
25
views
I cannot load the image in my template, I tried changing all upload file location and everything else and its the same with category field
models.py
class product(models.Model):
categoryChoices=[('food','Food'),('clothing','Clothing'),('books','Books'),('furniture','Furniture'),('others','Others')]
product_name=models.CharField(...
0
votes
0
answers
21
views
Save many-to-many relationship after use the add() method on the field to add a record
I have models Book and I want to save new record this book after every update information about this book (duplicate information). It works good, but I don't know how to store many-to-many ...
0
votes
0
answers
13
views
How can I make my form page resposive design in Django?
I have a form page with Django 1.11.10. I want to desing it responsive for all screen sizes. In phones and tabletes I want to not need to zoom in.
Here is my html :
{% extends 'base.html' %}
{% load ...
0
votes
1
answer
48
views
Django: Point not passing from ModelForm clean to Model clean
I have an Occurrence model that I am putting as TabularInline on the admin page of another model. It has a PointField and a PolygonField, of which at least one must exist.
Here is part of the model:
...
0
votes
1
answer
41
views
Selectfield not showing options
I have a field in my modelform where the user can choose the mealtype. But the form input does not work, when I click it, nothing happens. What I want to happen is to display a dropdown with the ...
0
votes
1
answer
29
views
Why am I only getting default values when adding something to my database? (Django)
I'm trying to add tasks to my todo list. All of my added tasks are listed on the homepage (home.html) but whenever I try to add something it always sets my input to default (I added a picture at the ...
0
votes
0
answers
17
views
Django forms integration with legacy UI component library
I'm working on a Django project and would like to incorporate a proprietary UI component library that my company created into my application. The library has CSS utility classes for positioning, font, ...
-1
votes
0
answers
20
views
'NoneType' object is not subscriptable Rasise Validation Error if same name filled twice Django
I am trying to create a validation that will raise validation error if same name filled twice , but i am getting 'NoneType' object is not subscriptable error.
Model.py
fruit_name = models....
1
vote
0
answers
16
views
How can I write text under the label of my Django model form?
I am working on a register form on Django. Under my TextFields label I want to write "For multiple purchased units any of the item barcode works." Like below:
image
How can I add this to my ...
0
votes
1
answer
18
views
In Django forms I can't use regex validators
Good day. I want to use regex validator for my full_name field in Django 1.11.10. But when I run the below code it doesn't work. How can I fix it?
forms.py
class CustomerForm(forms.ModelForm):
...
0
votes
0
answers
11
views
Django - do not validate the second form
I have this code snippet in template.
<form method="POST" novalidate>
{% csrf_token %}
{{ form }}
{{ form2.as_p }}
<button type="submit" ...
0
votes
0
answers
20
views
Is there a way to modify the common behavior of Django forms?
I am trying to prevent my forms from always redirecting me to another template or reload the page once data is submitted, but am not exactly sure how to do it
Take a look at this image as an example
...
0
votes
0
answers
14
views
Changing default dashes of select field in Django forms, empty_label attribute is working for ForeignKey field but not for CharField
I'm trying to set up a form that allows a tattoo shop to book consultations. There are 2 select fields: select an artist and select a tattoo style. Instead of the default first option of the select ...
0
votes
0
answers
9
views
Problems with Django forms and Bootstrap
Im making a form in django, were I style it with Widgets:
from django.forms import ModelForm, TextInput, EmailInput, NumberInput
from .models import *
class DateInput(forms.DateInput):
...
0
votes
0
answers
12
views
How to disable the whole screen along with a loader (that shows something is processing) rather than disabling button on clicking submit?
I want to disable a whole screen, rather than just a button on clicking submit button, I also want a loader on screen to show that something is under process.
Here is my code
It is not working ...