Hi,

there is no problem using the database in place.
The problem occures when I try to create the database from scratch:

mysql -uroot -p%passwd% -e"drop database %database%"
mysql -uroot -p%passwd% -e"create database %database%"

python manage.py syncdb

Creating table auth_message
Creating table auth_group
Creating table auth_user
Creating table auth_permission
Creating many-to-many tables for Group model
Creating many-to-many tables for User model
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table application_docchunk
Creating table application_screenshot
Creating table application_proglanguage
Creating table application_application
Traceback (most recent call last):
  File "manage.py", line 11, in ?
    execute_manager(settings)
  File "C:\Applications\wiposoft\dev\python\django\core\management.py",
line 1297, in execute_manager
    execute_from_command_line(action_mapping, argv)
  File "C:\Applications\wiposoft\dev\python\django\core\management.py",
line 1221, in execute_from_command_line
    action_mapping[action]()
  File "C:\Applications\wiposoft\dev\python\django\core\management.py",
line 473, in syncdb
    cursor.execute(statement)
  File
"C:\Applications\wiposoft\dev\python\django\db\backends\util.py", line
12, in execute
    return self.cursor.execute(sql, params)
  File
"C:\Applications\wiposoft\dev\python\django\db\backends\mysql\base.py",
line 35, in execute
    return self.cursor.execute(sql, params)
  File "C:\soft\python24\Lib\site-packages\MySQLdb\cursors.py", line
137, in execute
    self.errorhandler(self, exc, value)
  File "C:\soft\python24\Lib\site-packages\MySQLdb\connections.py",
line 33, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1005, "Can't create table
'.\\wiposoftdev\\#sql-84_3e9.frm' (errno: 121)")


Here is my mode:

from django.db import models
from django.contrib.auth.models import User
from datetime import datetime

class Contact(models.Model):
    user        = models.ForeignKey(User)
    name        = models.CharField(_('name'),maxlength=200,unique=True)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = _('author')
        verbose_name_plural = _('authors')
        ordering = ['name']

    class Admin:
        list_display = ('name',)
        search_fields = ['name']

class ProgLanguage(models.Model):
    name        = models.CharField(_('name'),maxlength=200,unique=True)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = _('programming language')
        verbose_name_plural = _('programming languages')
        ordering = ['name']

    class Admin:
        list_display = ('name',)

class OperatingSystem(models.Model):
    name        = models.CharField(_('name'),maxlength=200,unique=True)

    def __str__(self):
        return self.name

    class Meta:
        ordering = ['name']

    class Admin:
        list_display = ('name',)
        search_fields = ['name']

