Package: django-brain-utils
Brain UtilsBrain Utils is a Django app to let developers do not repeat same initial code for commons utilities. For example
configuration system values in database, configurable messages with traduction, stantard mixins for models and admins, etc.Quick startInstall:pip install django-brain-utilsAdd "brainutils" to your INSTALLED_APPS setting like this:INSTALLED_APPS = [ ... 'brainutils', # Before allauth ... ]To start you can add a configurable message in your home page, example:{% load butils %}{% display_message request 'home.welcome' %}Runpython manage.py migrateto create the brainutils models.Start the development server, visithttp://127.0.0.1:8000to watch first message and then gohttp://localhost:8000/admin/brainutils/message/to edit the created message, you may set there the message you want all times you need (to refressh changes you need
to restart your webserver Apache, Nginx, etc). Is easy and you got a total control for each message and it traductionMore utilitiesConfiguration variables:You can set and use in your code a configuration variable very easy like this:from brainutils import configurationtoken = configuration.get_value('api.some.token','HEREYOURINITIALTOKENVALUE')
max_items_per_page = configuration.get_integer('commons.pagination.maxitems','10')Then you may set a new value whenever you whant inhttp://localhost:8000/admin/brainutils/configuration/. Again you need
to restart your webserver to refresh changesModel standart base fields:`from brainutils import mixinsclass MyModel(mixins.AuditMixin):field1 = models.TextField(null=True, blank=True)
field2 = models.TextField(null=True, blank=True)`Then you have this fields and you may use like you want:
creation_date, modification_date, creation_user, modification_user, statusExtra Models Administrator SkillsIf you need to interact with your model administrator with extra tags or actions you can use something like this:`class MyModelAdmin(mixadmin.ModelAdminMixin):list_display = ('field1', 'field2', 'modification_date', 'extra_actions')

def myaction_view(self, request, id):
    try:
        obj = models.MyModel.objects.get(pk = id)
        success = obj.do_action()
        if success:
            return self.response_view(request, True, 'myaction_view', 'OK')
        else:
            return self.response_view(request, False, 'myaction_view', 'FAIL')
    except Exception as e:
        return self.response_view(request, False, 'myaction_view', str(e))

def get_specific_dual_methods(self, obj):
    return [
        {'name':'actionname', 'activation':True, 'color':self.ENABLED_COLOR, 
        'myaction_view':self.myaction_view},
    ]`Language ManagerYoure application may needs to be multilanguage, theres an easy way with Brain Utils, just set in your code:`from brainutils import messagesdef my_view(request):current_language = messages.languages.get_language(request)

# Do whatever you want with language object

# You may change the current language online in each moment if you need

messages.languages.change_language(request,'english')`In templates:{% for l in LANGUAGES %}
{{l.title}}
{% endfor %}Then you may set a new language value whenever you whant inhttp://localhost:8000/admin/brainutils/language/.Customers AccountsBrainutils gives you an standard login, signup and more functionalities for customers in your application.To customize messages and else, copy our templates/account/ folder and change there whatever you want. You may
reuse a lot of funcionality inside there if your application web structure is similar. We use bootstrap as this:Code GenerationWith Django Brain Utils you can generate repetitive code, as the Model Admins, for that objetive we have a console,
you can run the console from this command:./manage.py codegenAnd this menu will be displayed:Welcome to Brain UtilsBRAIN UTILS GENERATOR
What we gonna do?:Generate AdminsGenerate URLs- ViewsGenerate Signup - LoginExitSelect and option[and press ENTER]:By the moment with just try with option 1, is very intuitive and easy to generate admins code.