Giter Site home page Giter Site logo

django-extensions / django-extensions Goto Github PK

View Code? Open in Web Editor NEW
6.5K 103.0 1.2K 4 MB

This is a repository for collecting global custom management extensions for the Django Framework.

Home Page: https://django-extensions.readthedocs.io

License: MIT License

Python 94.81% CSS 0.08% JavaScript 4.72% HTML 0.24% Makefile 0.14%

django-extensions's Introduction

Django Extensions

Latest PyPI version Supports Wheel format Coverage

Django Extensions is a collection of custom extensions for the Django Framework.

Getting Started

The easiest way to figure out what Django Extensions are all about is to watch the excellent screencast by Eric Holscher (watch the video on vimeo). In a couple minutes Eric walks you through a half a dozen command extensions. There is also a short screencast on GoDjango's Youtube Channel to help show you even more.

Requirements

Django Extensions requires Django 3.2 or later.

Getting It

You can get Django Extensions by using pip:

$ pip install django-extensions

If you want to install it from source, grab the git repository from GitHub and run setup.py:

$ git clone git://github.com/django-extensions/django-extensions.git
$ cd django-extensions
$ python setup.py install

Installing It

To enable django_extensions in your project you need to add it to INSTALLED_APPS in your projects settings.py file:

INSTALLED_APPS = (
    ...
    'django_extensions',
    ...
)

Using It

Generate (and view) a graphviz graph of app models:

$ python manage.py graph_models -a -o myapp_models.png

Produce a tab-separated list of (url_pattern, view_function, name) tuples for a project:

$ python manage.py show_urls

Check templates for rendering errors:

$ python manage.py validate_templates

Run the enhanced django shell:

$ python manage.py shell_plus

Run the enhanced django runserver, (requires Werkzeug install):

$ python manage.py runserver_plus

Getting Involved

Open Source projects can always use more help. Fixing a problem, documenting a feature, adding translation in your language. If you have some time to spare and like to help us, here are the places to do so:

Documentation

You can view documentation online at:

Or you can look at the docs/ directory in the repository.

Support

Django Extensions is free and always will be. It is developed and maintained by developers in an Open Source manner. Any support is welcome. You could help by writing documentation, pull-requests, report issues and/or translations.

Please remember that nobody is paid directly to develop or maintain Django Extensions so we do have to divide our time between putting food on the table, family, this project and the rest of life :-)

django-extensions's People

Contributors

akaihola avatar bit avatar blueyed avatar camilonova avatar decibyte avatar domandinho avatar empty avatar fhahn avatar filipefigcorreia avatar jackatomenapps avatar jdufresne avatar jezdez avatar karranb avatar kevgathuku avatar khirstinova avatar kuter avatar michael-k avatar msabramo avatar nikolas avatar offpics avatar robhudson avatar tdsprogramming avatar tehfink avatar terencehonles avatar timgraham avatar trbs avatar ulgens avatar vstoykov avatar webs86 avatar yeojin-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-extensions's Issues

Problem with django-taggit when using graph_models

When using graph_models on a project with models that use django-taggit's TaggableManager, I get the following exception and traceback:

Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/Users/drbob/Development/pim/env/src/django-extensions/django_extensions/management/commands/graph_models.py", line 34, in handle
    dotdata = generate_dot(args, **options)
  File "/Users/drbob/Development/pim/env/src/django-extensions/django_extensions/management/modelviz.py", line 237, in generate_dot
    add_attributes(field)
  File "/Users/drbob/Development/pim/env/src/django-extensions/django_extensions/management/modelviz.py", line 227, in add_attributes
    'blank': field.blank,
AttributeError: 'TaggableManager' object has no attribute 'blank'

This error was found to exist in 22b5af8.

'syncdata' command fails, when model primary key is not 'id' field

Example model which cause failure:

class ContactOrganization(models.Model):
    key = models.CharField(_('Key'), max_length=30, unique=True, primary_key=True)
    name = models.CharField(_('Name'), max_length=40)

Quick fix: use 'pk' attribute instead of 'id':

--- syncdata.py 2010-09-02 11:04:57.000000000 +0200
+++ syncdata2.py 2010-10-18 13:11:01.000000000 +0200
@@ -29,14 +30,14 @@
         for class_ in objects_to_keep.keys():
 
             current = class_.objects.all()
