byashimov / django-controlcenter Goto Github PK
View Code? Open in Web Editor NEWSet of widgets to build dashboards for Django projects
License: BSD 3-Clause "New" or "Revised" License
Set of widgets to build dashboards for Django projects
License: BSD 3-Clause "New" or "Revised" License
When ItemList
s become big it'd be amazing if django-controlcenter could offer pagination.
Hi, with the most recent version of django (3.0.3) i get the above error.
From my understanding since django 3 django.utils.six is deprecated
Since django 3.2
, AdminSite.final_catch_all_view
has been introduced:
A boolean value that determines whether to add a final catch-all view to the admin that redirects unauthenticated users to the login page. By default, it is set to
True
.
โ ๏ธ Setting this to False is not recommended as the view protects against a potential model enumeration privacy issue.
The url of any dashboard results in a 404 error.
I have a need to add a summary line to an item list widget. Currently I add one more item to the list of data that is a sum of the integer columns. The problem with this is the row is sorted with all the other data rows. What I would like is to have a summary row that allows me to define how a column is summarized and would be always placed at the bottom of the table (i.e. table footer).
How would you accomplish this? I am willing to implement a solution but I want to do it in the way that makes the most sense.
The last commits you merged from my pull request #15 permit controlcenter to works with Django 2.0.
Please bump a new version of controlcenter with this commits and release it on pypi.
Thank you
title: | message |
---|---|
Django Version: | 3.2.7 |
Exception Type: | AttributeError |
Exception Value: | module 'django.db.models' has no attribute 'FieldDoesNotExist' |
Exception Location: | /usr/local/lib/python3.8/site-packages/controlcenter/templatetags/controlcenter_tags.py, line 185, in attrlabel |
Python Version: | 3.8.12 |
need fix =)
change django.db.models.FieldDoesNotExist
to django.core.exceptions.FieldDoesNotExist
try:
from django.db.models import FieldDoesNotExist
except ImportError:
from django.core.exceptions import FieldDoesNotExist
Can you please release 0.2.7 version on pypi.org
https://pypi.org/project/django-controlcenter
Using with python 3.10 the following error occurs
File "/Users/elenag/.virtualenvs/consialinkenv/lib/python3.10/site-packages/controlcenter/widgets/core.py", line 88, in
class Group(collections.Sequence):
AttributeError: module 'collections' has no attribute 'Sequence'
This class has been move to collections.abc
There is a way to use dashboards created with django-controlcenter like django-admin-tools does with CustomIndexDashboard and CustomAppIndexDashboard?
https://django-admin-tools.readthedocs.io/en/latest/customization.html#customizing-the-dashboards
https://github.com/gionkunz/chartist-js/issues/508
reverseData: true
reverses not only the list elements, but also the lists themselves insides series
. This might be logical for some, it is not logical for me.
In any case this messes up the order of widget.legend
.
I am not including any patches because the whole reverseData
feature needs mental gymnastics that is not worth the effort for me with possible side effects like this.
I am not sure this should be turned on by default.
can you please remove them?
$ find . -name .DS_Store
./.DS_Store
./static/.DS_Store
./static/controlcenter/.DS_Store
./static/controlcenter/css/.DS_Store
would you consider bundling some basic chartist plugins?
the 2 basic ones (that come "out of the box" with jchart) i had in mind are tooltips
and legend
.
i am not sure why legends is a plugin, any graph with multiple datasets on it is useless without it...
https://github.com/CodeYellowBV/chartist-plugin-legend
http://gionkunz.github.io/chartist-js/plugins.html#tooltip-plugin
Is there a way to inject in the current js something like labelInterpolationFnc
for chartist?
https://gionkunz.github.io/chartist-js/api-documentation.html:
// In addition to the regular options we specify responsive option overrides
// that will override the default configutation based on the matching media queries.
var responsiveOptions = [
['screen and (min-width: 641px) and (max-width: 1024px)', {
showPoint: false,
axisX: {
labelInterpolationFnc: function(value) {
// Will return Mon, Tue, Wed etc. on medium screens
return value.slice(0, 3);
}
}
}],
['screen and (max-width: 640px)', {
showLine: false,
axisX: {
labelInterpolationFnc: function(value) {
// Will return M, T, W etc. on small screens
return value[0];
}
}
}]
];
I just leave the queryset as default. And itemlist just give me the info. Python 2.7, Django 1.11
I am wondering is it'll be a good idea to add link to django-controlcenter
app from admin page without guessing which url I need to paste.
What do you think?
django-admin-tools being a very popular app for admin, i would want the controlcentre widgets to be intgerated with it.
I have in settings:
CONTROLCENTER_DASHBOARDS = (
('Leads', 'dashboards.Base'),
('Backlinks', 'apps.backlinks.dashboards.Backlinks'),
('Spiders', 'apps.spiders.dashboards.Spiders'),
)
But I get html without links:
<nav class="controlcenter__nav">
<a class="controlcenter__nav__item" href="">Leads</a>
<a class="controlcenter__nav__item" href="">Backlinks</a>
<a class="controlcenter__nav__item" href="">Spiders</a>
</nav>
What I am doing wrong?
Python 3.6
Django 1.11
django-controlcenter==0.2.5
Hi @byashimov
it could be useful to have the possibility to override colors at widget level, especially when a color is directly mapped to a specific state.
Would you be interested in receiving a PR for this feature?
Hello,
I am trying to create a Chart for a model that have a field with limited choices, represented like this :
class CertificateRequest(models.Model):
"""
Certificate request object in the database
"""
NEW = 0
REQUESTED = 1
ACCEPTED = 2
DENIED = 3
ERRORED = 4
STATUS = (
(NEW, _('New')),
(REQUESTED, _('Requested')),
(ACCEPTED, _('Accepted')),
(DENIED, _('Denied')),
(ERRORED, _('Errored')),
)
***
status = models.IntegerField(
verbose_name=_('Status'),
choices=STATUS,
default=0
)
****
I want to get the amount of Certificate Requests for each status, to I did like this :
class CertificateRequestsStatusWidget(widgets.SinglePieChart):
title = "Certificate Requests Status"
queryset = CertificateRequest.objects.values_list("status").annotate(status_count=Count("status")).order_by("status")
class Chartist:
options = {
"onlyInteger": True
}
def values(self):
return self.queryset
def labels(self):
return self.series
def legend(self):
return sum([[status[1].__str__() for status in CertificateRequest.STATUS if status[0] == status_id["status"]] for status_id in CertificateRequest.objects.values("status").annotate(status_count=Count("status")).order_by("status")], [])
The legend is more complex as I want to get the names of the statuses depending of if they are in present in the database.
The queries works fine in ipython :
In [55]: CertificateRequest.objects.values_list("status").annotate(status_count=Count("status")).order_by("status")
...:
Out[55]: <QuerySet [(1, 1), (2, 25)]>
In [56]: sum([[status[1].__str__() for status in CertificateRequest.STATUS if status[0] == status_id["status"]] for status_id in CertificateR
...: equest.objects.values("status").annotate(status_count=Count("status")).order_by("status")], [])
...:
Out[56]: ['Requested', 'Accepted']
But on my graph I don't get anything, just the default background.
What is the issue ?
Would not it be better to have more strict code check so if we put something wrong in our methods it will throw an exception with a detailed message ? I've been trying for hours and I can't get this graph to work correctly.
Thank you.
Best regards,
Mathieu
I've already got a dashboard and don't want another one. However - lovely declarative chart widgets would work very nicely as Django Admin Tools panels.
I add the short_description
but it doesn't work
def get_time(self, obj):
return obj.time
get_time.allow_tags = True
get_time.short_description = 'Time'
def get_user_count(self, obj):
return obj.user_count
get_user_count.allow_tags = True
get_user_count.short_description = 'count'
Hi, I'm thankfully using this package for my django project as a dashboard.
I use some widgets in my dashboard page such as itemlist, piechart, linechart.
BTW, I have a question for you.
As I mentioned in title, can i update my dashboard page without clicking f5 button?
I've founded that using Ajax or setTimeout function do it.
Please tell me if there is any way to do it.
I can not find a way to specify the stroke width of the lines in LineChart, any ideas?
Hey guys,
would it make sense to use this package as user dashboard outside of the django admin? It looks great :)
ModuleNotFoundError at /admin/dashboard/mydash/
No module named 'project'. I get this error when I try running in browser. I get same error even after changing project either name of my project or app name
First of all, this project looks very promising! I've been trying it out for a couple of hours now, with this result as code:
from django.db.models import Count
from django.db.models.functions import TruncMonth
from django.utils.translation import ugettext_lazy as _
from controlcenter import Dashboard, widgets
from dateutil.relativedelta import relativedelta
from bijleshuis.accounts.models import User
class NewUsersMixin:
model = User
title = _('New signups')
values_list = ('month', 'count')
def get_queryset(self):
base = User.objects.all()
qs = base.annotate(month=TruncMonth('date_joined')).values('month').annotate(count=Count('id'))
return qs.order_by('-month')
class NewUsersLineChart(NewUsersMixin, widgets.SingleLineChart):
class Chartist:
options = {
'reverseData': True,
}
def series(self):
series = super().series
series[0].insert(0, 0)
return series
def labels(self):
labels = super().labels
next_dt = labels[0] + relativedelta(months=1)
return [dt.strftime('%b %y') for dt in [next_dt] + labels]
class NewUsersBarChart(NewUsersMixin, widgets.SingleBarChart):
class Chartist:
options = {
'reverseData': True,
}
def series(self):
series = super().series
series.insert(0, 0)
return series
def labels(self):
labels = super().labels
next_dt = labels[0] + relativedelta(months=1)
return [dt.strftime('%b %y') for dt in [next_dt] + labels]
class MainDashboard(Dashboard):
widgets = (
NewUsersLineChart,
NewUsersBarChart
)
As you can see, both widgets are almost identical, with the difference being that one is a line chart and the other a bar chart. They display the exact same data.
In the SingleBarChart
, calling super().series
results in a one-dimensional list, while the LineBarChart
returns a two-dimensional list. I suspect this is a Chartist.js thing, but it's inconsistent on the Python side of things - it's the same one-dimensional dataset after all
There's a lot of code duplication like this. Initially, I tried something like
class NewUsersListChart(NewUsersMixin, widgets.SingleLineChart):
pass
this was kind of unexpected, and leads to a lot of code duplication when making small variants of widgets.
[Deleted]
When building project under Python 3.10, I'm getting the following error:
File "/usr/local/lib/python3.10/site-packages/controlcenter/widgets/core.py", line 88, in <module>
class Group(collections.Sequence):
AttributeError: module 'collections' has no attribute 'Sequence'
In the admin, going to: /admin/dashboard/
results in a 404 error, instead it would be much more useful/usable to redirect the user to the first dashboard, eg.
https://my-domain.com/admin/dashboard/
-> https://my-domain.com/admin/dashboard/accounts/
This would also simplify the url to remember/link for accessing the dashboard.
It seems that there is no urls.py
in controlcenter.
Am I missing something from the docs?
What do you think about making the sortable header in the item list optionally sticky? What I mean by sticky is that the header stays visible while scrolling through the list of items. I know I can do this by overriding the itemlist.html template but do you think this should be a built-in thing in the project?
I am willing to contribute this feature to the project but I wanted to check with you about whether you think its worth it.
I have created a SingleBarChart with 30 series.
Chartist assigns each series a class ct-series-{name}. With name looping from a to z.
The django-controlcenter static file 'chartist-default-colors.css' has colors defined for class a to o. Classes p to z do not have a color defined, and therefore do not display on the chart.
Would it be possible to append 'chartist-default-colors.css' to contain classes ct-series-p to ct-series-z?
Tested with Django 3.0.4 and got: ImportError: cannot import name 'six'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.