Django admin changelist view used in the users site - python

Basically the admin changelist view has a lot of nice features like sorting, filtering, field list, pagination...
Can I borrow that functionality and use it in my public users site? I was thinking to have class-based view called Cars and borrow all those features from the admin site.
I thought that ModelAdmin would be a place to look, but I have no idea to implement that.

The django-table2 app is more reasonable option for such task than the admin's changelist.

Actually I ended up using django admin for this site instead of developing a public site. Plus on top of this I used django-grappelli to customize the dashboard and make it look like a custom site.
So now I have two admin sites:
1- is the default django/grappelli site that has all the links and functions of the traditional admin site. and this was only used by developers and super users
2- a custom admin site called dashboard that looks more user friendly, and have customized all the look and feel, plus it has the change list, change form of my models so I don't have to rewrite these functions.
and this is how it looks now:

Related

Django ArrayField on Frontend Form?

I'm currently in the process of rebuilding my WordPress website into a full Django web app. With WordPress, I had made great use of the awesome Advanced Custom Fields plugin, and I'm struggling to get the same functionality with Django. One field in particular with ACF is called a "Repeater Field" that lets me click a button to add another row to an array.
I did manage to get something similar working with Django, but only in the Admin part. I've used this plugin "Django Better Admin ArrayField" - https://github.com/gradam/django-better-admin-arrayfield and it displays the arrayfield exactly as I want:
Django Better Admin ArrayField
How can I get this to work on the frontend of the site, like in a user-submitted form?

Adding a Non-Model Form in Django Admin

I am trying to add a non-model form in django admin interface and am not able to find any particular way to do it. This form would do some processing and change some data in the DB. But this is not related to a particular Model and should stand out. This form should not be available for the user to use.
One thing I can do is add the form to the general view and prohibit using permissions but I was thinking since django admin interface already exists, it would be better to add that to the django admin interface.
Is this possible to do in Django?
You can add arbitrary views that within a ModelAdmin that do whatever you want. See the documentation for ModelAdmin.get_urls. You can do the same at a higher level by defining AdminSite.get_urls.

Django Employee Profile Page Customization

I am new to Django as well as Python. I am trying to build a Employee management System using django framework.
Till now I was able to build models and show the models in admin module. Now I want to show user a user profile and able to update their details.
I am still in starting phase of the project. What I want to do is, I want show the profile page in the below format i.e similar to admin page look.
But till now I was able to get like below
Is it possible to make profile page of each employee look just like admin page look? which has collapsible options as well
You will need to write your views as well as create you template folder with the relevant template tag.
I believe that is what will get you what you want.
The models you create shows the database columns and rows you want Django to create.
Please check the link below assuming you are using Django 1.6:
https://docs.djangoproject.com/en/1.6/intro/tutorial03/
The collapsible part of Django admin, is made with JavaScript (jQuery) & CSS.
If you want your page to be dynamic, use JavaScript.
If you want to make it more beautiful, use CSS.

Django. Edit model form in popup in admin

Is there any ready apps for django admin, that allows to edit model in popup?
I want next functionallity:
View edit form for model in popup.
On model save - update row in list of models.
Motivation: reduce page reloads.
Also, if there any solutions oriented on massive manual data updates for django? I've taken a look at django grappelli - it improves view of data, but edit data is still not usable.
P.S.: If such kind of app is not available - I'll start open source project.
If you want to open a popup, simply create a link to your 'add' view with the following attribute on that link onclick='return showAddAnotherPopup(this);'
You can do most of what you ask there (at least point 1 and 2) using the django built in admin customisations.
Have a look at https://docs.djangoproject.com/en/dev/ref/contrib/admin/
The django admin itself already uses some things similar to this, pay special attention to the django _popup=1 variable in the request URI.
You will have to add a custom modelname_change_list.html file to provide some javascript and in the ModelAdmin override the delet_view, change_view, response_add and potentially response_change.

Django AdminSite - Difficult or Easy Implementation?

Has anyone implemented their own AdminSite? How easy/hard was the basic implementation?
I'm in the midst of building a "cms" that's going to be quite large and decently complex in some areas and I'm wondering if using something like AdminSite would save some time. I'd rather not have to make my own implementation for admin actions and inlines and the like (I know I can just use inline forms but that's not as simple as inlines = [Foo]).
When using a custom AdminSite, is further customization equivalent to customizing the standard Django admin?
You've read the admin site docs. It's a lengthy document, but two main hooks for adding custom functionality is through custom urls and modified standard views in your own AdminSite and ModelAdmin objects. Once you hook those in and the urls get mapped, it's just like building any other Django application, only that the templates aren't yours, so they're are a bit hard to manage and take getting used to. But it allows you to do additional gymnastics, like adding a form wizard to the admin site or splitting everything into multiple forms and rendering them in a single HTML form element in the templates, doing custom handling of GET/POST requests, etc.
I've used it in the past to create views for displaying custom reports and to create custom editing scenarios for the staff. My opinion is that you should KISS as much as possible. The admin site is all about generic views and generic presentation. Do expand, but be cautious if you override template blocks and think twice before you override something that's not wrapped in a block. Certain admin site features have certain presentation assumptions and the JS client app that's shipped with Django makes some too (that's what I've figured when working with adding dynamic inline models way back), so it'd be quite an undertaking if you'd like to roll a completely different presentation.
The answer in any case is YES! The admin site will provide you with more features for managing your model data interactively. I don't know how extensively you'd need to customize the admin, but there are CMSs, dedicated admin apps and admin integrated apps that are a real eye-opener. Django CMS, as I recalled, has been praised as the best open-source Django CMS out there and from what I can see it rolls it's own cust change/list views. Rosetta is an admin site only app that allows you to edit your translation files interactively and has an exhaustive admin interface! If you shop around on bitbucket and github you'll find many more examples, it should help you figure out best how much effort you'd need to put into it.
Both
If you are OK with it not doing exactly what you want its pretty much done for you automatically. If you need fine grain control over certain things it can be hard to customize without knowing the internals of the admin code.
the django admin is more of a one size fits all kind of ui which may not be intuitive for use in some cases ..
customizing its look is easy but extending it is some how hard. you are better off designing your own views in that case.

Categories

Resources