@@ -579,10 +579,6 @@ def __init__(self, *args, **kwargs) -> None:
579
579
# Initialize the source object field
580
580
initial ["source" ] = instance .source
581
581
582
- # Check if "comments" is absent, indicating a request with custom
583
- # GET parameters for prefilling of the form field "source".
584
- prefill_source = "comments" not in initial
585
-
586
582
kwargs ["initial" ] = initial
587
583
588
584
super ().__init__ (* args , ** kwargs )
@@ -602,7 +598,7 @@ def __init__(self, *args, **kwargs) -> None:
602
598
pass
603
599
604
600
# Clears the source field if the selected type changes
605
- if self .instance and source_type_id != self .instance .source_type_id and not prefill_source :
601
+ if self .instance and self . instance . pk and source_type_id != self .instance .source_type_id :
606
602
self .initial ["source" ] = None
607
603
608
604
def clean (self ):
@@ -744,10 +740,6 @@ def __init__(self, *args, **kwargs) -> None:
744
740
# Initialize the destination object field
745
741
initial ["destination" ] = instance .destination
746
742
747
- # Check if "comments" is absent, indicating a request with custom
748
- # GET parameters for prefilling of the form field "source".
749
- prefill_source = "comments" not in initial
750
-
751
743
kwargs ["initial" ] = initial
752
744
753
745
super ().__init__ (* args , ** kwargs )
@@ -768,7 +760,7 @@ def __init__(self, *args, **kwargs) -> None:
768
760
pass
769
761
770
762
# Clears the source field if the selected type changes
771
- if self .instance and source_type_id != self .instance .source_type_id and not prefill_source :
763
+ if self .instance and self . instance . pk and source_type_id != self .instance .source_type_id :
772
764
self .initial ["source" ] = None
773
765
774
766
# Destination
@@ -787,7 +779,7 @@ def __init__(self, *args, **kwargs) -> None:
787
779
pass
788
780
789
781
# Clears the destination field if the selected type changes
790
- if self .instance and destination_type_id != self .instance .destination_type_id and not prefill_source :
782
+ if self .instance and self . instance . pk and destination_type_id != self .instance .destination_type_id :
791
783
self .initial ["destination" ] = None
792
784
793
785
def clean (self ):
0 commit comments