class Software(models.Model):
    name        = models.CharField(_('name'),maxlength=200,unique=True)
    xp_compat   = models.BooleanField(_('MS Windows XP
compatible'),default=False)
    modified_on = models.DateTimeField(editable=False)
    short_desc  = models.TextField(_('short
description'),blank=True,null=True)
    comments    = models.TextField(_('comment'),blank=True,null=True)
    os          =
models.ManyToManyField(OperatingSystem,verbose_name=_('operating
system'),filter_interface=models.HORIZONTAL,blank=True,null=True)
    prgm_lang   =
models.ManyToManyField(ProgLanguage,verbose_name=_('programming
language'),filter_interface=models.HORIZONTAL,blank=True,null=True)

    def __str__(self):
        return self.name

    def save(self):
        self.modified_on = datetime.now()
        super(Software, self).save() # Call the "real" save() method

    def short_description(self):
         return self.short_desc
    short_description.allow_tags = True

    class Meta:
        verbose_name = _('third party software')
        verbose_name_plural = _('third party software')
        ordering = ['name']

    class Admin:
        list_display = ('name','short_description','modified_on')
        search_fields = ['name','short_desc']
        list_filter = ['modified_on','xp_compat','os','prgm_lang']
        fields = (
                  (None, {'fields': ('name','xp_compat')}),
                  (_('Short description and comments'), {
                   #'classes': 'collapse',
                   'fields' : ('short_desc','comments')
                   }),
                  (_('Links'), {
                   #'classes': 'collapse',
                   'fields' : ('os','prgm_lang')
                   }),
                 )
        js = (
             'js/tiny_mce/tiny_mce.js',
             'js/tiny_mce/textareas.js',
             )

class BusinessUnit(models.Model):
    name        = models.CharField(_('name'),maxlength=200,unique=True)
    admin       =
models.ForeignKey(Contact,verbose_name=_('applications administrator'))

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = _('business unit')
        verbose_name_plural = _('business units')
        ordering = ['name']

    class Admin:
        list_display = ('name','admin')
        search_fields = ['name']

class SoftwarePerUnit(models.Model):
    software      = models.ForeignKey(Software,edit_inline=True)
    business_unit = models.ForeignKey(BusinessUnit,
verbose_name=_('business unit'),core=True)
    net_dir       = models.CharField(_('network
directory'),maxlength=200,blank=True,null=True)
    nds_distrib   = models.BooleanField(_('NAL
distributed'),default=False)

    def __str__(self):
        return self.business_unit.name

    class Meta:
        verbose_name = _('per unit third party software')
        verbose_name_plural = _('per unit third party software')
        #order_with_respect_to = 'software'

class Application(models.Model):
    name         =
models.CharField(_('name'),maxlength=200,unique=True)
    dpt          = models.CharField(_('Owner
department'),maxlength=200,blank=True,null=True)
    net_dir      = models.CharField(_('network
directory'),maxlength=200,blank=True,null=True)
    user_prof    = models.CharField(_('Users
profile(s)'),maxlength=200,blank=True,null=True)
    nds_distrib  = models.BooleanField(_('NAL
distributed'),default=False)
    xp_compat    = models.BooleanField(_('MS Windows XP
compatible'),default=False)
    has_doc      = models.BooleanField(default=True,editable=False)
    modified_on  = models.DateTimeField(editable=False)
    short_desc   = models.TextField(_('short
description'),blank=True,null=True,help_text=_('Click on first button
to switch to full view and access more options.'))
    comments     =
models.TextField(_('comments'),blank=True,null=True,help_text=_('Use
this to type additional information for which there is no appropriate
field.'))
    business_unit= models.ForeignKey(BusinessUnit,
verbose_name=_('business unit'))
    admin        = models.ManyToManyField(Contact,
verbose_name=_('authors'),filter_interface=models.HORIZONTAL)
    related_app  = models.ManyToManyField("self",
verbose_name=_('related in-house
applications'),symmetrical=False,filter_interface=models.HORIZONTAL,blank=True,null=True)
    related_soft = models.ManyToManyField(Software,
verbose_name=_('third party
software'),filter_interface=models.HORIZONTAL,blank=True,null=True)
    os           =
models.ManyToManyField(OperatingSystem,verbose_name=_('operating
systems'),filter_interface=models.HORIZONTAL,blank=True,null=True)
    prgm_lang    = models.ManyToManyField(ProgLanguage,
verbose_name=_('programming
languages'),filter_interface=models.HORIZONTAL,blank=True,null=True)

    def __str__(self):
        return self.name

    def save(self):
        self.modified_on = datetime.now()
        super(Application, self).save() # Call the "real" save()
method.

    def short_description(self):
         return self.short_desc
    short_description.allow_tags = True

    class Meta:
        verbose_name = _('in-house application')
        verbose_name_plural = _('in-house applications')
        ordering = ['name']

    class Admin:
        list_display = ('name','dpt','short_description','modified_on')
        search_fields = ['name','short_desc','dpt','user_prof']
        list_filter =
['modified_on','xp_compat','nds_distrib','business_unit','admin','os','prgm_lang','related_soft','related_app']
        fields = (
                  (None, {
                   'fields':
('name','dpt','net_dir','user_prof','business_unit','nds_distrib','xp_compat')
                   }),
                  (_('Short description and comments'), {
                   #'classes': 'collapse',
                   'fields' : ('short_desc','comments')
                   }),
                  (_('Authors'), {
                   #'classes': 'collapse',
                   'fields' : ('admin',)
                   }),
                  (_('Links'), {
                   #'classes': 'collapse',
                   'fields' :
('related_app','related_soft','os','prgm_lang')
                   }),
                 )
        js = (
             'js/tiny_mce/tiny_mce.js',
             'js/tiny_mce/textareas.js',
             )

class DocTitle(models.Model):
    sequence    = models.IntegerField(_('sequence'))
    title_en    = models.CharField(_('title'),maxlength=200)

    def __str__(self):
        return self.title_en

    class Meta:
        verbose_name = _('documentation title')
        verbose_name_plural = _('documentation titles')
        ordering = ['sequence']

    class Admin:
        list_display = ('title_en',)

class DocChunk(models.Model):
    application =
models.ForeignKey(Application,edit_inline=True,num_in_admin=4,min_num_in_admin=4,max_num_in_admin=4)
    title       = models.ForeignKey(DocTitle)
    text        = models.TextField(_('text'),core=True)

    def __str__(self):
        return self.title.title_en

    class Meta:
        verbose_name = _('documentation chunk')
        verbose_name_plural = _('documentation chunks')
        ordering = ['title']
        #unique_together = (("application","title"),)

class Screenshot(models.Model):
    application =
models.ForeignKey(Application,edit_inline=True,num_in_admin=5,min_num_in_admin=5,num_extra_on_change=2)
    image       =
models.ImageField(_('image'),upload_to="screenshots/",height_field="height",width_field="width")
    caption     =
models.CharField(_('caption'),maxlength=200,core=True)
    height      =
models.IntegerField(_('height'),blank=True,null=True,editable=False)
    width       =
models.IntegerField(_('width'),blank=True,null=True,editable=False)

    def save(self):
        if self.image:
            import shutil
            from os import path,mkdir
            from django.conf import settings
            pathname, filename = path.split(self.image)
            if not
pathname.endswith(path.join("screenshots",self.application_id)):
                new_path = path.join(pathname,
str(self.application_id))
                if not path.isdir(path.join(settings.MEDIA_ROOT,
new_path)):
                    mkdir(path.join(settings.MEDIA_ROOT, new_path))
                new_image = path.join(new_path, filename)
                new_location = path.join(settings.MEDIA_ROOT,
new_image)
                old_location = path.join(settings.MEDIA_ROOT,
self.image)
                shutil.move(old_location, new_location)
                self.image = new_image
        super(Screenshot, self).save() # Call the "real" save() method.

    class Meta:
        verbose_name = _('screenshot')
        verbose_name_plural = _('screenshots')
        ordering = ['caption']
        
Olivier


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to