Inclusion Criteria:  Male or female aged above or equal to 18 years at the time of signing informed consent. Diagnosed with type 2 diabetes mellitus (T2D) greater than or equal to 180 days prior to the day of screening. Glycated haemoglobin (HbA1c) from 7.0-10.0% (53.0 85.8 mmol/mol) both inclusive at screening confirmed by central laboratory analysis. Treated with once daily basal insulin (neutral protamine hagedorn insulin, insulin degludec, insulin detemir, insulin glargine 100 units/mL, or insulin glargine 300 units/mL) and 2-4 daily injections of bolus insulin analog (insulin aspart, faster acting insulin aspart, insulin lispro, insulin glulisine) greater than or equal to 90 days prior to the day of screening with or without any of the following anti-diabetic drugs/regimens with stable doses greater than or equal to 90 days prior to screening:  Metformin / Sulfonylureas / Meglitinides (glinides) / DPP-4 inhibitors / SGLT2 inhibitors / Thiazolidinediones / Alpha-glucosidase inhibitors / Oral combination products (for the allowed individual oral anti-diabetic drugs) / Oral or injectable GLP-1-receptor agonists  Body mass index (BMI) below or equal to 40.0 kg/m^2.  Exclusion Criteria:  Any episodes (as declared by the subject or in the medical records.) of diabetic ketoacidosis within 90 days prior to the day of screening. Myocardial infarction, stroke, hospitalisation for unstable angina pectoris or transient ischaemic attack within 180 days prior to the day of screening. Chronic heart failure classified as being in New York Heart Association Class IV at screening. Anticipated initiation or change in concomitant medications (for more than 14 consecutive days) known to affect weight or glucose metabolism (e.g. treatment with orlistat, thyroid hormones, or corticosteroids). Uncontrolled and potentially unstable diabetic retinopathy or maculopathy. Verified by a fundus examination performed within the past 90 days prior to screening or in the period between screening and randomisation. Pharmacological pupil-dilation is a requirement unless using a digital fundus photography camera specified for non-dilated examination.