Changes between Version 39 and Version 40 of NewformsAdminBranch


Ignore:
Timestamp:
12/03/2007 08:40:31 PM (8 years ago)
Author:
gwilson
Comment:

updated code snippets for __unicode__ and max_length

Legend:

Unmodified
Added
Removed
Modified
  • NewformsAdminBranch

    v39 v40  
    8787# a sample models.py file
    8888from django.db import models
     89from django.contrib import admin
    8990
    9091class Author(models.Model):
    91     first_name = models.CharField(maxlength=30)
    92     last_name = models.CharField(maxlength=30)
    93 
    94     def __str__(self):
    95         return '%s %s' % (self.first_name, self.last_name)
     92    first_name = models.CharField(max_length=30)
     93    last_name = models.CharField(max_length=30)
     94
     95    def __unicode__(self):
     96        return u'%s %s' % (self.first_name, self.last_name)
    9697
    9798class Book(models.Model):
    98     title = models.CharField(maxlength=100)
     99    title = models.CharField(max_length=100)
    99100    author = models.ForeignKey(Author)
    100 
    101 from django.contrib import admin
    102101
    103102class BookOptions(admin.ModelAdmin):
     
    168167# OLD:
    169168class MyModel(models.Model):
    170     first_name = models.CharField(maxlength=30)
    171     last_name = models.CharField(maxlength=30)
    172     slug = models.CharField(maxlength=60, prepopulate_from=('first_name', 'last_name'))
     169    first_name = models.CharField(max_length=30)
     170    last_name = models.CharField(max_length=30)
     171    slug = models.CharField(max_length=60, prepopulate_from=('first_name', 'last_name'))
    173172
    174173    class Admin:
     
    177176# NEW:
    178177class MyModel(models.Model):
    179     first_name = models.CharField(maxlength=30)
    180     last_name = models.CharField(maxlength=30)
    181     slug = models.CharField(maxlength=60)
     178    first_name = models.CharField(max_length=30)
     179    last_name = models.CharField(max_length=30)
     180    slug = models.CharField(max_length=60)
    182181
    183182from django.contrib import admin
     
    273272    raw_id_fields = ('field1',)
    274273}}}
    275 
Back to Top