|
Posted by fyoung |
|
|
In my admin, I want my "slug" field to be prepopulated with the 'name' field. I'm using the below code but it isn't working. Maybe I should be importing the prepopulated field? Please let me know if you have any advice. I left out some of the code but I think I included all that's needed to debug the problem. Let me know if you require any additional information though. Thanks!
from django.contrib import admin from django.contrib.contenttypes import generic from django.contrib.localflavor.us.forms import USZipCodeField from django import forms from guide.businesses.models import * from guide.media.admin import RelatedPhotoInline, RelatedVideoInline, RelatedLinkInline from guide.restaurants.admin import RestaurantInline from guide.bars.admin import BarInline class UserSubmittedBusinessAdmin(admin.ModelAdmin): form = UserSubmittedBusinessAdminForm list_display = ('name', 'full_address', 'city', 'user', 'colored_status', 'is_change') list_filter = ['is_approved', 'is_change', 'city', 'sites'] search_fields = ['name', 'user'] filter_horizontal = ('categories', 'sites') prepopulated_fields = {"slug": ("name",),} raw_id_fields = ('city', 'neighborhood', 'street', 'user') fieldsets = ( (None, { 'fields': ('name', 'slug', 'sort_name'), }), ('Location', { 'fields': ('full_address', 'city', 'neighborhood', ('address', 'direction', 'street'), 'address_helper'), }), ('Contact', { 'fields': ('phone', 'fax', 'email', 'website'), }), ('Payment', { 'fields': ('accepts_amex', 'accepts_discover', 'accepts_mastercard', 'accepts_visa', 'accepts_checks', 'accepts_beakembucks'), }), ('Details', { 'fields': ('is_local_establishment', 'is_chamber_of_commerce_member', 'is_closed', 'wifi_access', 'description', 'other_information', 'categories', 'sites'), }), ('Approval', { 'fields': ('send_email_notification', 'reason_for_rejection') }), ) admin.site.register(UserSubmittedBusiness, UserSubmittedBusinessAdmin) |


