Django

Code

Changeset 1631

Show
Ignore:
Timestamp:
12/13/05 23:02:51 (3 years ago)
Author:
adrian
Message:

magic-removal: Moved django.core.meta to django.db.models

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/django/conf/app_template/models/app_name.py

    r3 r1631  
    1 from django.core import meta 
     1from django.db import models 
    22 
    33# Create your models here. 
  • django/branches/magic-removal/django/contrib/admin/filterspecs.py

    r1600 r1631  
    77""" 
    88 
    9 from django.core import meta 
     9from django.db import models 
    1010import datetime 
    1111 
     
    5151    def __init__(self, f, request, params): 
    5252        super(RelatedFilterSpec, self).__init__(f, request, params) 
    53         if isinstance(f, meta.ManyToManyField): 
     53        if isinstance(f, models.ManyToManyField): 
    5454            self.lookup_title = f.rel.to._meta.verbose_name 
    5555        else: 
     
    104104        today = datetime.date.today() 
    105105        one_week_ago = today - datetime.timedelta(days=7) 
    106         today_str = isinstance(self.field, meta.DateTimeField) and today.strftime('%Y-%m-%d 23:59:59') or today.strftime('%Y-%m-%d') 
     106        today_str = isinstance(self.field, models.DateTimeField) and today.strftime('%Y-%m-%d 23:59:59') or today.strftime('%Y-%m-%d') 
    107107 
    108108        self.links = ( 
     
    127127                   'display': title} 
    128128 
    129 FilterSpec.register(lambda f: isinstance(f, meta.DateField), DateFieldFilterSpec) 
     129FilterSpec.register(lambda f: isinstance(f, models.DateField), DateFieldFilterSpec) 
    130130 
    131131class BooleanFieldFilterSpec(FilterSpec): 
     
    145145                   'query_string': cl.get_query_string( {self.lookup_kwarg: v}, [self.lookup_kwarg2]), 
    146146                   'display': k} 
    147         if isinstance(self.field, meta.NullBooleanField): 
     147        if isinstance(self.field, models.NullBooleanField): 
    148148            yield {'selected': self.lookup_val2 == 'True', 
    149149                   'query_string': cl.get_query_string( {self.lookup_kwarg2: 'True'}, [self.lookup_kwarg]), 
    150150                   'display': _('Unknown')} 
    151151 
    152 FilterSpec.register(lambda f: isinstance(f, meta.BooleanField) or isinstance(f, meta.NullBooleanField), BooleanFieldFilterSpec) 
     152FilterSpec.register(lambda f: isinstance(f, models.BooleanField) or isinstance(f, models.NullBooleanField), BooleanFieldFilterSpec) 
  • django/branches/magic-removal/django/contrib/admin/models.py

    r1610 r1631  
    1 from django.core import meta 
     1from django.db import models 
    22from django.models import auth, core 
    33from django.utils.translation import gettext_lazy as _ 
    44 
    5 class LogEntry(meta.Model): 
    6     action_time = meta.DateTimeField(_('action time'), auto_now=True) 
    7     user = meta.ForeignKey(auth.User) 
    8     content_type = meta.ForeignKey(core.ContentType, blank=True, null=True) 
    9     object_id = meta.TextField(_('object id'), blank=True, null=True) 
    10     object_repr = meta.CharField(_('object repr'), maxlength=200) 
    11     action_flag = meta.PositiveSmallIntegerField(_('action flag')) 
    12     change_message = meta.TextField(_('change message'), blank=True) 
     5class LogEntry(models.Model): 
     6    action_time = models.DateTimeField(_('action time'), auto_now=True) 
     7    user = models.ForeignKey(auth.User) 
     8    content_type = models.ForeignKey(core.ContentType, blank=True, null=True) 
     9    object_id = models.TextField(_('object id'), blank=True, null=True) 
     10    object_repr = models.CharField(_('object repr'), maxlength=200) 
     11    action_flag = models.PositiveSmallIntegerField(_('action flag')) 
     12    change_message = models.TextField(_('change message'), blank=True) 
    1313    class META: 
    14         module_name = 'log' 
    1514        verbose_name = _('log entry') 
    1615        verbose_name_plural = _('log entries') 
  • django/branches/magic-removal/django/contrib/admin/templatetags/adminapplist.py

    r1443 r1631  
    88 
    99    def render(self, context): 
    10         from django.core import meta 
     10        from django.db import models 
    1111        from django.utils.text import capfirst 
    1212        app_list = [] 
    1313        user = context['user'] 
    1414 
    15         for app in meta.get_installed_model_modules(): 
     15        for app in models.get_installed_model_modules(): 
    1616            app_label = app.__name__[app.__name__.rindex('.')+1:] 
    1717            has_module_perms = user.has_module_perms(app_label) 
  • django/branches/magic-removal/django/contrib/admin/templatetags/admin_list.py

    r1443 r1631  
    22from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR 
    33from django.contrib.admin.views.main import IS_POPUP_VAR, EMPTY_CHANGELIST_VALUE, MONTHS 
    4 from django.core import meta, template 
     4from django.core import template 
    55from django.core.exceptions import ObjectDoesNotExist 
     6from django.db import models 
    67from django.utils import dateformat 
    78from django.utils.html import strip_tags, escape 
     
    7576        try: 
    7677            f = lookup_opts.get_field(field_name) 
    77         except meta.FieldDoesNotExist: 
     78        except models.FieldDoesNotExist: 
    7879            # For non-field list_display values, check for the function 
    7980            # attribute "short_description". If that doesn't exist, fall 
     
    9091            yield {"text": header} 
    9192        else: 
    92             if isinstance(f.rel, meta.ManyToOne) and f.null: 
     93            if isinstance(f.rel, models.ManyToOne) and f.null: 
    9394                yield {"text": f.verbose_name} 
    9495            else: 
     
    111112        try: 
    112113            f = cl.lookup_opts.get_field(field_name) 
    113         except meta.FieldDoesNotExist: 
     114        except models.FieldDoesNotExist: 
    114115            # For non-field list_display values, the value is a method 
    115116            # name. Execute the method. 
     
    127128            field_val = getattr(result, f.attname) 
    128129 
    129             if isinstance(f.rel, meta.ManyToOne): 
     130            if isinstance(f.rel, models.ManyToOne): 
    130131                if field_val is not None: 
    131132                    result_repr = getattr(result, 'get_%s' % f.name)() 
     
    133134                    result_repr = EMPTY_CHANGELIST_VALUE 
    134135            # Dates and times are special: They're formatted in a certain way. 
    135             elif isinstance(f, meta.DateField) or isinstance(f, meta.TimeField): 
     136            elif isinstance(f, models.DateField) or isinstance(f, models.TimeField): 
    136137                if field_val: 
    137138                    (date_format, datetime_format, time_format) = get_date_formats() 
    138                     if isinstance(f, meta.DateTimeField): 
     139                    if isinstance(f, models.DateTimeField): 
    139140                        result_repr = capfirst(dateformat.format(field_val, datetime_format)) 
    140                     elif isinstance(f, meta.TimeField): 
     141                    elif isinstance(f, models.TimeField): 
    141142                        result_repr = capfirst(dateformat.time_format(field_val, time_format)) 
    142143                    else: 
     
    146147                row_class = ' class="nowrap"' 
    147148            # Booleans are special: We use images. 
    148             elif isinstance(f, meta.BooleanField) or isinstance(f, meta.NullBooleanField): 
     149            elif isinstance(f, models.BooleanField) or isinstance(f, models.NullBooleanField): 
    149150                BOOLEAN_MAPPING = {True: 'yes', False: 'no', None: 'unknown'} 
    150151                result_repr = '<img src="%simg/admin/icon-%s.gif" alt="%s" />' % (ADMIN_MEDIA_PREFIX, BOOLEAN_MAPPING[field_val], field_val) 
    151152            # ImageFields are special: Use a thumbnail. 
    152             elif isinstance(f, meta.ImageField): 
     153            elif isinstance(f, models.ImageField): 
    153154                from django.parts.media.photos import get_thumbnail_url 
    154155                result_repr = '<img src="%s" alt="%s" title="%s" />' % (get_thumbnail_url(getattr(result, 'get_%s_url' % f.name)(), '120'), field_val, field_val) 
    155156            # FloatFields are special: Zero-pad the decimals. 
    156             elif isinstance(f, meta.FloatField): 
     157            elif isinstance(f, models.FloatField): 
    157158                if field_val is not None: 
    158159                    result_repr = ('%%.%sf' % f.decimal_places) % field_val 
  • django/branches/magic-removal/django/contrib/admin/templatetags/admin_modify.py

    r1486 r1631  
    44from django.utils.functional import curry 
    55from django.contrib.admin.views.main import AdminBoundField 
    6 from django.core.meta.fields import BoundField, Field 
    7 from django.core.meta import BoundRelatedObject, TABULAR, STACKED 
     6from django.db.models.fields import BoundField, Field 
     7from django.db.models import BoundRelatedObject, TABULAR, STACKED 
    88from django.conf.settings import ADMIN_MEDIA_PREFIX 
    99import re 
  • django/branches/magic-removal/django/contrib/admin/views/doc.py

    r1522 r1631  
    1 from django.core import meta 
    21from django import templatetags 
    32from django.conf import settings 
    43from django.contrib.admin.views.decorators import staff_member_required 
    5 from django.models.core import site
     4from django.db import model
    65from django.core.extensions import DjangoContext, render_to_response 
    76from django.core.exceptions import Http404, ViewDoesNotExist 
    87from django.core import template, urlresolvers 
    98from django.contrib.admin import utils 
     9from django.models.core import sites 
    1010import inspect, os, re 
    1111 
     
    137137 
    138138    models = [] 
    139     for app in meta.get_installed_model_modules(): 
     139    for app in models.get_installed_model_modules(): 
    140140        for model in app._MODELS: 
    141141            opts = model._meta 
     
    153153 
    154154    try: 
    155         model = meta.get_app(model) 
     155        model = models.get_app(model) 
    156156    except ImportError: 
    157157        raise Http404 
  • django/branches/magic-removal/django/contrib/admin/views/main.py

    r1600 r1631  
    22from django.contrib.admin.views.decorators import staff_member_required 
    33from django.contrib.admin.filterspecs import FilterSpec 
    4 from django.core import formfields, meta, template 
     4from django.core import formfields, template 
    55from django.core.template import loader 
    6 from django.core.meta.fields import BoundField, BoundFieldLine, BoundFieldSet 
     6from django.db.models.fields import BoundField, BoundFieldLine, BoundFieldSet 
    77from django.core.exceptions import Http404, ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied 
    88from django.core.extensions import DjangoContext as Context 
     
    1414except ImportError: 
    1515    raise ImproperlyConfigured, "You don't have 'django.contrib.admin' in INSTALLED_APPS." 
     16from django.db import models 
    1617from django.utils.html import strip_tags 
    1718from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect 
     
    4142    "Helper function that returns a tuple of (module, opts), raising Http404 if necessary." 
    4243    try: 
    43         mod = meta.get_module(app_label, module_name) 
     44        mod = models.get_module(app_label, module_name) 
    4445    except ImportError: 
    4546        raise Http404 # Invalid app or module name. Maybe it's not in INSTALLED_APPS. 
     
    162163 
    163164        # Normalize it to new-style ordering. 
    164         ordering = meta.handle_legacy_orderlist(ordering) 
     165        ordering = models.handle_legacy_orderlist(ordering) 
    165166 
    166167        if ordering[0].startswith('-'): 
     
    172173                try: 
    173174                    f = lookup_opts.get_field(lookup_opts.admin.list_display[int(params[ORDER_VAR])]) 
    174                 except meta.FieldDoesNotExist: 
     175                except models.FieldDoesNotExist: 
    175176                    pass 
    176177                else: 
    177                     if not isinstance(f.rel, meta.ManyToOne) or not f.null: 
     178                    if not isinstance(f.rel, models.ManyToOne) or not f.null: 
    178179                        order_field = f.name 
    179180            except (IndexError, ValueError): 
     
    197198        try: 
    198199            f = lookup_opts.get_field(order_field) 
    199         except meta.FieldDoesNotExist: 
     200        except models.FieldDoesNotExist: 
    200201            pass 
    201202        else: 
    202             if isinstance(lookup_opts.get_field(order_field).rel, meta.ManyToOne): 
     203            if isinstance(lookup_opts.get_field(order_field).rel, models.ManyToOne): 
    203204                f = lookup_opts.get_field(order_field) 
    204205                rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column 
     
    212213                try: 
    213214                    f = lookup_opts.get_field(field_name) 
    214                 except meta.FieldDoesNotExist: 
     215                except models.FieldDoesNotExist: 
    215216                    pass 
    216217                else: 
    217                     if isinstance(f.rel, meta.ManyToOne): 
     218                    if isinstance(f.rel, models.ManyToOne): 
    218219                        lookup_params['select_related'] = True 
    219220                        break 
     
    224225                or_queries = [] 
    225226                for field_name in lookup_opts.admin.search_fields: 
    226                     or_queries.append(meta.Q(**{'%s__icontains' % field_name: bit})) 
     227                    or_queries.append(models.Q(**{'%s__icontains' % field_name: bit})) 
    227228                complex_queries.append(reduce(operator.or_, or_queries)) 
    228229            lookup_params['complex'] = reduce(operator.and_, complex_queries) 
     
    248249change_list = staff_member_required(change_list) 
    249250 
    250 use_raw_id_admin = lambda field: isinstance(field.rel, (meta.ManyToOne, meta.ManyToMany)) and field.rel.raw_id_admin 
     251use_raw_id_admin = lambda field: isinstance(field.rel, (models.ManyToOne, models.ManyToMany)) and field.rel.raw_id_admin 
    251252 
    252253def get_javascript_imports(opts,auto_populated_fields, ordered_objects, field_sets): 
     
    255256    if auto_populated_fields: 
    256257        js.append('js/urlify.js') 
    257     if opts.has_field_type(meta.DateTimeField) or opts.has_field_type(meta.TimeField) or opts.has_field_type(meta.DateField): 
     258    if opts.has_field_type(models.DateTimeField) or opts.has_field_type(models.TimeField) or opts.has_field_type(models.DateField): 
    258259        js.extend(['js/calendar.js', 'js/admin/DateTimeShortcuts.js']) 
    259260    if ordered_objects: 
     
    270271            try: 
    271272                for f in field_line: 
    272                     if f.rel and isinstance(f, meta.ManyToManyField) and f.rel.filter_interface: 
     273                    if f.rel and isinstance(f, models.ManyToManyField) and f.rel.filter_interface: 
    273274                        js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js']) 
    274275                        raise StopIteration 
     
    282283 
    283284        self.element_id = self.form_fields[0].get_id() 
    284         self.has_label_first = not isinstance(self.field, meta.BooleanField) 
     285        self.has_label_first = not isinstance(self.field, models.BooleanField) 
    285286        self.raw_id_admin = use_raw_id_admin(field) 
    286         self.is_date_time = isinstance(field, meta.DateTimeField) 
    287         self.is_file_field = isinstance(field, meta.FileField) 
    288         self.needs_add_label = field.rel and isinstance(field.rel, meta.ManyToOne) or isinstance(field.rel, meta.ManyToMany) and field.rel.to._meta.admin 
    289         self.hidden = isinstance(self.field, meta.AutoField) 
     287        self.is_date_time = isinstance(field, models.DateTimeField) 
     288        self.is_file_field = isinstance(field, models.FileField) 
     289        self.needs_add_label = field.rel and isinstance(field.rel, models.ManyToOne) or isinstance(field.rel, models.ManyToMany) and field.rel.to._meta.admin 
     290        self.hidden = isinstance(self.field, models.AutoField) 
    290291        self.first = False 
    291292 
     
    308309            return 
    309310        # HACK 
    310         if isinstance(self.field.rel, meta.ManyToOne): 
     311        if isinstance(self.field.rel, models.ManyToOne): 
    311312             func_name = 'get_%s' % self.field.name 
    312313             self._display = self._fetch_existing_display(func_name) 
    313         elif isinstance(self.field.rel, meta.ManyToMany): 
     314        elif isinstance(self.field.rel, models.ManyToMany): 
    314315            func_name = 'get_%s_list' % self.field.rel.singular 
    315316            self._display =  ", ".join([str(obj) for obj in self._fetch_existing_display(func_name)]) 
     
    355356        self.coltype = self.ordered_objects and 'colMS' or 'colM' 
    356357        self.has_absolute_url = hasattr(opts.get_model_module().Klass, 'get_absolute_url') 
    357         self.form_enc_attrib = opts.has_field_type(meta.FileField) and \ 
     358        self.form_enc_attrib = opts.has_field_type(models.FileField) and \ 
    358359                                'enctype="multipart/form-data" ' or '' 
    359360 
     
    400401    if request.POST: 
    401402        new_data = request.POST.copy() 
    402         if opts.has_field_type(meta.FileField): 
     403        if opts.has_field_type(models.FileField): 
    403404            new_data.update(request.FILES) 
    404405        errors = manipulator.get_validation_errors(new_data) 
     
    477478    if request.POST: 
    478479        new_data = request.POST.copy() 
    479         if opts.has_field_type(meta.FileField): 
     480        if opts.has_field_type(models.FileField): 
    480481            new_data.update(request.FILES) 
    481482 
     
    559560        opts_seen.append(related.opts) 
    560561        rel_opts_name = related.get_method_name_part() 
    561         if isinstance(related.field.rel, meta.OneToOne): 
     562        if isinstance(related.field.rel, models.OneToOne): 
    562563            try: 
    563564                sub_obj = getattr(obj, 'get_%s' % rel_opts_name)() 
  • django/branches/magic-removal/django/contrib/comments/models/comments.py

    r1364 r1631  
    1 from django.core import meta 
     1from django.db import models 
    22from django.models import auth, core 
    33from django.utils.translation import gettext_lazy as _ 
    44 
    5 class Comment(meta.Model): 
    6     user = meta.ForeignKey(auth.User, raw_id_admin=True) 
    7     content_type = meta.ForeignKey(core.ContentType) 
    8     object_id = meta.IntegerField(_('object ID')) 
    9     headline = meta.CharField(_('headline'), maxlength=255, blank=True) 
    10     comment = meta.TextField(_('comment'), maxlength=3000) 
    11     rating1 = meta.PositiveSmallIntegerField(_('rating #1'), blank=True, null=True) 
    12     rating2 = meta.PositiveSmallIntegerField(_('rating #2'), blank=True, null=True) 
    13     rating3 = meta.PositiveSmallIntegerField(_('rating #3'), blank=True, null=True) 
    14     rating4 = meta.PositiveSmallIntegerField(_('rating #4'), blank=True, null=True) 
    15     rating5 = meta.PositiveSmallIntegerField(_('rating #5'), blank=True, null=True) 
    16     rating6 = meta.PositiveSmallIntegerField(_('rating #6'), blank=True, null=True) 
    17     rating7 = meta.PositiveSmallIntegerField(_('rating #7'), blank=True, null=True) 
    18     rating8 = meta.PositiveSmallIntegerField(_('rating #8'), blank=True, null=True) 
     5class Comment(models.Model): 
     6    user = models.ForeignKey(auth.User, raw_id_admin=True) 
     7    content_type = models.ForeignKey(core.ContentType) 
     8    object_id = models.IntegerField(_('object ID')) 
     9    headline = models.CharField(_('headline'), maxlength=255, blank=True) 
     10    comment = models.TextField(_('comment'), maxlength=3000) 
     11    rating1 = models.PositiveSmallIntegerField(_('rating #1'), blank=True, null=True) 
     12    rating2 = models.PositiveSmallIntegerField(_('rating #2'), blank=True, null=True) 
     13    rating3 = models.PositiveSmallIntegerField(_('rating #3'), blank=True, null=True) 
     14    rating4 = models.PositiveSmallIntegerField(_('rating #4'), blank=True, null=True) 
     15    rating5 = models.PositiveSmallIntegerField(_('rating #5'), blank=True, null=True) 
     16    rating6 = models.PositiveSmallIntegerField(_('rating #6'), blank=True, null=True) 
     17    rating7 = models.PositiveSmallIntegerField(_('rating #7'), blank=True, null=True) 
     18    rating8 = models.PositiveSmallIntegerField(_('rating #8'), blank=True, null=True) 
    1919    # This field designates whether to use this row's ratings in aggregate 
    2020    # functions (summaries). We need this because people are allowed to post 
    2121    # multiple reviews on the same thing, but the system will only use the 
    2222    # latest one (with valid_rating=True) in tallying the reviews. 
    23     valid_rating = meta.BooleanField(_('is valid rating')) 
    24     submit_date = meta.DateTimeField(_('date/time submitted'), auto_now_add=True) 
    25     is_public = meta.BooleanField(_('is public')) 
    26     ip_address = meta.IPAddressField(_('IP address'), blank=True, null=True) 
    27     is_removed = meta.BooleanField(_('is removed'), help_text=_('Check this box if the comment is inappropriate. A "This comment has been removed" message will be displayed instead.')) 
    28     site = meta.ForeignKey(core.Site) 
     23    valid_rating = models.BooleanField(_('is valid rating')) 
     24    submit_date = models.DateTimeField(_('date/time submitted'), auto_now_add=True) 
     25    is_public = models.BooleanField(_('is public')) 
     26    ip_address = models.IPAddressField(_('IP address'), blank=True, null=True) 
     27    is_removed = models.BooleanField(_('is removed'), help_text=_('Check this box if the comment is inappropriate. A "This comment has been removed" message will be displayed instead.')) 
     28    site = models.ForeignKey(core.Site) 
    2929    class META: 
    3030        db_table = 'comments' 
     
    4444        } 
    4545        ordering = ('-submit_date',) 
    46         admin = meta.Admin( 
     46        admin = models.Admin( 
    4747            fields = ( 
    4848                (None, {'fields': ('content_type', 'object_id', 'site')}), 
     
    156156        return False 
    157157 
    158 class FreeComment(meta.Model): 
     158class FreeComment(models.Model): 
    159159    # A FreeComment is a comment by a non-registered user. 
    160     content_type = meta.ForeignKey(core.ContentType) 
    161     object_id = meta.IntegerField(_('object ID')) 
    162     comment = meta.TextField(_('comment'), maxlength=3000) 
    163     person_name = meta.CharField(_("person's name"), maxlength=50) 
    164     submit_date = meta.DateTimeField(_('date/time submitted'), auto_now_add=True) 
    165     is_public = meta.BooleanField(_('is public')) 
    166     ip_address = meta.IPAddressField(_('ip address')) 
     160    content_type = models.ForeignKey(core.ContentType) 
     161    object_id = models.IntegerField(_('object ID')) 
     162    comment = models.TextField(_('comment'), maxlength=3000) 
     163    person_name = models.CharField(_("person's name"), maxlength=50) 
     164    submit_date = models.DateTimeField(_('date/time submitted'), auto_now_add=True) 
     165    is_public = models.BooleanField(_('is public')) 
     166    ip_address = models.IPAddressField(_('ip address')) 
    167167    # TODO: Change this to is_removed, like Comment 
    168     approved = meta.BooleanField(_('approved by staff')) 
    169     site = meta.ForeignKey(core.Site) 
     168    approved = models.BooleanField(_('approved by staff')) 
     169    site = models.ForeignKey(core.Site) 
    170170    class META: 
    171171        db_table = 'comments_free' 
     
    173173        verbose_name_plural = _('Free comments') 
    174174        ordering = ('-submit_date',) 
    175         admin = meta.Admin( 
     175        admin = models.Admin( 
    176176            fields = ( 
    177177                (None, {'fields': ('content_type', 'object_id', 'site')}), 
     
    204204    get_content_object.short_description = _('Content object') 
    205205 
    206 class KarmaScore(meta.Model): 
    207     user = meta.ForeignKey(auth.User) 
    208     comment = meta.ForeignKey(Comment) 
    209     score = meta.SmallIntegerField(_('score'), db_index=True) 
    210     scored_date = meta.DateTimeField(_('score date'), auto_now=True) 
     206class KarmaScore(models.Model): 
     207    user = models.ForeignKey(auth.User) 
     208    comment = models.ForeignKey(Comment) 
     209    score = models.SmallIntegerField(_('score'), db_index=True) 
     210    scored_date = models.DateTimeField(_('score date'), auto_now=True) 
    211211    class META: 
    212212        module_name = 'karma' 
     
    243243        return int(round((4.5 * score) + 5.5)) 
    244244 
    245 class UserFlag(meta.Model): 
    246     user = meta.ForeignKey(auth.User) 
    247     comment = meta.ForeignKey(Comment) 
    248     flag_date = meta.DateTimeField(_('flag date'), auto_now_add=True) 
     245class UserFlag(models.Model): 
     246    user = models.ForeignKey(auth.User) 
     247    comment = models.ForeignKey(Comment) 
     248    flag_date = models.DateTimeField(_('flag date'), auto_now_add=True) 
    249249    class META: 
    250250        db_table = 'comments_user_flags' 
     
    273273            f.save() 
    274274 
    275 class ModeratorDeletion(meta.Model): 
    276     user = meta.ForeignKey(auth.User, verbose_name='moderator') 
    277     comment = meta.ForeignKey(Comment) 
    278     deletion_date = meta.DateTimeField(_('deletion date'), auto_now_add=True) 
     275class ModeratorDeletion(models.Model): 
     276    user = models.ForeignKey(auth.User, verbose_name='moderator') 
     277    comment = models.ForeignKey(Comment) 
     278    deletion_date = models.DateTimeField(_('deletion date'), auto_now_add=True) 
    279279    class META: 
    280280        db_table = 'comments_moderator_deletions' 
  • django/branches/magic-removal/django/contrib/flatpages/models/flatpages.py

    r1166 r1631  
    1 from django.core import meta, validators 
     1from django.core validators 
     2from django.db import models 
    23from django.models.core import Site 
    34from django.utils.translation import gettext_lazy as _ 
    45 
    5 class FlatPage(meta.Model): 
    6     url = meta.CharField(_('URL'), maxlength=100, validator_list=[validators.isAlphaNumericURL], 
     6class FlatPage(models.Model): 
     7    url = models.CharField(_('URL'), maxlength=100, validator_list=[validators.isAlphaNumericURL], 
    78        help_text=_("Example: '/about/contact/'. Make sure to have leading and trailing slashes.")) 
    8     title = meta.CharField(_('title'), maxlength=200) 
    9     content = meta.TextField(_('content')) 
    10     enable_comments = meta.BooleanField(_('enable comments')) 
    11     template_name = meta.CharField(_('template name'), maxlength=70, blank=True, 
     9    title = models.CharField(_('title'), maxlength=200) 
     10    content = models.TextField(_('content')) 
     11    enable_comments = models.BooleanField(_('enable comments')) 
     12    template_name = models.CharField(_('template name'), maxlength=70, blank=True, 
    1213        help_text=_("Example: 'flatpages/contact_page'. If this isn't provided, the system will use 'flatpages/default'.")) 
    13     registration_required = meta.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page.")) 
    14     sites = meta.ManyToManyField(Site) 
     14    registration_required = models.BooleanField(_('registration required'), help_text=_("If this is checked, only logged-in users will be able to view the page.")) 
     15    sites = models.ManyToManyField(Site) 
    1516    class META: 
    1617        db_table = 'django_flatpages' 
     
    1819        verbose_name_plural = _('flat pages') 
    1920        ordering = ('url',) 
    20         admin = meta.Admin( 
     21        admin = models.Admin( 
    2122            fields = ( 
    2223                (None, {'fields': ('url', 'title', 'content', 'sites')}), 
  • django/branches/magic-removal/django/contrib/redirects/models/redirects.py

    r1166 r1631  
    1 from django.core import meta 
     1from django.db import models 
    22from django.models.core import Site 
    33from django.utils.translation import gettext_lazy as _ 
    44 
    5 class Redirect(meta.Model): 
    6     site = meta.ForeignKey(Site, radio_admin=meta.VERTICAL) 
    7     old_path = meta.CharField(_('redirect from'), maxlength=200, db_index=True, 
     5class Redirect(models.Model): 
     6    site = models.ForeignKey(Site, radio_admin=models.VERTICAL) 
     7    old_path = models.CharField(_('redirect from'), maxlength=200, db_index=True, 
    88        help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'.")) 
    9     new_path = meta.CharField(_('redirect to'), maxlength=200, blank=True, 
     9    new_path = models.CharField(_('redirect to'), maxlength=200, blank=True, 
    1010        help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'.")) 
    1111    class META: 
     
    1515        unique_together=(('site', 'old_path'),) 
    1616        ordering = ('old_path',) 
    17         admin = meta.Admin( 
     17        admin = models.Admin( 
    1818            list_filter = ('site',), 
    1919            search_fields = ('old_path', 'new_path'), 
  • django/branches/magic-removal/django/core/management.py

    r1614 r1631  
    6161def get_sql_create(mod): 
    6262    "Returns a list of the CREATE TABLE SQL statements for the given module." 
    63     from django.core import db, meta 
     63    from django.core import db 
     64    from django.db import models 
    6465    final_output = [] 
    6566    for klass in mod._MODELS: 
     
    6768        table_output = [] 
    6869        for f in opts.fields: 
    69             if isinstance(f, meta.ForeignKey): 
     70            if isinstance(f, models.ForeignKey): 
    7071                rel_field = f.rel.get_related_field() 
    7172                data_type = get_rel_data_type(rel_field) 
     
    234235def get_sql_sequence_reset(mod): 
    235236    "Returns a list of the SQL statements to reset PostgreSQL sequences for the given module." 
    236     from django.core import db, meta 
     237    from django.core import db 
     238    from django.db import models 
    237239    output = [] 
    238240    for klass in mod._MODELS: 
    239241        for f in klass._meta.fields: 
    240             if isinstance(f, meta.AutoField): 
     242            if isinstance(f, models.AutoField): 
    241243                output.append("SELECT setval('%s_%s_seq', (SELECT max(%s) FROM %s));" % \ 
    242244                    (klass._meta.db_table, f.column, db.db.quote_name(f.column), 
     
    369371    "Initializes the database with auth and core." 
    370372    try: 
    371         from django.core import db, meta 
    372         auth = meta.get_app('auth') 
    373         core = meta.get_app('core') 
     373        from django.core import db 
     374        from django.db import models 
     375        auth = models.get_app('auth') 
     376        core = models.get_app('core') 
    374377        cursor = db.db.cursor() 
    375378        for sql in get_sql_create(core) + get_sql_create(auth) + get_sql_initial_data(core) + get_sql_initial_data(auth): 
     
    575578    yield "# into your database." 
    576579    yield '' 
    577     yield 'from django.core import meta
     580    yield 'from django.db import models
    578581    yield '' 
    579582    for table_name in db.get_table_list(cursor): 
    580         yield 'class %s(meta.Model):' % table2model(table_name) 
     583        yield 'class %s(models.Model):' % table2model(table_name) 
    581584        try: 
    582585            relations = db.get_relations(cursor, table_name) 
     
    589592                rel_to = rel[1] == table_name and "'self'" or table2model(rel[1]) 
    590593                if column_name.endswith('_id'): 
    591                     field_desc = '%s = meta.ForeignKey(%s' % (column_name[:-3], rel_to) 
     594                    field_desc = '%s = models.ForeignKey(%s' % (column_name[:-3], rel_to) 
    592595                else: 
    593                     field_desc = '%s = meta.ForeignKey(%s, db_column=%r' % (column_name, rel_to, column_name) 
     596                    field_desc = '%s = models.ForeignKey(%s, db_column=%r' % (column_name, rel_to, column_name) 
    594597            else: 
    595598                try: 
     
    611614                    extra_params['maxlength'] = row[3] 
    612615 
    613                 field_desc = '%s = meta.%s(' % (column_name, field_type) 
     616                field_desc = '%s = models.%s(' % (column_name, field_type) 
    614617                field_desc += ', '.join(['%s=%s' % (k, v) for k, v in extra_params.items()]) 
    615618                field_desc += ')' 
     
    635638    "Validates all installed models. Writes errors, if any, to outfile. Returns number of errors." 
    636639    import django.models 
    637     from django.core import meta 
     640    from django.db import models 
    638641    e = ModelErrorCollection(outfile) 
    639     module_list = meta.get_installed_model_modules() 
     642    module_list = models.get_installed_model_modules() 
    640643    for module in module_list: 
    641644        for mod in module._MODELS: 
     
    644647            # Do field-specific validation. 
    645648            for f in opts.fields: 
    646                 if isinstance(f, meta.CharField) and f.maxlength in (None, 0): 
     649                if isinstance(f, models.CharField) and f.maxlength in (None, 0): 
    647650                    e.add(opts, '"%s" field: CharFields require a "maxlength" attribute.' % f.name) 
    648                 if isinstance(f, meta.FloatField): 
     651                if isinstance(f, models.FloatField): 
    649652                    if f.decimal_places is None: 
    650653                        e.add(opts, '"%s" field: FloatFields require a "decimal_places" attribute.' % f.name) 
    651654                    if f.max_digits is None: 
    652655                        e.add(opts, '"%s" field: FloatFields require a "max_digits" attribute.' % f.name) 
    653                 if isinstance(f, meta.FileField) and not f.upload_to: 
     656                if isinstance(f, models.FileField) and not f.upload_to: 
    654657                    e.add(opts, '"%s" field: FileFields require an "upload_to" attribute.' % f.name) 
    655                 if isinstance(f, meta.ImageField): 
     658                if isinstance(f, models.ImageField): 
    656659                    try: 
    657660                        from PIL import Image 
     
    677680            # Check admin attribute. 
    678681            if opts.admin is not None: 
    679                 if not isinstance(opts.admin, meta.Admin): 
    680                     e.add(opts, '"admin" attribute, if given, must be set to a meta.Admin() instance.') 
     682                if not isinstance(opts.admin, models.Admin): 
     683                    e.add(opts, '"admin" attribute, if given, must be set to a models.Admin() instance.') 
    681684                else: 
    682685                    # list_display 
     
    687690                            try: 
    688691                                f = opts.get_field(fn) 
    689                             except meta.FieldDoesNotExist: 
     692                            except models.FieldDoesNotExist: 
    690693                                klass = opts.get_model_module().Klass 
    691694                                if not hasattr(klass, fn) or not callable(getattr(klass, fn)): 
    692695                                    e.add(opts, '"admin.li