How to customize admin filter in Django 1.4
By : Mike Miersen
Date : March 29 2020, 07:55 AM
around this issue There is new django.contrib.admin.SimpleListFilter introduced in v1.4 meet your need, and official document provide sample code and easy to read. search SimpleListFilter in this section.
|
Customize Django Admin Advice
By : Sergey Mitrofanov
Date : March 29 2020, 07:55 AM
help you fix your problem This is quite a broad question but I'll give it a shot. There are a few ways you can achieve this: code :
class Filter(models.Model):
Filter_Query = models.CharField(max_length=30)
from app_name.models import Filter, Some_Model
def filter(request, pk):
template = loader.get_template("app_name/filter_search.html")
filter_1 = Filter.objects.get(id=pk)
some_model = Some_Model.objects.all()
filter_1_search = model_name.filter(some_option=filter_1)
context = RequestContext(request, {'filter_1_search': filter_1_search})
return HttpResponse(template.render(context))
{$("#some_div").load(filter/1)
from app_name.models import Some_Model
def filter_query(request):
filter_1 = request.GET.get('filter_query', '')# Receives from AJAX
some_model = Some_Model.objects.all()
filter_1_search = model_name.filter(some_option=filter_1)
jsonDump = json.dumps(str(filter_1_search))
return HttpResponse(jsonDump, content_type='application/json')
var data_JSON_Request = {'filter_query': filter_search1, 'csrfmiddlewaretoken': "{{csrf_token}}"};//JSON package.
function ajax_call(data_JSON_Request){
$(function jQuery_AJAX(){
$.ajax({
type: 'GET',
url: '/filter_query/',
data: data_JSON_Request,
datatype: "json",
success: function(data) {$("#sove_div").load(data);
open_model_menu();
},//success
error: function() {alert("failed...");}
});//.ajax
});//jQuery_AJAX
};//ajax_call
|
how to customize django admin panel model columns? django
By : pdpascual
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You can create a function in the "ModelAdmin" subclass that renders custom content in the results table for each entry, like in this answer. For example, let's say that your "download" text in your table links to a Google search (" https://www.google.com.au/search?q=test"). You can do something like this: code :
from django.contrib import admin
class EmployeeAdmin(admin.ModelAdmin):
fields = ('name')
list_display = ('name', 'download')
def download(self, obj):
return '<a href=https://www.google.com.au/search?q="' + obj.name + '">' + obj.name + '</a>'
download.allow_tags = True
|
How can I customize Django Admin?
By : Eduard Dobrynin
Date : March 29 2020, 07:55 AM
it should still fix some issue Yes you can, first you have to import your admin templates, read this how to collect admin templates file in django . Also you have to collect admin static typing manage.py collectstatic, then you can modify your static and your templates. Your question is too broad, so let me know if you want to know more
|
How to customize django admin
By : user2655647
Date : March 29 2020, 07:55 AM
this one helps. You can do it as follows: Create a custom admin template. Copy the standard template from the django installation into the directory yourproject/templates/admin/youapp/yourmodel/change_list.html Replace the names yourproject etc. with your names. code :
class YourAdmin(admin.ModelAdmin):
change_list_template = 'admin/yourapp/yourmodel/change_list.html'
{% block pagination %}{% pagination cl %}{% endblock %}
<!--Inserted code starts here-->
<input type="message" name="mail_subject">
<textarea type="message" name="mail_message"><textarea>
<!--End of inserted code-->
</form>
</div>
</div>
{% endblock %}
def send_mail(self, request, queryset):
form_data = request.POST.dict()
subject= form_data["mail_subject"]
message = form_data["mail_message"]
... and then send your emails
|