Monday, September 27, 2010

setting environment PATH in ubuntu

open file /etc/environment and edit it, this change only affects the new sell. If you wanna apply change for current sell, do this: "
export PATH="${PATH}:"

Tuesday, September 14, 2010

reinstall grub on MBR

from ubuntu 9.10, grub 2 is installed by default.

if for some reasons, you installed windows after ubuntu on your machine, grub gone.

one of the ways to get your ubuntu back is reinstall grub on MBR. follow these steps
  • boot from an ubuntu livecd.
  • open terminal, type sudo -i
  • fdisk -l and find the partition where located linux
  • mkdir /media/root
  • mount /dev/sda(x) /media/root
  • grub-setup --root-directory=/media/root -m /media/root/boot/grub/device.map /dev/sda(x) 
run apt-get install grub-pc if needed.

Wednesday, June 2, 2010

how to use slug with django

2 options

on Admin

create a slug = models.SlugField(max_length = 200) in model

class ClientAdmin(admin.ModelAdmin):     prepopulated_fields = {'slug': ('name',)} admin.site.register(Client, ClientAdmin)
 
or
 
class test(models.Model):
    q = models.CharField(max_length=30)
    s = models.SlugField(editable=False) # hide from admin

    def save(self):
        if not self.id:
            self.s = slugify(self.q)

        super(test, self).save()
 

Monday, March 29, 2010

using CKeditor with django

CKEditor is the new version of famous FCKeditor. In this artical, I note the way we use CKEditor with django-1.1

Assumes that you have python and django-1.1 installed in your system. There're 2 steps that you should follow
  1. Download ckeditor from http://ckeditor.com/
  2. Download django-ck from http://code.google.com/p/django-ck/downloads/list
Then, take a look at wiki page at http://code.google.com/p/django-ck/w/list

All done, extract the ckeditor and copy it into your media folder. This step related to
  • Serve the static file in django http://docs.djangoproject.com/en/dev/howto/static-files/. Remember that you must avoid the url name /media resembling to admin media prefix.
Make some changes on settings.py, create CKEDITOR_PATH as exact URL to the ckeditor.js. Open ck/fields.py, set CKeditor.BasePath = "%s/js/ckeditor/";  Don't forget to add 'ck' to your installed apps in settings.py

That okies, all you need is follow the guide in wiki and make admin works.