I know, but i tried with Crispy forms and i couldn’t get the layout right. I’d much prefer to let Django render the forms for me if i could get this styling right. Although i have found a good video on this.
For some reason when i was trying to apply the css styles to crispy it wouldn’t work the same as when i apply directly in html.
w.r.t the changes.
do i need to do this Remove the project_name field from the Form class Meta. (Yes, that means replacing the __all__ with the list of fields you want editable.)
as well as one of these
Change the attribute of this field from readonly to disabled
Change this from an input field to just a block of text
This is not the completed form, but is this correct way to do it? As i still want to use bootstrap to style? and i know i have correct the {{ form.subject.erros }}
One minor question - you’re trying to render a field named ckeditor_classic. Unless your form field is named that, that wouldn’t be the correct reference.
(I’m guessing that you’re trying to use the CKeditor on that field. The reference should be to the form field - the editor is the widget being used. If my guess is wrong and you do have a FormField named ckeditor, then you’re ok.)
I’ve gone back through all of my forms and recreated using ModelForms. Its so much quicker and easier. Thanks for pointing me in the right direction.
I am back on the fundamentals update form. The redirect is working now so if no records exist it will take me to the add page, otherwise to the update page, but for some reason the update view isn’t showing the existing values?
Im using {{ form.project_tier_entry_level }}
My view is
def update_fundamentals_view(request, project_id):
project= Project.objects.get(pk=project_id)
form = FundamentalsForm(request.POST or None, instance=project)
if form.is_valid():
form.save()
return redirect('dashboard.html')
return render(request, 'pages/update_fundamentals.html', {'project': project, "form": form})
I’ve made sure i’ve removed the project_name from the Meta which has worked on all my other forms. But some reason this one doesn’t see to work and it wont update the values if i make a change.
Sorry to ask for help again, but could you let me know what i am doing wrong?
And also
within my forms i have a select feild. Where the user can choose Yes or No but i’m not sure how i pass in the choices.
Thanks again ken. For some reason the doc i was reading it looked like i was meant to apply the choices to the form not the models. This is working now
And for my very last question…
Within my view i want present data on the screens that is only relevent to the project.
for example, i have loads of events all relating to different projects. When i load the project details page i’d like to only show events that are related to that project ?
I’m sorry, I’m kinda lost here. What is this “Event” object? What objects are referring to it?
I can’t find an Event model in what you’ve posted so far or what it’s related to or what’s related to it.
I’m try to figure out a way to only show events relating to that project using this query? events = Event.objects.get(pk=project_id).event_list = Event.objects.filter(event_date__gte=today).order_by('event_date')