Skip to content

Instantly share code, notes, and snippets.

View dmenisdev's full-sized avatar

Dmenis dmenisdev

  • vdBit
  • World
View GitHub Profile
@dmenisdev
dmenisdev / readme.md
Last active December 10, 2022 12:08
Simple international non-localised shipping address fields [Django ORM]

Objective

Create a minimal simple set of fields to store shipping address for use in non-localised forms that can be used to easliy create shipping address labels.

Reasoning

full_name Can't get more simple than that 😂. Reasons for this can be found at w3.org personal names you'll find some good advice here if you want to go more fancy that just the one field. Field size of 70 comes from UK Government Data Standards Catalogue.

address fields Most international shipping requirements state that a shipping label should have only 2 address lines not exceeding 50 characters each.

@dmenisdev
dmenisdev / admin.py
Last active February 3, 2021 08:52
Django admin - Show fields of related model in list view
Class AlbumAdmin(ImportExportModelAdmin, admin.ModelAdmin):
list_display=('name', 'release_date', 'artist', 'get_musician_instrument')
list_filter=('name')
def get_musician_instrument(self,obj):
Return obj.artist.instrument
get_musician_instrument.admin_order_field='artist' # allowscolumnordersorting
get_musician_instrument.short_description='Instrument' # overwritecolumnname