Django Admin Tutorial - Full Customization (2018)
ฝัง
- เผยแพร่เมื่อ 25 ส.ค. 2024
- 7 Tips For Getting Better At Django:
mailchi.mp/dea...
In this video you will learn how to customize the django admin view.
django-suit package license:
djangosuit.com/...
Starting point for this tutorial:
github.com/Rec...
You are going to learn:
- how to register and unregister models
- how to add filtering
- how to add a custom input and button which update a field on all objects
- how to change the theme using the django-suit package.
Registering and unregistering models is quite easy. Simple use the admin.site.register/admin.site.unregister functions and provide them with the model.
In order to take our customization further, we'll then create an admin class for the snippet and alter various attributes, such as filter, exclude, list_display, list_filter.
To include an input with a button, we'll need to override the change_list_template attribute and set it to our desired path. In the template, we'll then extend from admin/change_list.html, and can now override the various blocks. For our custom behaviour to work, we'll set up a form with an action, override the get_urls() to include a custom path we'll create that the form will then navigate to, and finally write a view that will handle our request.
Configuring our custom theme is easy. We'll pip install django-suit, create a custom SuitConfig and include it in our INSTALLED_APPS in the settings.py. Now, we can alter the SuitConfig attributes to "suit" (that wordplay...) our needs.
Anyway, you can find the step-by-steps instructions in this video.
If you enjoyed this video, make sure to subscribe and share it with anyone you think could enjoy it as well.
I hope to see you inside of the next episode,
Cheers.
thanks you are the life saver you are the only one who cover this topic
please add more videos about admin Customization if you can because no one talk about it before
Usually I don't comment on TH-cam, but I have to say that this video is AMAZING !!! The speed of presenting is really great - it's amazing how much I learnt and how many new ideas I got in only 14 minutes. Thanks !
Only Tutorial That Actually Shows How To Customize Django Admin.
For real man. you'll spend a whole day just listening to people tell you what you already know. I'm subscribing to this channel
Awesome! You deserve more than 1 million subscribers.
Hope that you'll have 1 million subscribers very soon.
Thank you for your support Srikant, let's go for it!
Very good tutorial, one of the best I have seen in ages! Congrats. Keep up the great work!
Thanks Yared, I appreciate the awesome feedback!
It's super usefull, simple and full of info
Wow that looks really easy. Thank you for showing us !
I love you Sir. You deserve more than 1 million subscribers.
Thanks for the support ;)
Thanks
Useful, thanks
Thank you.
Thank you so much for this video!!!!
very helpful thanks sir
thanks a lot!
Good tutorial
Nice...So fast, but touches everything
Awesome. Thanks.
Awesome tutorial! Really enjoyed watching it!
thank you Jixin!
What kind of keyboard were you using? It sounds amazing
Thank you, I am looking for this.
thank you for this tutorial
Awesome. Thank you so much
wow its amazing
You can fix the admin.py HttpResponseRedirect to ("../../"), which of course depends on the custom url path('fontsize//') in this case, go 2 directories back
Without this, "Snipped with ID "fontsize" doesn't exist. Perhaps it was deleted?" will appear as yellog warning and the redirect happens to localhost:8000/admin, because it tried to access the page "/fontsize" before the ""
Thanks - that was bugging me :)
I know this video is 2 years old but which version of django were you using and is this tutorial update to date with the current version of django?
Thanks for this! Very helpful!
Glad you liked it!
Thank you 😀😊😀😀😀😀😊😀😊😀😊😀😀😀 #unboxingmind
Amazing!
thank you!
will you make video how to customize admin panel in django ? how to change it like WP admin panel
Hi, nice video, not sure if you're going to see this message, but is there a way in which I can add for example a rad button to all records of a given model to mark them as primary (primary would be a field of the model) so when I click a record's rad button then the flag for it is set to true and all others are set to false? The rad button would have to appear in every record of the model
thanx man
Thx for watching!
Thank you for the video. How can you edit the admin login page? It would like to change the 'Django administration' text
very nice sir
Thanks :)
So I'm getting the Django 'No module named 'suit.apps' error
Your videos are really educational, thank you
But can you please help with the above?
Help me
it's very great. thank's
Aymar Amono you're welcome!
Great tutorial sir. Would love to see your tutorials based on data visualization in Django using d3 or chart.js
d3 and chart.js are both on the frontend, so you just need a way to make the frontend and backend talk with each other, just like you would with any other backend framework. Thanks for the suggestion! I'll consider doing something about that in the future.
@@thedumbfounds767 thank you sir 😊
@@nishantbhavsar6785 you're welcome! If you have any other requests, let me know. I'm always looking for suggestions ;)
How can I redirect the user to the website after saving the form instead of redirecting then to the default admin section? I will really appreciate if someone could help.
There is no suit.apps in suit package. How to do the import.
If possible, I'd like to make a video request. Do you have any experience with a multiple page form? For example, the Form Wizard tool with Django? Would you be interested in making a tutorial for that where the form data gets passed in to the back end?
You're making great tutorials! They're brilliant!
Thanks Kayla, I don't have experience with it, yet. But it's a great video idea! Thanks.
Thanks a lot for this awesome tutorial. By the way, can we add a search function to the Django admin?
Hi, yes you defintely can, you just need to add search_fields attribute in Custom admin class that you create. Any field you mention in search_fields attribute can be used to search on list display on Django Admin
@@storiesfromincredibleindia Thanks so much. I actually did it. Now I am looking for ways to let it be done at admin interface, not in code. Can you give me advice on that?
@@gratefulNow. what do you mean?
Subscribed!
Thanks man!
Hello Sir thank you for the tutorial
please I have a question though it's beyond the scope of this tutorial
I have a django app deployed on namecheap shared hosting and throws up and error such as:
Request Method: POST
Request URL: myworldgist.com/admin/blog/post/add/
Raised by: django.contrib.admin.options.add_view
And everything works well in development
I have pillow installed and my urls config is ok according to the docs.
Please any help base on how I could bypass this error will be highly appreciated
When I m registering SnippetAdmin class in admin.py it's showing an error -
For model in model_or_iterable:
TypeError : 'MediaDefiningClass' object is not iterable...plz help
you got a subscriber ;)
Thanks!
GREAAAAAAAT !
ty :)
cool 😃
haha, thanks!
how to add custom button or action in django admin panel to view single blog or template ?
I just follow your video and can't find where did you mention that you will do api call to /admin/fontsize/int . I created my form its doing post method to /admin/ my code is not working. Where did you mention that?
The default update option goes away when the list_display method is used in django admin. Any solution for that? Cheers!
i want to add a button in admin's list_display, but ....
can we add custom field through admin panel?
Could you make a video about how to change the domain name of a local server. For example.. Say I want someone on the server to type in example.com:8000 and it lead to the django site. How would I go about doing that? I've found some tutorials, but none of them seem to work in django 2.0..
Thanks for the suggestion! I'll do a video on that if I can make it work. Which tutorial have you found that didn't work?
Awesome man! That would be amazing if you can pull it off!
If you're on windows, have you tried editing the hosts file? Although that would probably be a security vulnerability, as you typically don't want to enable the hosts file to be edited.
The Dumbfounds I have tried that. It works, but you have to edit them on every computer on the network that would try and access that URL. But yes, technically that does work, just only for that one computer.
I didn’t know if there was a way to be able to do it from the host computer so that every computer on the network could type in example.com:8000 and be able to access the site. It would be basically setting up Django as an intranet through the network
sir where to find snippets
Short question - how do you get it working in terminal so you don't have to type "python" at the beginning of every command - and is this related to the "lambda" symbol?
I used Windows in this tutorial. Which OS are you currently on? That may be the difference.
@@thedumbfounds767 Aha, ok, I'm in Mac OSX. Maybe Windows recognises the .py and automatically runs it with the python in your env.
Hey man gr8 video! Can u pls help me out with moving the filter panel that appears on the right side of the page towards the top of the page? I really want it to display on the top.
Thanks in advance , God bless ya! :)
Thanks! Haven't ever done that. Take a look at what makes the filter stick to the right (e.g. floats) and remove them.
@@thedumbfounds767 hey man thanks for replying, I am trying it from a week now , no success. If you get time , pls have a look. :)
@@niteshrawat576 I think it's best if you ask on StackOverflow. That way, many more people can respond! :)
Hi sir im currently a PHP programmer and wanted to get a job as python-django programmer, any tips please 😊 thanks..
I don't think there's much difference between getting one doing PHP and getting one using python/Django. Start looking, appliying and have some good projects ready you can showcase.
@@thedumbfounds767 appreciate it a lot sir. 😁
im getting error that, "'ModuleNotFoundError: No module named 'suit.apps'" --help
do the following : pip uninstall django-suit
pip install github.com/darklow/django-suit/tarball/v2
sir i have this error how can i solve such error
This site can’t be reachedlocalhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
your server isnt running
The keyboard sound is so sexy! What is the model of it?
It's a titanwolf! I think I'll get a new one, though, this one has caused me problems twice already...
Customization is not working here
i found this error .from suit.apps import DjangoSuitConfig
ModuleNotFoundError: No module named 'suit.apps' . i have done the pip install django-suit and app setting myapp.apps.SuitConfig but this error is occuring. Help me
i have got exact same problem. And i don't know why this going on
Did you slove it I having same issue
Is it possible to inject our js on Add button present under Snippet, if yes what steps i can follow, Please help!
Don't really understand what you're after...
@@thedumbfounds767 I want to change the form page from djanga admin(which shows the field and value from db), how can I do that
@@kushanjoshi1222 Try overriding the object_form.html admin template. Not sure if that's the right one, but the name seems to fit. In the example of the video, the path should be /templates/admin/snippets/snippets_object_form.html. Let me know if that works!
@@thedumbfounds767 Thanks for your direction, that might not be the apt name of the template, i want to alter but it gave me some html template with which i can fiddle around like change_form.html (i want to use a editor instead of that form, fetch the data so that i can perform some operation and show the output in particular format)
Hi I'm wondering if I could make the django admin like a profile page with a picture and a description of you and I want to make a tracking thing like when you get a free trial and once the free trial is up it cuts you off until you signed up and can you put a progress bar in django admin Please let me know I've bee trying to figure how to do that but nobody answering thanks for your time
The admin should really only be accessible to admins, never end users. If that's what you want your admins to see for every user, you can do that. You'd need to override the appropriate template(s).
@@thedumbfounds767 Ok so I have to build one then in html or in python but I can't use the one that django has then. I want to build one like this for users blackrockdigital.github.io/startbootstrap-sb-admin/
@@chrisgomez7070 yes, if it's for end users, DON'T use the built-in admin (it's meant for admins of the website itself). If you haven't done so yet, learn the basics of the web (frontend / backend), starting with the basics of the frontend, and take it from there.
@@thedumbfounds767 Ok thanks
13:31 for some reason the package apps is not in the installed suit from '> pip install djang-suit' ,,, i found it with this one : '> pip install github.com/darklow/django-suit/tarball/v2'
anyway it always complain that 'module named 'suit' ' did not find...
thanx a ton dude.....really helped me
@@vaibhavshukla5673 No problem! :)
Sir i have just started learning django. I do not get admin.site.register
it says admin.site has no attribute register.
it shows admin.register but i cant use it/
YOUR HELP WILL BE HIGHLY APPRECIATED
Could you share your admin.py file?
from django.contrib import admin
# Register your models here.
from .models import Question,Choice
@admin.register(Question)
@admin.register(Choice)
from django.contrib import admin
# Register your models here.
from .models import Question,Choice
admin.site.register(Question)
admin.site.register(Choice)
at first i tried this. bus got an error.AFter that i used @admin but its of no use.
@@intertainment1261 that's weird. Is your project on github? If yes, I'll try to replicate the error.
I followed tutorials again. Got it right.
May be i have missed one statement.Thanks a lot Sir!. You are a great teacher as well as great responser. YOur reply means a lot to me.
Thanks once again.
I cant get into the admin interface, becouse of 404 error
you havent added the admin url to root url config. Check it
;/ good
Please upload the full code in GitHub
Not full customization
Video summary:
142 likes 0 dislike
186 likes 0 dislike
For thoso who are getting "Django 'No module named 'suit.apps' error" do the following :
pip uninstall django-suit
pip install github.com/darklow/django-suit/tarball/v2
I keep getting Udemy ads for python and they disturb me. I will never use Udemy..
"Python's where it's at. You can do almost anything with it. You know, you should check out this..."
I understood nothing at all !
Great , thank you a lot
:)