On Jul 17, 3:06 pm, cornjuliox <teh.sa...@gmail.com> wrote: > Hi everyone. I'm new to Django, learning things mostly through trial > and error, but this time I can't seem to figure out what went wrong. I > overrode the admin change_form.html for my model so that I could add a > Javascript RTE that I found, but not only does the text area look > broken (it's split in two, on separate lines), the slug field no > longer prepopulates (it did before I changed things). The RTE works as > expected, though. I'm not sure what I'm supposed to be pasting in > order to get an accurate diagnosis, so here's everything I think is > relevant.
> This is the model in question: > class Entry(models.Model): > # ALL TITLES MUST BE UNIQUE! The slug is gonna give me problems if > it isn't. > title = models.CharField(max_length=250, unique=True) > slug = models.SlugField( > help_text="This field will be filled in automatically based on > the title field.\ > You don't need to fill this in. Honest." > ) > subject = models.CharField(max_length=140) > category = models.ManyToManyField(Category) > author = models.ForeignKey(User) > dateTime = models.DateTimeField(default=datetime.datetime.now) > content = models.TextField() > content_html = models.TextField() > > class Meta: > ordering = ['-dateTime'] > verbose_name_plural = "Entries" > > def __unicode__(self): > return self.title > > def get_aboslute_url(self): > return "/%s/%s" % (self.dateTime.strftime("%Y/%b/%d").lower > (),self.slug) > > def save(self): > html_data = markdown.markdown(self.content) > super(Entry, self).save() > > This is the modeladmin for the model: > class EntryAdmin(admin.ModelAdmin): > fields = ('title', 'subject', 'slug', 'dateTime', 'category', > 'content',) > prepopulated_fields = {'slug' : ('title',)} > date_hierarchy = 'dateTime' > list_filter = ('dateTime',) > > def save_model(self, request, object, form, change): > if not change: > object.author = request.user > object.save() > > And this is the new form: > {% extends "admin/change_form.html" %} > {% block form_top %} > <p>A customized entry form.</p> > {% endblock %} > > {% block extrahead %} > <script src="http://js.nicedit.com/nicEdit-latest.js" type="text/ > javascript"></script> > <script type="text/javascript">bkLib.onDomLoaded > (nicEditors.allTextAreas);</script> > {% endblock %} > > I placed this file in my templates dir, in the /admin/(my_app)/Entry > folder. Any help would be greatly appreciated, because I'm really > stuck on this one. I'm not sure if this will help but try adding {{ block.super}} somewhere in your {% block extrahead %} section as it sounds like you may have inadvertantly stopped some JavaScript from loading. -- G --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---