Is it possible to replicate the django admin into the app? - django

Django provides a very useful admin interface but is it possible to replicate it inside the app as well to not writing extra code? I would only have to code the registration system but to use the django admin interface inside the app. Is it possible?

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)

Can i use django reversion only for Admin or front end as well

I am trying to use Django reversion so that i can have the audit log of all changes done to all models in front end application done in Angular JS as front end and Django REST as backend.
I am thinking of using Django Reversion and their docs say this
https://django-reversion.readthedocs.org/en/latest/how-it-works.html
Any models that use subclasses of VersionAdmin in the admin interface
will be automatically registered with django-reversion. As such, it is
only necessary to manually register these models if you wish to
override the default registration settings.
Now does that mean that i can only use that in admin site only and not on models being saved via frond end.
Of course you can use it in the frontend as well, study its API on how to create versions yourself and handle restoring of previous/deleted versions manually as you will have to integrate it with your UI yourself...

Should I use the Django admin for user submitted content?

I'm creating a site that will allow users to authenticate via Facebook and create content.
Should I use the Django admin interface for content creation or would it be smarter to create my own interface. If I should roll my own are there any good tutorials about this?
You can use admin login page and with custom URL redirection. Here is the working example for facebook authentication.
https://github.com/sivaa/django-social-auth-facebook
As a general rule, the django admin is best for validating your models during development and testing; and should not be used as a front end user interface.
Since each site/application has their own unique requirements, it is difficult to recommend a tutorial. Once you are familiar with django, you will find the following libraries helpful:
django-bootstrap-toolkit - this integrates the the excellent bootstrap css/javascript framework in django.
django-social-auth - allows your users to login using their social network credentials.
pinax project - a collection of common utilities for developing just about any kind of front end website.
For customizing the existing admin application:
grappelli - a custom skin for the admin
django-frontendadmin - edit models in the front end using template tags
django-admin-tools - customized widgets and UI elements for the admin application