-            current_ids = set( [x.id for x in current] )
-            keep_ids = set( [x.id for x in objects_to_keep[class_]] )
+            current_ids = set( [x.pk for x in current] )
+            keep_ids = set( [x.pk for x in objects_to_keep[class_]] )
 
             remove_these_ones = current_ids.difference(keep_ids)
             if remove_these_ones:
 
                 for obj in current:
-                    if obj.id in remove_these_ones:
+                    if obj.pk in remove_these_ones:
                         obj.delete()
                         if verbosity >= 2:
                             print "Deleted object: "+ unicode(obj)

sqldiff failing for DecimalField in sqlite3

./manage.py sqldiff -a -e -d -t
Traceback (most recent call last):
  File "./manage.py", line 13, in 
    execute_manager(settings)
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django/core/management/**init**.py", line 362, in execute_manager
    utility.execute()
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django/core/management/**init**.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django/core/management/base.py", line 195, in run_from_argv
    self.execute(_args, *_options.**dict**)
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django/core/management/base.py", line 222, in execute
    output = self.handle(_args, *_options)
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django_extensions/management/commands/sqldiff.py", line 590, in handle
    sqldiff_instance.find_differences()
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django/db/transaction.py", line 265, in _commit_manually
    return func(_args, *_kw)
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django_extensions/management/commands/sqldiff.py", line 344, in find_differences
    self.find_field_type_differ(meta, table_description, table_name)
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django_extensions/management/commands/sqldiff.py", line 266, in find_field_type_differ
    db_type = self.strip_parameters(self.get_field_db_type(description, field))
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django_extensions/management/commands/sqldiff.py", line 450, in get_field_db_type
    db_type = super(SqliteSQLDiff, self).get_field_db_type(description)
  File "/usr/local/ve/cms/lib/python2.5/site-packages/django_extensions/management/commands/sqldiff.py", line 190, in get_field_db_type
    kwargs['decimal_places'] = abs(description[5])
TypeError: bad operand type for abs(): 'NoneType'

error is raised at field defined simply as:

CREATE TABLE ... (
...
    "lat" decimal,
...
);

Autocomplete stop working after Django update

Hello,
I haved problem with autocomplete admin widget after I update Django to revision 10781. I try to figure what is wrong and found some working solution. I replaced method __call__ in django-extensions / django_extensions / admin / __init__.py file with new method:


    def get_urls(self):
        urls = super(ForeignKeyAutocompleteAdmin, self).get_urls()
        my_urls = patterns('',
            (r'^foreignkey_autocomplete/$', self.admin_site.admin_view(self.foreignkey_autocomplete))
        )
        return my_urls + urls

sync_media_s3 error doesn't work with latest boto

File "commands/sync_media_s3.py", line 249, in upload_s3
    except boto.s3.connection.S3CreateError, e:
AttributeError: 'module' object has no attribute 'S3CreateError'

The error is in a different place in the version of boto I just pulled with pip, 2.0b3.

sync_media_s3 help require "boto"

I think that is a bug.

I can't see the help of this command if I don't have installed "boto" in my sistem.

Before install boto:
$ ./manage.py help sync_media_s3
Traceback (most recent call last):
File "./manage.py", line 11, in ?
execute_manager(settings)
File "/home/humitos/.virtualenvs/atsimarketing/lib/python2.4/site-packages/django/core/management/init.py", line 361, in execute_manager
utility.execute()
File "/home/humitos/.virtualenvs/atsimarketing/lib/python2.4/site-packages/django/core/management/init.py", line 292, in execute
self.fetch_command(args[2]).print_help(self.prog_name, args[2])
File "/home/humitos/.virtualenvs/atsimarketing/lib/python2.4/site-packages/django/core/management/init.py", line 260, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/humitos/.virtualenvs/atsimarketing/lib/python2.4/site-packages/django/core/management/init.py", line 67, in load_command_class
{}, {}, ['Command']), 'Command')()
File "/home/humitos/.virtualenvs/atsimarketing/src/django-command-extensions/django_extensions/management/commands/sync_media_s3.py", line 48, in ?
raise ImportError, "The boto Python library is not installed."
ImportError: The boto Python library is not installed.

After install boto:
$ ./manage.py help sync_media_s3usage: manage.py sync_media_s3 [options] bucket_name

Syncs the complete MEDIA_ROOT structure and files to S3 into the given bucket name.

options:
--settings=SETTINGS The Python path to a settings module, e.g.
"myproject.settings.main". If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be
used.
--pythonpath=PYTHONPATH
A directory to add to the Python path, e.g.
"/home/djangoprojects/myproject".
--traceback Print traceback on exception
-p PREFIX, --prefix=PREFIX
The prefix to prepend to the path on S3.
--gzip Enables gzipping CSS and Javascript files.
--expires Enables setting a far future expires header.
--force Skip the file mtime check to force upload of all
files.
-v, --verbosity Verbose mode. Multiple -v options increase the
verbosity.
--version show program's version number and exit
-h, --help show this help message and exit

pip install problems

If django-extensions is in a pip requirements file and pip tries to install it, the result
doesn't include needed dependencies. Missing are python-keyczar and pyasn1. Also
once those are installed it still complains of missing settings.ENCRYPTED_FIELD_KEYS_DIR to your Keyczar keys directory.

Describe_form Creates invalid code

When using describe form the code produced for foreign key fields breaks with django 1.1

Currently a foreign key field is produced like:
field = forms.ModelChoiceField(required=false, label='some label')

However, in django 1.1 a queryset is a required argument for a ModelChoiceField

http://docs.djangoproject.com/en/1.1/ref/forms/fields/#modelchoicefield

This results in a type error when attempting to import those models

TypeError at ...

init() takes at least 2 non-keyword arguments (1 given)
... snip ...
class PartyForm(forms.Form):
namePronounciation = forms.URLField(max_length=90, required=False, label=u'Party Name Pronounciation')
_partyPhoto = forms.ModelChoiceField(required=False, label=u'FK to PartyPhoto')

Support for Symlinks

Because you can only have one media root in django, i often need to create symlinks to the media files for other applications. So, have updated so it uses os.walk (not os.path.walk) and it now goes into symlinks. See below:

"""
Sync Media to S3
================

Django command that scans all files in your settings.MEDIA_ROOT folder and
uploads them to S3 with the same directory structure.

This command can optionally do the following but it is off by default:
* gzip compress any CSS and Javascript files it finds and adds the appropriate
  'Content-Encoding' header.
* set a far future 'Expires' header for optimal caching.

Note: This script requires the Python boto library and valid Amazon Web
Services API keys.

Required settings.py variables:
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
AWS_BUCKET_NAME = ''

Command options are:
  -p PREFIX, --prefix=PREFIX
                        The prefix to prepend to the path on S3.
  --gzip                Enables gzipping CSS and Javascript files.
  --expires             Enables setting a far future expires header.
  --force               Skip the file mtime check to force upload of all
                        files.
  --filter-list         Override default directory and file exclusion
                        filters. (enter as comma seperated line)

TODO:
 * Use fnmatch (or regex) to allow more complex FILTER_LIST rules.

"""
import datetime
import email
import mimetypes
import optparse
import os
import sys
import time

from django.conf import settings
from django.core.management.base import BaseCommand, CommandError

# Make sure boto is available
try:
    import boto
    import boto.exception
except ImportError:
    raise ImportError, "The boto Python library is not installed."

class Command(BaseCommand):

    # Extra variables to avoid passing these around
    AWS_ACCESS_KEY_ID = ''
    AWS_SECRET_ACCESS_KEY = ''
    AWS_BUCKET_NAME = ''
    DIRECTORY = ''
    FILTER_LIST = ['.DS_Store', '.svn', '.hg', '.git', 'Thumbs.db']
    GZIP_CONTENT_TYPES = (
        'text/css',
        'application/javascript',
        'application/x-javascript'
    )

    upload_count = 0
    skip_count = 0

    option_list = BaseCommand.option_list + (
        optparse.make_option('-p', '--prefix',
            dest='prefix', default='',
            help="The prefix to prepend to the path on S3."),
        optparse.make_option('-d', '--dir',
            dest='dir', default=settings.MEDIA_ROOT,
            help="The root directory to use instead of your MEDIA_ROOT"),
        optparse.make_option('--gzip',
            action='store_true', dest='gzip', default=False,
            help="Enables gzipping CSS and Javascript files."),
        optparse.make_option('--expires',
            action='store_true', dest='expires', default=False,
            help="Enables setting a far future expires header."),
        optparse.make_option('--force',
            action='store_true', dest='force', default=False,
            help="Skip the file mtime check to force upload of all files."),
        optparse.make_option('--filter-list', dest='filter_list',
            action='store', default='',
            help="Override default directory and file exclusion filters. (enter as comma seperated line)"),
    )

    help = 'Syncs the complete MEDIA_ROOT structure and files to S3 into the given bucket name.'
    args = 'bucket_name'

    can_import_settings = True

    def handle(self, *args, **options):

        # Check for AWS keys in settings
        if not hasattr(settings, 'AWS_ACCESS_KEY_ID') or \
           not hasattr(settings, 'AWS_SECRET_ACCESS_KEY'):
           raise CommandError('Missing AWS keys from settings file.  Please' +
                     'supply both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.')
        else:
            self.AWS_ACCESS_KEY_ID = settings.AWS_ACCESS_KEY_ID
            self.AWS_SECRET_ACCESS_KEY = settings.AWS_SECRET_ACCESS_KEY

        if not hasattr(settings, 'AWS_BUCKET_NAME'):
            raise CommandError('Missing bucket name from settings file. Please' +
                ' add the AWS_BUCKET_NAME to your settings file.')
        else:
            if not settings.AWS_BUCKET_NAME:
                raise CommandError('AWS_BUCKET_NAME cannot be empty.')
        self.AWS_BUCKET_NAME = settings.AWS_BUCKET_NAME

        if not hasattr(settings, 'MEDIA_ROOT'):
            raise CommandError('MEDIA_ROOT must be set in your settings.')
        else:
            if not settings.MEDIA_ROOT:
                raise CommandError('MEDIA_ROOT must be set in your settings.')

        self.verbosity = int(options.get('verbosity'))
        self.prefix = options.get('prefix')
        self.do_gzip = options.get('gzip')
        self.do_expires = options.get('expires')
        self.do_force = options.get('force')
        self.DIRECTORY = options.get('dir')
        self.FILTER_LIST = getattr(settings, 'FILTER_LIST', self.FILTER_LIST)
        filter_list = options.get('filter_list')
        if filter_list:
            # command line option overrides default filter_list and
            # settings.filter_list
            self.FILTER_LIST = filter_list.split(',')

        # Now call the syncing method to walk the MEDIA_ROOT directory and
        # upload all files found.
        self.sync_s3()

        print
        print "%d files uploaded." % (self.upload_count)
        print "%d files skipped." % (self.skip_count)

    def sync_s3(self):
        """
        Walks the media directory and syncs files to S3
        """
        bucket, key = self.open_s3()
        #os.path.walk(self.DIRECTORY, self.upload_s3,
        #   (bucket, key, self.AWS_BUCKET_NAME, self.DIRECTORY))
        self.upload_s3(bucket, key, self.AWS_BUCKET_NAME, self.DIRECTORY)


    def compress_string(self, s):
        """Gzip a given string."""
        import cStringIO, gzip
        zbuf = cStringIO.StringIO()
        zfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
        zfile.write(s)
        zfile.close()
        return zbuf.getvalue()

    def open_s3(self):
        """
        Opens connection to S3 returning bucket and key
        """
        conn = boto.connect_s3(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY)
        try:
            bucket = conn.get_bucket(self.AWS_BUCKET_NAME)
        except boto.exception.S3ResponseError:
            bucket = conn.create_bucket(self.AWS_BUCKET_NAME)
        return bucket, boto.s3.key.Key(bucket)

    #def upload_s3(self, arg, dirname, names):
    def upload_s3(self, bucket, key, bucket_name, root_dir):

        for dirname, dirs, names in os.walk(root_dir, followlinks = True):

            if not dirname in self.FILTER_LIST:

                # Exclude the dirs in the filter list
                dirs[:] = [d for d in dirs if not d in self.FILTER_LIST]

                for file in names:

                    if not file in self.FILTER_LIST:

                        headers = {}

                        filename = "%s/%s" % (dirname, file)

                        file_key = filename[len(root_dir):]

                        if self.prefix:

                            file_key = '%s/%s' % (self.prefix, file_key)

                        # Check if file on S3 is older than local file, if so, upload
                        if not self.do_force:
                            s3_key = bucket.get_key(file_key)
                            if s3_key:
                                s3_datetime = datetime.datetime(*time.strptime(
                                    s3_key.last_modified, '%a, %d %b %Y %H:%M:%S %Z')[0:6])
                                local_datetime = datetime.datetime.utcfromtimestamp(
                                    os.stat(filename).st_mtime)
                                if local_datetime < s3_datetime:
                                    self.skip_count += 1
                                    if self.verbosity > 1:
                                        print "File %s hasn't been modified since last " \
                                            "being uploaded" % (file_key)
                                    continue

                        # File is newer, let's process and upload
                        if self.verbosity > 0:
                            print "Uploading %s..." % (file_key)

                        content_type = mimetypes.guess_type(filename)[0]
                        if content_type:
                            headers['Content-Type'] = content_type
                        file_obj = open(filename, 'rb')
                        file_size = os.fstat(file_obj.fileno()).st_size
                        filedata = file_obj.read()

                        if self.do_gzip:
                            # Gzipping only if file is large enough (>1K is recommended) 
                            # and only if file is a common text type (not a binary file)
                            if file_size > 1024 and content_type in self.GZIP_CONTENT_TYPES:
                                filedata = self.compress_string(filedata)
                                headers['Content-Encoding'] = 'gzip'
                                if self.verbosity > 1:
                                    print "\tgzipped: %dk to %dk" % \
                                        (file_size/1024, len(filedata)/1024)

                        if self.do_expires:
                            # HTTP/1.0
                            headers['Expires'] = '%s GMT' % (email.Utils.formatdate(
                                time.mktime((datetime.datetime.now() +
                                datetime.timedelta(days=365*2)).timetuple())))
                            # HTTP/1.1
                            headers['Cache-Control'] = 'max-age %d' % (3600 * 24 * 365 * 2)
                            if self.verbosity > 1:
                                print "\texpires: %s" % (headers['Expires'])
                                print "\tcache-control: %s" % (headers['Cache-Control'])

                        try:
                            key.name = file_key
                            key.set_contents_from_string(filedata, headers, replace=True)
                            key.set_acl('public-read')
                        except boto.s3.connection.S3CreateError, e:
                            print "Failed: %s" % e
                        except Exception, e:
                            print e
                            raise
                        else:
                            self.upload_count += 1

                        file_obj.close()

# Backwards compatibility for Django r9110
if not [opt for opt in Command.option_list if opt.dest=='verbosity']:
    Command.option_list += (
        optparse.make_option('-v', '--verbosity',
            dest='verbosity', default=1, action='count',
            help="Verbose mode. Multiple -v options increase the verbosity."),
    )

runscript not working

Django-extensions works well, the dumpscript command too
but when I launch a ./manage.py runscript myscript ("myscript" being in a "scripts" folder, in the project root folder, with an init.py file inside) I always get :
No module for script 'myscript' found

History feature

It would be helpful to create a history feature to record all modifications that were made to a record as part of the created and modified date/time.

Cristian

Problem with using `python setup.py install`

I first noticed this during the dash and just confirmed the same problem on my work computer.

To recreate:

  1. Download or clone the official github repo
  2. sudo python setup.py install
  3. Run create_jobs on an installed app

Create jobs fails silently (doesn't create the directory structure), as conf apparently was not copied to site-packages during the install. Copying all folders manually after the install works for me in the meantime.

Both machines running OSX Leopard latest updates with stock python 2.5.

graph_models doesn't handle ForeignKey where model parameter is a string

Sometimes there is a circular relationship between models, so it's necessary to refer to another model using a string because the class has not been defined yet:

class Foo(models.Model):
    bar = models.ForeignKey("Bar")

In this case, the generated diagram does not link Foo with Bar. Instead, it draws the arrow for the relationship from Foo leading outside the bounding border for the app.

profiling model validation

I had a need to profile model validation, so I've patched runprofileserver to support this, if this is useful to anyone else...

JSONField default= doesn't accept a dict

Dicts can be assigned to JSONFields in model instances, but default values must currently be specified as JSON strings in model definitions.

In other words, instead of this:

myfield = JSONField(default=simplejson.dumps(mydict))

if would be nice to just say:

myfield = JSONField(default=mydict)

reset_db: psycopg2.OperationalError: FATAL: database "None" does not exist

I try to use reset_db on Postgres and it doesn't work without use "-D db_name" parameter:

ram@ram-laptop:~/workspace/movister/web_site$ ./manage.py reset_db

You have requested a database reset.
This will IRREVERSIBLY DESTROY
ALL data in the database "movister".
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 439, in execute_manager
    utility.execute()
  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 380, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ram/workspace/movister/web_site/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/ram/workspace/movister/web_site/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/home/ram/workspace/movister/web_site/django_extensions/management/commands/reset_db.py", line 110, in handle
    connection = Database.connect(conn_string)
psycopg2.OperationalError: FATAL:  database "None" does not exist

If I try with "-D", it doesn't work too:

ram@ram-laptop:~/workspace/movister/web_site$ ./manage.py reset_db -D movister

You have requested a database reset.
This will IRREVERSIBLY DESTROY
ALL data in the database "movister".
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 439, in execute_manager
    utility.execute()
  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 380, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ram/workspace/movister/web_site/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/ram/workspace/movister/web_site/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/home/ram/workspace/movister/web_site/django_extensions/management/commands/reset_db.py", line 117, in handle
    cursor.execute(drop_query)
psycopg2.OperationalError: cannot drop the currently open database

I'm sure all connection to DB are closed. I solve this problem by using this command in SQL terminal:

DROP OWNED BY movister;

sqldiff strip_parameters breaks db_types like 'double precision' in postgres

postgres uses db type 'double precision' for FloatField.
sqldiff only prints double for those fields and thus breaks.
adding a check for double precision this can be worked around. but in general types can have spaces.

def strip_parameters(self, field_type):
    if field_type and field_type != 'double precision':
        return field_type.split(" ")[0].split("(")[0]
    return field_type

Documentation on GitHub

It seems like you're using GitHub for mostly everything except your docs that are available on Google Code. Could you move those over here too?

AttributeError: dummy instance has no attribute 'ERROR_OUTPUT'

After this changeset http://code.djangoproject.com/changeset/12009 when I try to start shell_plus, I got error:

From 'admin' autoload: LogEntry, ActionEntry
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 439, in execute_manager
    utility.execute()
  File "/home/ram/workspace/movister/web_site/django/core/management/__init__.py", line 380, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/ram/workspace/movister/web_site/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/ram/workspace/movister/web_site/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/home/ram/workspace/movister/web_site/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/home/ram/workspace/movister/web_site/django_extensions/management/commands/shell_plus.py", line 44, in handle_noargs
    print self.style.ERROR_OUTPUT("Failed to import '%s' from '%s' reason: %s" % (model.__name__, app_mod.__name__.split('.')[-2], str(e)))
AttributeError: dummy instance has no attribute 'ERROR_OUTPUT'

Before I got pretty red error, like this:

From 'admin' autoload: LogEntry, ActionEntry
Failed to import 'ActionEntry' from 'admin' reason: 'module' object has no attribute 'ActionEntry' 

CreationByField & ModificationByField

In a similar vein to CreationDateTimeField and ModificationDateTimeField, fields that stored the user (or even just user id) would be really useful, not sure how it could be achieved though.

eg CreationUserField & ModificationUserField

AutoSlugField unique argument

I like AutoSlugField's populate from argument however sometimes I don't need to slug to be unique (eg number incremented and added). It would be good if I could pass AutoSlugField(populate_from='name',overwrite=True,unique=False) to prevent the unique functionality

graphviz and model inheritance

When I try to create a graph (the dot file) from a model which has got an abstract class inheritance from an other model, like this :

class Foo(models.Model):
    foofoo = models.CharField(max_length = 255)
    class Meta:
        abstract = True
class Bar(Foo):
    barbar = models.CharField(max_length = 255)

the rendering is not good : 'Bar is empty'

UTILS_TESTS failure: python 2.6.5, django 1.1

When I upgraded Ubuntu Karmic to Lucid, the Python version bumped up from 2.6.4 to 2.6.5. Running tests on my apps causes the following failures. Running on 2.6.4 still passes the tests.

FAIL: Doctest: django_extensions.tests.test.UTILS_TESTS

Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/test/_doctest.py", line 2180, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for django_extensions.tests.test.UTILS_TESTS
File "/usr/lib/pymodules/python2.6/django_extensions/tests/init.py", line unknown line number, in UTILS_TESTS


File "/usr/lib/pymodules/python2.6/django_extensions/tests/init.py", line ?, in django_extensions.tests.test.UTILS_TESTS
Failed example:
from django_extensions.utils import uuid
Exception raised:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/test/_doctest.py", line 1267, in __run
compileflags, 1) in test.globs
File "<doctest django_extensions.tests.test.UTILS_TESTS[5]>", line 1, in
from django_extensions.utils import uuid

ImportError: cannot import name uuid

File "/usr/lib/pymodules/python2.6/django_extensions/tests/init.py", line ?, in django_extensions.tests.test.UTILS_TESTS
Failed example:
uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
Exception raised:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/test/_doctest.py", line 1267, in __run
compileflags, 1) in test.globs
File "<doctest django_extensions.tests.test.UTILS_TESTS[6]>", line 1, in
uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')

NameError: name 'uuid' is not defined

File "/usr/lib/pymodules/python2.6/django_extensions/tests/init.py", line ?, in django_extensions.tests.test.UTILS_TESTS
Failed example:
uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
Exception raised:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/test/_doctest.py", line 1267, in __run
compileflags, 1) in test.globs
File "<doctest django_extensions.tests.test.UTILS_TESTS[7]>", line 1, in
uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')

NameError: name 'uuid' is not defined

File "/usr/lib/pymodules/python2.6/django_extensions/tests/init.py", line ?, in django_extensions.tests.test.UTILS_TESTS
Failed example:
x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
Exception raised:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/test/_doctest.py", line 1267, in __run
compileflags, 1) in test.globs
File "<doctest django_extensions.tests.test.UTILS_TESTS[8]>", line 1, in
x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')

NameError: name 'uuid' is not defined

File "/usr/lib/pymodules/python2.6/django_extensions/tests/init.py", line ?, in django_extensions.tests.test.UTILS_TESTS
Failed example:
str(x)
Exception raised:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/test/_doctest.py", line 1267, in __run
compileflags, 1) in test.globs
File "<doctest django_extensions.tests.test.UTILS_TESTS[9]>", line 1, in
str(x)

NameError: name 'x' is not defined

File "/usr/lib/pymodules/python2.6/django_extensions/tests/init.py", line ?, in django_extensions.tests.test.UTILS_TESTS
Failed example:
x.bytes
Exception raised:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/test/_doctest.py", line 1267, in __run
compileflags, 1) in test.globs
File "<doctest django_extensions.tests.test.UTILS_TESTS[10]>", line 1, in
x.bytes

NameError: name 'x' is not defined

File "/usr/lib/pymodules/python2.6/django_extensions/tests/init.py", line ?, in django_extensions.tests.test.UTILS_TESTS
Failed example:
uuid.UUID(bytes=x.bytes)
Exception raised:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/test/_doctest.py", line 1267, in __run
compileflags, 1) in test.globs
File "<doctest django_extensions.tests.test.UTILS_TESTS[11]>", line 1, in
uuid.UUID(bytes=x.bytes)
NameError: name 'uuid' is not defined

sync_media_s3: FILTER field in settings is effectively ignored

The sync_media_s3 command allows the filter list defined in settings to be overridden. This snippet of code does the work:

   self.FILTER_LIST = getattr(settings, 'FILTER_LIST', self.FILTER_LIST)
   filter_list = options.get('filter_list').split(',')
   if filter_list:
       # command line option overrides default filter_list and
       # settings.filter_list
       self.FILTER_LIST = filter_list

however, unless I'm missing something here, filter_list will never be False. For example, even an empty string will evaluate to True when split by something.

>>> bool(''.split('jam'))
True

Because split will return a list of one (empty) string

>>> ''.split('jam')
['']

Perhaps this could look something like:

   self.FILTER_LIST = getattr(settings, 'FILTER_LIST', self.FILTER_LIST)
   filter_list = options.get('filter_list')
   if filter_list:
       # command line option overrides default filter_list and
       # settings.filter_list
       self.FILTER_LIST = filter_list.split(',')

Test fail

Hi there,

testing on version 0.5 fails:

  ./manage.py test
  Traceback (most recent call last):
  File "./manage.py", line 11, in 
    execute_manager(settings)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py",    line 438, in execute_manager
    utility.execute()
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.6/dist-packages/south/management/commands/test.py", line 8, in handle
    super(Command, self).handle(*args, **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/django/core/management/commands/test.py", line 37, in handle
    failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python2.6/dist-packages/django/test/simple.py", line 312, in run_tests
    suite = self.build_suite(test_labels, extra_tests)
  File "/usr/local/lib/python2.6/dist-packages/django/test/simple.py", line 248, in build_suite
    suite.addTest(build_suite(app))
  File "/usr/local/lib/python2.6/dist-packages/django/test/simple.py", line 109, in build_suite
    test_module = get_tests(app_module)
  File "/usr/local/lib/python2.6/dist-packages/django/test/simple.py", line 67, in get_tests
    test_module = __import__('.'.join(app_path + [TEST_MODULE]), {}, {}, TEST_MODULE)
  File "/usr/local/lib/python2.6/dist-packages/django_extensions/tests/__init__.py", line 3, in 
    from django_extensions.tests.encrypted_fields import EncryptedFieldsTestCase
  File "/usr/local/lib/python2.6/dist-packages/django_extensions/tests/encrypted_fields.py", line 2, in 
    from keyczar import keyczar
ImportError: No module named keyczar

Unknown database engine exception bug.

Traceback (most recent call last):
File "./manage.py", line 12, in
execute_manager(settings)
File "/home/foo/projects/all/bar/src/vendor/django/core/management/init.py", line 438, in execute_manager
utility.execute()
File "/home/foo/projects/all/bar/src/vendor/django/core/management/init.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/foo/projects/all/bar/src/vendor/django/core/management/base.py", line 191, in run_from_argv
self.execute(_args, *_options.dict)
File "/home/foo/projects/all/bar/src/vendor/django/core/management/base.py", line 218, in execute
output = self.handle(_args, *_options)
File "/home/foo/projects/all/bar/src/vendor/django_extensions/management/commands/reset_db.py", line 116, in handle
raise CommandError, "Unknown database engine %s", engine
TypeError: raise: arg 3 must be a traceback or None

iPython broken

Not much to say:

$ python manage.py shell
Traceback (most recent call last):
  File "manage.py", line 11, in 
    execute_manager(settings)
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager
    utility.execute()
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/Library/Python/2.6/site-packages/django/core/management/commands/shell.py", line 29, in handle_noargs
    shell = IPython.Shell.IPShell(argv=[])
AttributeError: 'module' object has no attribute 'Shell'

I use the SVN checkout.

EncryptedCharField does not decrypt for objects.filter

For a model with EncryptedCharField named "last_name" i notice that the field does not decrypt when I search on it. In all other uses it is fine. This does not work:
if form.is_valid():
cd = form.cleaned_data
search_results = MyTable.objects.filter(first_name__icontains=cd['search_term'])

is this by design or am i doing something wrong?
thanks for you help...

AutoSlugField should handle Tuples of fields

Currently the AutoSlugField only handles one field. It should be possible to define a string (1 field) or a tuple of fields that are generated.

A definition of:

```
slug = AutoSlugField(populate_from=(‘artist’, ‘title’))
```

would create a slug like “u2-sunday-bloody-sunday”.

Bump up version number?

I see that there has been a lot of changes since 0.5 came out but the version number hasn't changed. I think it would be helpful if it was bumped up to avoid confusion.

shell_plus fails to import models when they specify a custom app_label

shell_plus fails when you specify custom Meta app_label to models.

Example:

Here's project_name/app_name/models.py

from django.db import models
class Person(models.Model):
  name = models.CharField(max_length=100)
  class Meta:
    app_label = 'another_app'

And then shell_plus fails:
$ python manage.py shell_plus
Failed to import 'Person' from 'another_app' reason: 'module' object has no attribute 'Person'
>>>

It tries to import the model from the app suplied on app_label rather than in the proper models.py file.

search on EncryptedCharField (does not decrypt)

is this possible?

For a model with EncryptedCharField named "last_name" i notice that the field does not decrypt when I search on it. In all other uses it is fine. This does not work:
if form.is_valid():
cd = form.cleaned_data
search_results = MyTable.objects.filter(first_name__icontains=cd['search_term'])

is this by design or am i doing something wrong?
thanks for you help...

graph_model ignores OneToOneField relation

OneToOne is subclass of ForeignKey

checking isinstance while ading relation should be in this order:
if isinstance(field, OneToOneField):
add_relation(field, '[arrowhead=none arrowtail=none]')
elif isinstance(field, ForeignKey):
add_relation(field)

reset_db exception error

The line 132 of reset_db.py should be:

        raise CommandError, "Unknown database engine %s" % engine

Replace a "," for a "%"

AutoSlugField is not compatible with django_evolution

The AutoSlugField is not compatible with django_evolution

python manage.py evolve --hint --execute

raises:
ValueError: missing 'populate_from' argument

This is because init.py in db.fields has no default-value on populate_from

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.