Django: Add my own form to the admin backend? - python

I'm using the Django Admin module. It displays a list of models to edit by app. I would like to add another form to this list. It won't edit a specific model, but it will edit settings that are stored in the database. Is this possible?

You may check out Django Live Settings. It was split out of the Satchmo project and looks to do what you're looking for.
Otherwise, you may look into Overriding the Django Admin Templates. You could just override the index template and add your links to the bottom.

Related

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.

Adding new pages to Django Admin

I am looking for information on how to add entirely new pages to the django admin interface. I need to add a view that allows admins to change the contents of an existing text file. This view needs to exist within the existing django admin app. I am using django 1.9.
I found information on extending existing pages, but not adding entirely new pages. Is this possible?
Once you've written your view, you can include it in the admin by overriding get_urls.
An alternative is to override the AdminSite class, which also has a get_urls method. However this will require changing more code if you are not already using a custom AdminSite subclass.

How to add HTML content editor in Django admin view?

How would I add a rich-text HTML content editor in my Django admin view?
For example, if I want to change the content on my homepage, what python code would I have to input for the HTML to be displayed when I log into the admin portal?
I want to be able to view all of my pages (hopefully even be able to add/delete them), and edit the content directly from the admin view. Similar to something like this:
http://feincms-django-cms.readthedocs.org/en/latest/_images/item_editor_content.png
I appreciate any and all help! Thank you!
The html shown there is there cuz it is in the database. If what you want is a cms, there are several of those for django like django-cms, wagtail, mezzanine among others.
If, on the other hand, you have a model already and want to display it in the admin, you can register it:
from django.contrib import admin
from myproject.myapp.models import Author
class AuthorAdmin(admin.ModelAdmin):
pass
admin.site.register(Author, AuthorAdmin)
In that example, the Author model will show up in admin for edition.
In the last case, where you already have your model registered but you want to have a WYSIWYG editor, check the django-grid for that kind of package and find one suitable, or install one manually.
You have several options in case you want to try the second approach: ckeditor, tinymce, etc.

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.

How to add link at top of django admin list

I want to do the following:
I want to add a "Refresh" link at the top of the django admin page for a model. How can I do that? I want when people click on Refresh they go to another page that gets data from Google analytics API.
How can I add a link at the top of the admin page for a model? Thanks!
What I tried:
I tried overriding the change_list template for the django admin, but that did not work.
Overriding the change_list template is really your only choice. Did you get errors? or did your content not show up? The hierarchy of your templates directory is directly related to how/where Django looks for templates.
Double check the documentation on overriding admin templates. You may have made a simple mistake: https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#overriding-admin-templates

Categories

Resources