How use the filter of django Admin in my apps on my Projects - django

I tried to find a way to use the filter that gives the Django Admin in my applications, as you know by just adding "list_filter" in admin.py, to enter the Admin, our results can be filtered, I would like know if there are ways to use the same application but in my own projects
Thanks!!

You can use ListView and add a filter form to context. It's not like "add one line to admin class" but it does not need much time to do too.
Django has lots of magic in admin site because built-in powerful admin site is one of Django's killer features. So it works out-of-the-box without setting up static url and with only tiny admin module linking your models. But all this magic is not isolated and in most cases cannot be used outside the admin.

Related

Deploying Django admin and Site as different applications

Is there a way to deploy Django Admin and your main application separately, though both of them sharing the same Models / Business logic services.
I come from Grails background where you can create a plugin which can hold your Entities and common business logic and that plugin can be utilized by other application deployed and scaled separately though using the same Database. You don't have to repackage your plugin again for every change rather its just sibling folder to your other projects.
Can I achieve something similar with Django?
Assuming a typical setup, in order to be useful Django Admin needs access to project's apps and their models.
So a setup that you've described would require at least:
simple URLconf with just Django Admin
models and their Admin bindings for all apps that need Admin
settings with database credentials
Even if your models and Admin bindings are not dependent on other parts of the codebase,
extracting the above components to a separate project and then keeping everything
in sync sounds pretty hard.
Summarizing: I would say it's hard but possible if it's something that you really need,
but Django Admin hasn't been designed with such use case in mind.
Django admin is actually separate from the main application by placing it on its own url. Even if they know the admin url, users cannot log in to the site's admin unless they have already been assigned Staff status via the admin. You can set the admin prefix to anything you want, so if you want to "hide" the admin login page, just make it something long and random (good for security too), and basically no one but those you tell will even know where the admin site can be found.

Django views accessible in the admin site

I would like to embed front end views in my django admin site at any possible specified locale, maybe in a class or site admin dashboard;anywhere I feel is the best option.. Tried out a few git projects but seems they are not compatible with current django versions..any one offering any idea?!
The Django Admin site is intentionally a separate site, with its own views.
In any app you can make functions that compute various values; but the Admin for that app will need to define its own views, using whatever functions you like.

create an admin's like application in django

Im really confused about what is all i need to consider for creating a django aplication with almost similar functionality to it's own admin.
The index page should deploy the list of models the user has access to modify or create...almost the same as when you put admin.site.register(MyModel) but with permission restriction. Im not sure how should i ckeck permissions, and show 1 ,2 or many "ModelAdmis" on my main page.
btw admin users are redirected to the admin index page, non-admins go to my page
Before you consider creating a django admin from scratch, you should read the answers to this question Django Admin app or roll my own?
I couldn't find any resource on how to create a django admin from scratch, but here's what you should do if this is your first time overriding a framework's functionality (in my humble opinion):
Understand and make sure you are comfortable with the django admin app
start from the docs https://docs.djangoproject.com/en/1.7/#the-admin
Head over to the django admin app source code so you can start reading the internals of the functionality you want to implement/override in your new admin app.
source code can be found here https://github.com/django/django/tree/master/django/contrib/admin
(this may involve reading other apps source code too)
After those two steps you should have an idea on how the admin app is implemented and it's dependencies, then you can start creating your custom admin app.
an example on how this may go can be found in this qestion:
How to override Django admin's views?
If you are building something new, try to separate the UI from the backend. You can build your UI using react, angular or whatever and interact with django using the API. To build the API you can use the Django Rest Framework.
Don't use the Django Admin as a public interface. Use that only for the admins!
If you start to use the Django Admin as interface for your public site, you'll fight with the package to tailor and secure the views to avoid destructive actions. What happen if you forget a readonly field? What if the user deleted something ON_CASCADE?
Building the UI you are totally free and you can customise easily everything without fighting the django admin package (it's awesome package but is not provided for public use)

Custom Django admin panel

I want to use Django for a web application I'm building that will have an admin panel. I know that you need to just activate the admin app and you're ready to go. However, I would like to have a custom panel, I mean, I want to design the layout myself, I want to add menus and forms for the admin to insert new data in the database etc. Is it possible? or I should write a similar application that will have such features?
For more control over the layout (custom menus etc.) you should check django-admin-tools.
And if you take a look at Django's docs you'll learn that you can easily tweak and override most parts of the admin. For example here is a demonstration on how to use a custom form:
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#adding-custom-validation-to-the-admin
So the admin is pretty customizable. But the question if you should build your own app or reuse the admin depends pretty much on your specific needs. At least make sure you know in which directions the admin can be easily bend.
The sole purpose for Django's admin is to allow you to manipulate (add/edit/remove) data in your database. I think you should at least try to check what the admin is capable of before trying to reinvent the wheel. You'll soon discover the level of complex insight the admin allows you to have. Then you'll discover that making it yourself is unnecessary excess of work and you'll end up with modifying a couple of admin-templates and CSS styles.
Yes, you can customize Django Admin Panel, Django provides some sort of customization for showing database tables structure from their own, for that you can follow DJANGO ADMIN SITE DOC , it will really help you.
For the customizations beyond the Django admin site settings, you can customize admin panel add manual layout, by adding manual detailing in Django template files which are stored in Django environment, django/django/contrib/admin/templates/admin/index.html of your current Django version. You can update its HTML, CSS, and JS according to need.

What are some Apps or add ons that get used to customize Django Admin

Im looking for a list or just suggestions on some Django Admin must haves or things that people tend to use.
I'm particularly interested in adding a Wysiwyg or Markdown Editor to the the TextAreas in the Django Admin.
Any suggestions?
There are a number of apps that add wysiwyg editors to Django's admin, such as django-wysiwyg. There are also a couple of articles on this subject in Django's wiki. Some other django apps that are great for admin customization are django-admin-tools and grappelli. Beyond being a general ovehaul of the user interface, grappelli also includes support for the inclusion of a wysiwig editor. And as always, the Django docs are usually a good first stop.
Personanlly, I'm particularly fond of grappelli, it's been used to great effect on a number of Django projects, including mezzanine and a few of my own! Here's a preview of the facelift it gives Django's admin:
Have you take a look at this list ?
I use the django-adimin-tools myself, it lets you create custom menus and custom dashboard as well as custom css. Here is what it looks like pretty much out of the box. Items are draggable. More on that here.
I also used django-admin-bootstrapped which uses twitter bootstrap to make the admin look nicer. more information on it here.
Grapelli is probably the most popular though and I have been using it in my Mezzanine apps but haven't yet tried it in a vanilla Django app as of yet.