create an admin's like application in django - 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)

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.

Ember application with an admin site

I'm creating a basic Ember application. I am trying to set up a backend that stores posts. I would like to have a system where I can go to some admin site that has a form that has all the fields for a post that allows me to add, update, and delete posts. For example, if I have a Post model with attributes like Title, Contents, Date_created, and Image, I would like to have these fields in a form in some kind of admin site.
One example from a past tutorial I have done is the Django admin site. Is it possible to set up a Django backend for my Ember app? The Django admin is here: (scroll to bottom)
https://docs.djangoproject.com/en/1.10/intro/tutorial02/
I know that asking how to set up a backend for my Ember application is a very general question, but I am confused as to where to start. I have already created a Post model with various attributes. I can create an Ember route that is a form to add a post, but then there comes authentication for that which I'm not really sure how to deal with either. That's why I came to Django because I remember they had a very nice admin site.
If it is not feasible to use Django to accomplish this, what are some other routes I can take to be able to get to some admin page where I can manipulate records and add new data to my website?
This is a pretty big question, but I feel your pain. Most tutorials are all, "so... just build out a rails app... or use all this long lost stubbing stuff... or here's a super outdated node server on github to use."
I would suggest breaking it down into pieces. Ember is really great, but–Yes–you need a backend. You could make a backend with Django(python), Rails(ruby), WordPress(PHP) + ember-wordpress, express or hapi(node), phoenix(elixir)- or really anything that will generate an API. You could also build an admin with Ember and then use that to send data to a service like parse or firebase. Those could get you an MVP while you learn more about how to build out a traditional back-end.
Django + http://www.django-rest-framework.org has a pretty great admin setup that builds out the admin and fields from your API specifications. I can see why people like it.
I would also mention, that ember-cli-mirage is great when you aren't sure what backend you'll have, but you need to have a mock-server to build off of.
If you can, choose something that will spit out an API with jsonAPI.
I would split this into 2 parts.
build out an Ember app with Mirage or some other temporary data.
build a back-end somehow.
Then you can connect them ~ without being stuck beforehand.
Good luck!
So pretty much a blog site where only person can create/delete/edit posts? If so then all you have to do is create a user with a predefined username and password in your Django app. You login through your Ember app. For this protected view you will need to use ember-simple-auth, which is the simplest way to implement something like this. Google ember-simple-auth and run its dummy app to see what they are doing.

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

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?

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

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.