Forms#

The coins app provides a single user-facing form – the coin creation / edit form. It is one of the per-app subclasses of BaseUserItemForm (see Forms, fields and widgets), narrowed to Coin, with an extra coin_id field and cross-field validation that disambiguates colliding ticker symbols against CoinGecko via the Karpet library.

UserCoinForm#

Concrete coin variant of BaseUserItemForm. Sets item_model = Coin. The extra coin_id field carries the unambiguous CoinGecko slug (see Coins). On edit, both symbol and coin_id are rendered read-only so the asset identity cannot change after creation.

The form-level clean() performs the symbol-disambiguation handshake:

  • If the user did not enter a coin_id and the symbol resolves to more than one slug, the form raises a validation error asking for an explicit coin_id.

  • If the symbol resolves to nothing – or the entered coin_id is not among the slugs found – the form raises a “Coin ID wasn’t found.” error.

class richy.coins.forms.UserCoinForm(user, *args, **kwargs)[source]#

Bases: BaseUserItemForm

UserCoinForm.clean()[source]#

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.