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.
Related
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?
I am new to Django. I have read the official documentations and managed to create models in Django. I have a task to create an estimator tool that could provide the estimate(cost) to the user when he selects the hardware/softwares etc. This could be something similar to this http://calculator.s3.amazonaws.com/index.html. This is only for reference but I want to add details dynamically.
Basically I am curious to know about:
How to add rows in Django?
How is the 'Monthly cost' working in amazon calculator?
I want to achieve something similar to this dynamic estimations.
Any pointers/articles/suggestions will be helpful in my learning and analysis.
You have to override the Django admin template for that.
How to add button next to Add User button in Django Admin Site
for auto-selecting the group value you can use
https://github.com/crucialfelix/django-ajax-selects
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.
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
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.