Login

Tag "utilities"

Snippet List

Convert CamelCase to lowercase_with_underscores

Just a simple regex function to convert a camel case string ("ClassName") to a lower case string with underscores ("class_name"). Came across a need for this when I was trying to add properties to a model at runtime using `object.__class__.__name__`. This is a modification of the function "get_verbose_name" found in django.db.models.options.

  • utilities
  • formatting
  • one-liners
Read More

2 snippets posted so far.