Login

Snippets by binishkaspar

Snippet List

Custom model field for Frame or Box

**Purpose** We often need to store x,y, width and height for a model, we can store all these values in same field by having custom field. **How to Use** Save this code in *customfields.py* and in your model >*from customfields import FrameField* >*class MyModel(models,Model)* >* frame = FrameField()* And in your in views, you can use as follows >*model = MyModel.objects.get(1)* >*print model.frame.x, model.frame.y, model.frame.width, model.frame.height*

  • field
  • custom-model-field
  • frame
Read More

binishkaspar has posted 1 snippet.