plz help me. I get a trouble with slug in forms. I creat forms from models. This is models.py
class hire_article(models.Model):
hiring = models.CharField(max_length=50)
slug = models.SlugField(max_length=200)
This is forms
from django import forms
from django.forms import ModelForm, Textarea
from django.utils.translation import ugettext_lazy as _
import datetime
from .models import hire_article
from django.template.defaultfilters import slugify
from django.db import models
from django.contrib import admin
class postform(ModelForm):
# class hire_articleAdmin(admin.ModelAdmin):
# prepopulated_fields = {"slug": ("hiring",)}
class Meta:
# more_infomation = MyFormField(max_length=200, required=False,
# help_text="Use puns liberally")
model = hire_article
# exclude = ['slug']
fields = '__all__'
This is admin.py
from django.contrib import admin
from .models import category, hire_article, localwork, salary, mode_work, exp_year, degree, sex, language
class hire_articleAdmin(admin.ModelAdmin):
prepopulated_fields = {"slug": ("hiring",)}
list_display = ('id', 'hiring', 'publication_date', 'namecompany', )
admin.site.register(hire_article, hire_articleAdmin)
It works only in admin . I want it work in forms too. Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire