When we post, dropdown bar shows available uers, anyone can pick anyone.
Because frontend knows user.id and who logged in, but backend doesn't know it yet.
in order to forms.py to go to the frontend and figure out the user and comeback
no more select drowdown bar, change it to testinput and add id in the widgets
forms.py
class PostForm(forms.ModelForm): #inherit forms. ModelForm allows us to create form fields for our Post model.
class Meta:
model = Post
fields = ('title', 'title_tag', 'author', 'category', 'body')
#add styling: widget dictionary
widgets = {
'author': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'username', 'id': 'cats'} ),}
view the source code to identify id
since we added id as 'users_id' in the forms.py, it's now showing it in the html code.
Add JS script down below.
variable 'name'
user.id, user.username, user.first_name, etc
<script>
var name = "{{ user.id }}";
document.getElementById("users_id").value
= name;
</script>
Now it's showing user_id in the form.
we want input box to be value not a placeholder. Leave value as empty as JS will put the value in it.
'author': forms.TextInput(attrs={'class': 'form-control','value': '', 'id': 'users_id'} ),
make the field hidden so user cannot edit their username.
'author': forms.TextInput(attrs={'class': 'form-control','value': '', 'id': 'users_id', 'type':'hidden'} ),
value is empty but JS put id in there. We just can't see it.
Make tremendous you could pay whoever you're borrowing from decrease returned in a sincere quantity of time, without the troubles.
http://riyasingh.in/
http://www.komalsharma.in/
http://www.shilpiescort.in/
http://www.bangaloreescortagency.co.in/
http://www.blrescorts.in/
Very terrific article precious creator, I significantly liked I want to percentage this publish to my Facebook or myspace or Twitter. Thanks
http://www.hotbangaloreescorts.in/
http://www.perfectbabes.in/
http://www.callgirlsinbengaluru.com/
http://www.bangalorehotcallgirls.in/
http://www.bangalorehotcallgirls.com/
http://www.escortsbangalore.co.in/
I virtually bear in mind you've got were given stated a few very thrilling info, thankyou for the position up.
http://www.bangalorehotescorts.co.in/
http://www.bangaloreescortsgirls.in/
http://www.bangaloreprincess.in/
http://www.miky.in/
http://www.bangalore-escort.org/
KD SOFTWARE is a software and website design in Agra firm with offices in AGRA, Mainpuri, Mathura, Firozabad, Etah, and Shahjahanpur, Uttar Pradesh. KD SOFTWARE developed customized software based on platforms and technologies such. Net, PHP, HTML, JavaScript, and CSS and in compliance with market demands. The developers at Team KD SOFTWARE have experience creating complicated, sizable websites with a range of design approaches. KD SOFTWARE provides a wide range of services, including website design and development. PHP programming, software development, digital marketing, SEO, and net programming in Agra
https://kdsoftware.in
https://websitedesigningnoida.com
I hope you'll write some very good stuff soon.
https://ishadas.com/
https://sweetysharma.in/
https://preetykaur.com/
https://diyaoswal.com/
https://snehaoswal.com
I couldn't observe you're completely positioned up as I get bored very short however notable to see a person chatting about gadgets like this.
http://bangaloreescortsgirls.com/
http://www.bangalorecallgirls.in/
http://www.kalpanachawla.in/
http://www.priyasenbangaloreescorts.co.in/
http://www.thebangaloreescorts.com/
http://www.priyaoberoi.in/