-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dashboard doesn't update unless i press reset button #26
Comments
I am also facing exactly the same issue since many months. |
This is made mainly for storing widget's settings (title, some settings). What changes you do to dashboard file you don't want to be loaded from database? |
I need a multi-level dashboard so i am extending jet and making it hierarchial. So i would prefer loading it from file. Also in development its difficult to add more module and check because this function create new entry in database only when module_models is'nt there or its length is 0. |
Man, why put you a JET_INDEX_DASHBOARD if django-jet doesn't charge a custom dashboard by default? It's crazy. I think that this are a bug mine, but isn't it, it's a Django-Jet Bug 👍 |
HI, this bug is a pain for me too, |
@f1nality what's about this man? I think that a possible solution will be use the same methos with this form: class ResetDashboardForm(forms.Form):
app_label = forms.CharField(required=False)
def __init__(self, request, *args, **kwargs):
self.request = request
super(ResetDashboardForm, self).__init__(*args, **kwargs)
class Meta:
model = UserDashboardModule
fields = []
def clean(self):
data = super(ResetDashboardForm, self).clean()
data['app_label'] = data['app_label'] if data['app_label'] else None
if not self.request.user.is_authenticated():
raise ValidationError('error')
return data
def save(self, commit=True):
if commit:
UserDashboardModule.objects.filter(
user=self.request.user.pk,
app_label=self.cleaned_data['app_label']
).delete() Use some this methods when load the custom template. I think that when you use migrate on dashboard you load first default dashboard and it is set in database first. So, when you use reset, this function clean default dashboard sets in database and save the new dashboard, right? |
@Ajeetlakhani what do you mean by pressing the "reset" button here? Does this mean wiping out the database and starting fresh? @f1nality This is rough bug to figure out. What is the work around to getting your dashboard to update with different modules? Wiping out the database isn't really an option for me. (I bought the license if that matters at all) |
I actually implemented a workaround for this. It involves overriding from jet.dashboard.dashboard import Dashboard
from jet.dashboard.models import UserDashboardModule
class CustomIndexDashboard(Dashboard):
columns = 3
# Moderator Tools
def init_with_context(self, context):
self.available_children.append(modules.LinkList)
def get_or_create_module_models(self, user):
module_models = []
i = 0
for module in self.children:
column = module.column if module.column is not None else i % self.columns
order = module.order if module.order is not None else int(i / self.columns)
obj, created = UserDashboardModule.objects.get_or_create(
title=module.title,
app_label=self.app_label,
user=user.pk,
module=module.fullname(),
column=column,
order=order,
settings=module.dump_settings(),
children=module.dump_children()
)
module_models.append(obj)
i += 1
return module_models
def load_modules(self):
module_models = self.get_or_create_module_models(self.context['request'].user)
loaded_modules = []
for module_model in module_models:
module_cls = module_model.load_module()
if module_cls is not None:
module = module_cls(model=module_model, context=self.context)
loaded_modules.append(module)
self.modules = loaded_modules |
Please come to the django-jet Discord server so we can organize if you like: Welcome! 😄 |
@Ismael-VC , what's about this? Did you test it? |
When i do some changes in my custom dashboard file it does not reflect changes in browser unless i press reset button. When i looked into jet's dashboard file i found that
This function loads module from UserDashboardModule model not from my custom dashboard file. I guess model should only store the position and some setting for respective modules instead of storing all the modules in db. It never happened with me when i used admin-tools.
The text was updated successfully, but these errors were encountered: