def config_set(key, value): """ Save key, value in DB. If it allready exist, it will be updated """ try: c = Config.objects.get(id=key) except Config.DoesNotExist: c = Config() c.id = str(key) c.value = unicode(value) c.save()