google-code-export / django-mptt

Automatically exported from code.google.com/p/django-mptt
Other
0 stars 0 forks source link

Unable to get started #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I see on the Internet that other people have mptt working, but I am having
trouble getting off the ground.  I have this model with a 'self' field. 

class Characterizations(models.Model):
    parent=models.ForeignKey(
        'self',
        null=True,
        blank=True,
        db_index=True,
        help_text="Parent of node in tree") 
    dimen=models.ForeignKey(
        Dimen,
        related_name='characterizations_fk_dimen',
        null=True,
        blank=False,
        db_index=True,
        help_text="Dimension of characterization") 
    title=models.CharField(
        max_length=72,
        null=False,
        blank=True,
        db_index=False,
        help_text="Title of this node (short)") 
    description=models.CharField(
        max_length=72*24,
        null=False,
        blank=True,
        db_index=False,
        help_text="Description of this node (a paragraph)") 

After installing mptt, at the top of models.py, right below "from django.db
import models" I added

  import mptt

and I added 'mptt' to INSTALLED_APPS in settings.py.

Below the model I added

  mptt.register(Characterizations, order_insertion_by='title')

and I try to run.  I drop all tables (I have a command "psql -a -f
dropTables.sql az" for that).  Then I run 

  /usr/local/bin/python manage.py reset --noinput pkgs

and I get the error (entire traceback at bottom):  

File "/usr/local/lib/python2.5/site-packages/mptt/__init__.py", line 73, in
register
    dispatcher.connect(pre_save, signal=model_signals.pre_save, sender=model)
AttributeError: 'module' object has no attribute 'connect'

Indeed, there is no connect() call at the top level in
django/dispatch/dispatcher.py .  I see there a class Signal which itself
has a connect() call, but in mptt/__init__.py I don't see that Signal is
ever instantiated.

I just updated django out of svn a few minutes ago and it shows the same
behavior.  I downloaded mptt version 0.2.1 this morning.  I am running
Ubuntu (maybe Hardy Heron, but I have Python 2.5 which is why I call it out
of /usr/local/bin).

I'd be glad for any tips.  (I'd also be glad to show any and all code if
that would help, of course.) 

Thanks,
Jim Hefferon

...............................................................
  Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_manager(settings)
  File
"/usr/local/lib/python2.5/site-packages/django/core/management/__init__.py",
line 340, in execute_manager
    utility.execute()
  File
"/usr/local/lib/python2.5/site-packages/django/core/management/__init__.py",
line 295, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/usr/local/lib/python2.5/site-packages/django/core/management/base.py",
line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File
"/usr/local/lib/python2.5/site-packages/django/core/management/base.py",
line 221, in execute
    self.validate()
  File
"/usr/local/lib/python2.5/site-packages/django/core/management/base.py",
line 249, in validate
    num_errors = get_validation_errors(s, app)
  File
"/usr/local/lib/python2.5/site-packages/django/core/management/validation.py",
line 28, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File
"/usr/local/lib/python2.5/site-packages/django/db/models/loading.py", line
128, in get_app_errors
    self._populate()
  File
"/usr/local/lib/python2.5/site-packages/django/db/models/loading.py", line
57, in _populate
    self.load_app(app_name, True)
  File
"/usr/local/lib/python2.5/site-packages/django/db/models/loading.py", line
72, in load_app
    mod = __import__(app_name, {}, {}, ['models'])
  File "/var/www/az/development/az/pkgs/models.py", line 710, in <module>
    mptt.register(Characterizations, order_insertion_by='title')
  File "/usr/local/lib/python2.5/site-packages/mptt/__init__.py", line 73,
in register
    dispatcher.connect(pre_save, signal=model_signals.pre_save, sender=model)

Original issue reported on code.google.com by jim.heff...@gmail.com on 29 Nov 2008 at 1:32

GoogleCodeExporter commented 9 years ago
Old django, probably. They have signals refactored 2 months ago.

Original comment by mocksoul on 6 Dec 2008 at 12:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Thanks, but I run django from the svn and I have tried it with a number of 
recent
versions.

Original comment by jim.heff...@gmail.com on 9 Dec 2008 at 1:28

GoogleCodeExporter commented 9 years ago
I'm having the same issue here, running Django 1.0.1 final. The cause of this 
issue
is the removal of some old deprecated methods in the dispatcher, see Django 
changeset
#8291.

http://code.djangoproject.com/changeset/8291

Original comment by Jonatan....@gmail.com on 20 Dec 2008 at 8:59

GoogleCodeExporter commented 9 years ago
I had the same issue, but after banging my head against a wall for a few hours 
I came
up with a solution that worked for me (on a linux box).

My problem stemmed from the fact that i had used the installer BEFORE trying to
install an up to date version from svn.

First I deleted "/usr/local/lib/python2.5/site-packages/mptt/" to remove the 
older
version of mptt.

Then I used svn to get the latest release of mptt.

Finally I opened a terminal in mptt-trunk and ran "sudo python setup.py 
install" to
install the new version.

Also, if you haven't done so, you might want to run "svn update" in your 
django_trunk
folder.

Good Luck
-Caz

Original comment by skopsyc...@gmail.com on 25 Jan 2009 at 6:30

GoogleCodeExporter commented 9 years ago
> Comment 5  by skopsycats, Jan 25, 2009

Thank you for this.  It is exactly what I needed to hear.

Just a note for anyone reading this who had the same problem: the docs on the 
web
page similarly have to be updated.  In particular, you need to say
order_insertion_by=['title'] (making it a list).  The docs from the svn are 
correct.

Original comment by jim.heff...@gmail.com on 5 Feb 2009 at 7:15

GoogleCodeExporter commented 9 years ago
Thanks, you saved me a lot of time.

Original comment by lenko...@gmail.com on 6 Jun 2009 at 6:37

GoogleCodeExporter commented 9 years ago
Yes - the current SVN release has it fixed.
Thank you.

Original comment by uszywiel...@gmail.com on 30 Aug 2009 at 7:27

GoogleCodeExporter commented 9 years ago
Fixed for me as well

Original comment by abdulrah...@gmail.com on 14 May 2010 at 1:01

GoogleCodeExporter commented 9 years ago
Awesome, thanks!

Original comment by lardissone on 17 Jun 2010 at 5:23

GoogleCodeExporter commented 9 years ago
Confirmed! works with mptt revision 121 and django 1.2.

Original comment by rumi.kg@gmail.com on 18 Jun 2010 at 2:13

GoogleCodeExporter commented 9 years ago
The recently added 0.3 release and the source checkout from github work with 
Django 1.1+

The SVN repo is now out of date, if you are using it please upgrade to 0.3 or 
checkout the github source.

(also the order_insertion_by bug is fixed in HEAD - it now accepts either 
string, tuple, or list)

Original comment by craig.ds@gmail.com on 2 Sep 2010 at 1:01