title: redirect Createview to Updateview if record exist in 1:1
body: <p>I am trying to redirect a logged in user to an <code>Updateview</code> instead of a <code>Createview</code> if they have already created a record in the <code>organizations</code> model. 
  My <code>organizations</code> has a 1:1 relationship with my <code>users</code> model.</p>
  
  <p>I am currently able to return the <code>Updateview</code> with the <code>get</code> method if the related record exists, but the Url is not redirected to <code>/update</code></p>
  
  <p>My code:</p>
  
  <p><strong>urls.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>urlpatterns = [
      path("add/", view=organization_add_view, name="add"),
      path("update/", view=organization_update_view, name="update"),
      path("&lt;int:id&gt;/&lt;str:slug&gt;", view=organization_detail_view, name="detail"),
  ]
  </code></pre>
  
  <p><strong>models.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>class Organization(TimeStampedModel):
  
      name = CharField(_("Organization Name"), blank=False, max_length=255, unique=True)
      slug = AutoSlugField(_('slug'), max_length=100, unique=False, populate_from=('name',))
      user = OneToOneField(settings.AUTH_USER_MODEL, on_delete=CASCADE, db_index=True)
  
      def __str__(self):
          return self.name
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>class OrganizationDetailView(DetailView):
  
      model = Organization
      slug_field = "slug"
      slug_url_kwarg = "slug"
  
  organization_detail_view = OrganizationDetailView.as_view()
  
  
  class OrganizationAddView(LoginRequiredMixin, SuccessMessageMixin, CreateView):
      model = Organization
      form_class = OrganizationForm
  
      success_message = "%(name)s was created successfully"
  
      def form_valid(self, form):
          obj = form.save(commit=False)
          obj.user = self.request.user
          obj.save()
          return self.get_success_url()
  
      def get_form_kwargs(self):
          kwargs = super(OrganizationAddView, self).get_form_kwargs()
          kwargs.update({'request': self.request})
          return kwargs
  
      def get_initial(self):
          return {
              'user': self.request.user,
              'is_update': False
          }
  
  
      def get(self, *args, **kwargs):
          if self.model.objects.filter(user=self.request.user).exists():
              return redirect("organizations:update")
          else:
              return super(OrganizationAddView, self).get(*args, **kwargs)
  
      def get_success_url(self):
          return reverse("organizations:list")
  
  organization_add_view = OrganizationAddView.as_view()
  
  
  class OrganizationUpdateView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
      model = Organization
      form_class = OrganizationForm
      success_message = 'Organization updated successfully.'
  
      def get_object(self, queryset=None):
          obj = self.model.objects.get(user=self.request.user)
          return obj
  
      def get_initial(self):
          return {
              'is_update': True
          }
  
      def get(self, *args, **kwargs):
          if self.model.objects.filter(user=self.request.user).exists():
              return super().get(*args, **kwargs)
          else:
              return redirect("organizations:add")
  
      def get_form_kwargs(self):
          kwargs = super(OrganizationUpdateView, self).get_form_kwargs()
          kwargs.update({'request': self.request})
          return kwargs
  
      def get_success_url(self):
          return reverse("organizations:update")
  
  organization_update_view = OrganizationUpdateView.as_view()
  </code></pre>
  
  <p><strong>forms.py</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>class OrganizationForm(forms.ModelForm):
      def __init__(self, *args, **kwargs):
  
          self.request = kwargs.pop("request")
  
          super(OrganizationForm, self).__init__(*args, **kwargs)
  
          organization = kwargs.get('instance')
  
          user = self.request.user
  
          self.helper = FormHelper(self)
          if organization:
              if organization.email is None:
                  self.initial['email'] = self.request.user.email
          elif user.email:
              self.initial['email'] = user.email
  
          self.helper.form_method = 'post'
  
          submit_btn_text = 'Continue'
  
          if kwargs.get('initial')['is_update']:
              submit_btn_text = 'Update'
  
          self.helper.add_input(Submit('submit', submit_btn_text)) 
  
      class Meta:
          model = Organization
          widgets = {
              'description': forms.Textarea(attrs={'rows': 10, 'cols': 60}),
              # 'logo': forms.ImageField()
          }
          fields = '__all__'
          exclude = ['created', 'expires', 'is_sponsor', 'view_count', 'user']
  </code></pre>