you're welcome, Mayank!
Adding initial to your ModelChoiceField definition should give you the
preselection.
self.fields['project'] = forms.ModelChoiceField(
initial=projectid,
queryset=Project.objects.filter(id=projectid)
)
On Sun, Apr 12, 2020 at 1
Cool, thanks Antje.
Seems it is working now, the only thing is in Drop-down i will have the
Project Name for which the URL is rest of the PRojects are removed from
drop down.
Now will work to have pre-selected. As of now it will default display as
-- with only one required project name.
Thank
Hi, I think in your view modulesView() you need to pass the project id to
ModuleForm:
..
else :
form = ModuleForm(projectid)
..
and then you need to overwrite the constructor of ModuleForm by adding an
__init__ function:
def __init__(self, projectid=None, *args, **kwargs):
super(Mod
Hi All,
I am facing an issue, to pre-populate the Foreign Key on the web page.
Actually i have two models Projects and Modules.
To create a Module, one has to select the Project and go to Module page for
create it, but there the Project is not populated.
Below are the details... Please guide me
4 matches
Mail list logo