posts/django-dashboard-with-suit-and-highcharts/ #30
Replies: 22 comments
-
Original author: Gustavo Thanks for post :) Using Django 1.9.5, you need to declare something like (in urls.py):
|
Beta Was this translation helpful? Give feedback.
-
Original date: 2016-05-04T09:30:28Z Thank you Gustavo, I added your comment as an edit in the post :) |
Beta Was this translation helpful? Give feedback.
-
Original author: gdr Great post! Is it possible to use in a custom AdminSite? I've tried the above, but am getting "You don't have permission to edit anything." when trying to open the custom site after logging in |
Beta Was this translation helpful? Give feedback.
-
Original date: 2016-08-01T18:45:57Z Thank you! Okay so if you want to use this without django-suit, you have to play between 'django.contrib.admin' and 'django.contrib.admin.apps.SimpleAdminConfig' in your installed apps. You could also check the django-app I wrote, starting from this post: https://github.com/Pawamoy/... |
Beta Was this translation helpful? Give feedback.
-
Original author: gdr Thanks for the speedy response! I've tried both 'django.contrib.admin' and 'django.contrib.admin.apps.SimpleAdminConfig' without any luck. I am using django-suit too, but for 2 admin sites- admin and custom_admin. It looks like it might be an issue with app_list context var for custom_admin site possibly (or is this something I need to create in the view myself?) as it's still possible to navigate to to the models that have been custom_admin.register(). I'll play around with templates though, as I've only been extending the dashboard off suit's admin/index.html at the moment as a starting point. I'm also using a custom AUTH_USER_MODEL, so not sure if that would affect things? |
Beta Was this translation helpful? Give feedback.
-
Original date: 2016-08-01T19:14:00Z You're welcome. Okay so you have 2 sites. Maybe an issue with admin.sites.site = admin.site? You could check what differs in your custom admin from the one I show in this post... Good luck ! (but don't hesitate to ask me more if you think I can help ;)) |
Beta Was this translation helpful? Give feedback.
-
Original author: gdr Thanks again, I'm quite new to django, so pretty sure I was missing something simple, but in the end for my purposes I landed up doing: class CustomAdmin(admin.AdminSite):
def get_urls(self):
from django.conf.urls import url
urls = super(CustomAdmin, self).get_urls()
urls += [
url(r'^custom-admin/$', self.admin_view(self.DashboardView))
]
return urls
class DashboardView(TemplateView):
template_name = 'admin/dashboard/welcome.html'
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
return self.render_to_response(context=context)
custom_admin = CustomAdmin(name='custom_admin') |
Beta Was this translation helpful? Give feedback.
-
Original author: Gustavo Soeiro Senise @gustavosoeirosenise Hello Pawamoy, |
Beta Was this translation helpful? Give feedback.
-
Original date: 2016-12-30T11:06:54Z Hi Gustavo! Do you work in a virtualenv? If so, could you paste the result of a "pip freeze" command? |
Beta Was this translation helpful? Give feedback.
-
Original author: Gustavo Soeiro Senise @gustavosoeirosenise Thank you very much for your answer Pawamoy!
I might buy Pycharm and test it! I am using WebStorm from the same company, for nodejs. |
Beta Was this translation helpful? Give feedback.
-
Original date: 2016-12-31T19:34:37Z Yes you should use virtualenv to avoid mixing specific project Maybe we could also chat on gitter instead? My nickname there is Pawamoy also |
Beta Was this translation helpful? Give feedback.
-
Original author: Gustavo Soeiro Senise @gustavosoeirosenise Heppy new year Pawa man! I have no batery right now on my cell. And parting a little bit. I've just bought a Pycharm license. I've just created a django app in a virtual env. Would you send to me a pip freeze for this project, so I can start from your scope? Thank you very much!! |
Beta Was this translation helpful? Give feedback.
-
Original author: Anupam Jain Thanks! Your post helped with a design improvement in the structure of my Django/Highcharts code (referred to your post here: http://stackoverflow.com/qu... |
Beta Was this translation helpful? Give feedback.
-
Original date: 2017-04-19T13:47:55Z You're welcome! Glad my post helped you :) I'm using a lot Highcharts in an automated way in my project, and I now actually pass the entire chart to the template (as JSON) from the view. Every bit of render is computed server-side, so my template works with every type of chart :) One disadvantage to my method though is that you have to hack a bit to use javascript function in your chart (tooltip.formatter, etc.). |
Beta Was this translation helpful? Give feedback.
-
Original author: Anupam Jain Ah, thats interesting to know. Do you think it'll be cleaner if you could retain the same dynamism of creating any type of chart by using js functions and have the view only pass the actual data needed from the models? Because I am thinking its the template's responsibility to show 'how' the data is shown (what goes on x axis, what goes on y axis etc.) and the view just sends 'what' data needs to be shown. But I am still learning, so could be wrong, or it could just be a trade-off in the given use case. Happy to hear your thoughts. |
Beta Was this translation helpful? Give feedback.
-
Original date: 2017-04-21T11:12:46Z You are absolutely right. Django stresses this in its documentation: no logic in template, no "presentation" in views. I guess you could easily "reverse" my method by using several templates (extending others or included by them), one for each type of chart, and pass only a few values to them from the views (like the series, maybe title, height, width, etc.). I chose to compute the entire chart server-side because the project I'm working on is evolving quickly, and I didn't want to edit chart templates each time I needed to add or change a value in the chart. There are two many (an infinity?) possible combinations with Highcharts so it was easier for me to pass it all from the views, but it might not be your case! |
Beta Was this translation helpful? Give feedback.
-
Original author: Anupam Jain Ah - got it, thanks for getting back on that! |
Beta Was this translation helpful? Give feedback.
-
Original author: Rovshan Musayev @rovshan_musayev I have applied everything what here written but I get error ModuleNotFoundError: No module named 'admin'. What can be a problem? |
Beta Was this translation helpful? Give feedback.
-
Original date: 2018-01-22T14:58:20Z Do you get this error when starting the server? Could you please post the entire stack trace so I have more information about this issue? |
Beta Was this translation helpful? Give feedback.
-
Original author: Rovshan Musayev @rovshan_musayev Unfortunately, currently I haven't. After error I gave up to to implement this component |
Beta Was this translation helpful? Give feedback.
-
Original author: aymanemx @aymaneMx thank you! |
Beta Was this translation helpful? Give feedback.
-
Original date: 2020-04-23T09:11:20Z You're welcome! |
Beta Was this translation helpful? Give feedback.
-
Django admin dashboard with Suit and Highcharts - pawamoy's website
Findings, thoughts, tutorials, work. Pieces of my mind!
https://pawamoy.github.io/posts/django-dashboard-with-suit-and-highcharts/
Beta Was this translation helpful? Give feedback.
All reactions