Has many belongs to relation deletion error

Hey there I am having a team that can be selected on a user, and the foreign key is saved.
but when I am trying to delete a team that is selected for a user it cannot be done, it just gives an exception.

(Ecto.ConstraintError) constraint error when attempting to delete struct:

* foreign_key: users_team_id_fkey

If you would like to convert this constraint into an error, please
call foreign_key_constraint/3 in your changeset and define the proper
constraint name. The changeset has not defined any constraint.

I dont want my users to see this, i searched about foreign_key_constraint but not too sure where to put it, or what is the proper way to deal with this issue nicely.
my code: https://github.com/benonymus/userteamroleapi

ok i found this useful so far: https://elixirforum.com/t/constraint-error-when-attempting-to-delete-struct/13689/2

although not perfect, I would like to keep my users not delete them, i also tried nullify but with that the users cannot be displayed since that filed does not have the propertied that it would want to display (team name)

i figure that maybe i could use sometihing like this: https://stackoverflow.com/questions/29041352/how-can-i-handle-the-empty-case-in-elixir-phoenix-templates

but does not work yet

<td><%= if user.team.empty?(@users) do %>
        no team set <% else %> <%= user.team.name %>
      <% end %>

ok so this part : <%= if user.team.empty?(@users) do %> is not correct for sure

<%= if !user.team do %> this works beautifully