cfpb / idea-box

An application that lets an organization collect ideas, comment on them, and vote them up.
Creative Commons Zero v1.0 Universal
158 stars 49 forks source link

Error: type object 'Manager' has no attribute 'from_queryset' #95

Closed h10dinh closed 8 years ago

h10dinh commented 8 years ago

Hello Ideabox, I am trying to create Ideabox project and app using Django 1.5.8, done everything described in README.md file, until the last step : migration. Error : AttributeError: type object 'Manager' has no attribute 'from_queryset'.

I suspected the mptt lib is too new for your app, but not sure what version required. Please help!!! Thanks,

m3brown commented 8 years ago

It may also be related to the version of south. Known working versions of the requirements:

django-mptt==0.7.4
south==0.7.6

If either of these resolve your issue, let me know and we'll use this issue as leverage to tag the proper versions in the requirements.txt.

h10dinh commented 8 years ago

Hello: yes, it works with those versions. I now got pass the migration. But onto another problem: 404 error (http://(servername0/Project/Idea) , which I suspect due to directory structure problem. I install your idea as a new app under an existing project ( .. startapp idea) called Project.

Here is my directory structure: /opt/bitnami/apps/Django/Django_projects/Project/Project which has main urls.py as follows: +++++++++++++++++++++++++++++++++++++++++ from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() from Project import settings urlpatterns = patterns('', url(r'^HelloWorldApp/', include('HelloWorldApp.urls')), url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), ) if 'idea' in settings.INSTALLED_APPS and 'django.contrib.comments' in settings.INSTALLED_APPS: urlpatterns.append(url(r'^comments/', include('django.contrib.comments.urls'))) urlpatterns.append(url(r'^idea/', include('idea.urls', namespace='idea'))) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ the Idea directory is under :/opt/bitnami/apps/Django/Django_projects/Project/Idea where I copied the code from GitHub. this idea directory has views.py; settings.py and others directories.

any ideas why the 404 error? thanks

m3brown commented 8 years ago

Three thoughts:

1) Is the directory named Idea or idea? It should be lowercase.

2) Just to be clear, the idea directory is the idea directory from the git repository, not the entire git repository itself, right? Basically, you don't need the root of the git repo (which contains README.md, doc/, requirements.txt, etc.), you want to pull the idea directory out of the repo and put it into your project environment.

3) If the above two are correct, I think the problem may be that you have your idea directory in the wrong path. The idea directory should be in the same directory as the manage.py file, which is the root as far as importing/namespaces goes. Is that in Project? My hunch is it's one directory up, in Django_projects.

h10dinh commented 8 years ago

thanks, Mike for the quick response. 1) the directory is "idea" (lower-case). As matter of fact, the 404 error came back from IE, not from the debug page, which means django found the idea url. The actual site is here: http://ideabox-0n6g45b3.cloudapp.net/Project/idea . 2) yes, I pull the idea directory from GitHub, and place in the directory as follows:

- | django_projects (this is the root of all django projects. contained no manage.py)     
     |- Project:  (Project is a name of Django project - comes with Django stacks on the cloud VM)
            | - manage.py (I copied from the Ideabox github)
            | - conf 
            | - Project: 
                   |- urls.py  (this is where the main urls.py with code urlpatterns.append resides)
                   |- settings.py (this is where I added 'idea';'south';'mptt', etc under INSTALLED_APP)
                   |- views.py (comes with the Project) 
                   |- wsgi.py  (comes with the Project)
                   |- etc
            | - Idea (copied whole directory form Github)
                  |- urls.py 
                  |- views.py
                  |- admin.py
                  |- templates
                  |- fixtures
                  |- migrations
                  |- etc (all directories and files from Github 's idea directory)

In other words, Project is a project, and Idea is an app. I have another app in the same project, called HelloWorldApp, and it works just fine. See here: http://ideabox-0n6g45b3.cloudapp.net/Project/HelloWorldApp

+++++++++++++++++++ Appreciate any helps!!!

m3brown commented 8 years ago

Ahh, okay. so when i go to http://ideabox-0n6g45b3.cloudapp.net/Project/idea, the page redirects to http://ideabox-0n6g45b3.cloudapp.net/accounts/login/?next=/Project/idea/, and that results in a 404.

IdeaBox requires that the user be logged in (@login_required) to access the page, and right now you don't have any login url paths.

If you already created a superuser via ./manage.py createsuperuser, you should be able to log in as that user via http://ideabox-0n6g45b3.cloudapp.net/Project/admin/ - once you do that, hopefully the /idea/ url will work.

What's the proper solution? You'll want to implement an /accounts/login page (documentation)

If that all wires together properly, going to the /idea/ page will redirect to a login screen. You can login as the superuser account, or you can create new non-administrator accounts by going to the /admin/ page and clicking on the Auth -> User link.

h10dinh commented 8 years ago

Hello Mike, I replied the comments via email a few days ago, somehow it did not make in here. Your suggestion on createsuperuser worked on admin interface but not with the "idea' app. Even it gets passed the login , and go to next to Idea app, it throws errors about query.py line 404, context not found... In the last three days, I have re-installed this app in two additional servers (Ubuntu and Windows) using Bitnami Django stacks. Still no luck. Overall, I have run into several issues, differently per version of Django and dependencies. I think primarily because Django has gone through significant changes since your app was written (1.5.4), and requires significant code migration. For example, the current Django version (1.9) does not even support south. May be just me, but it is tough to get the old code to work, while every components has changed in the last two years. My CIO asked for this, and that's the reason I have spent so much time on although I am not a Python developer :( Will try again tomorrow..

m3brown commented 8 years ago

@h10dinh, your assessment is correct, a lot has changed since Django 1.5.4. This is why our requirements.txt specifies the (old!) versions that work with ideabox. This app is not under active development, and as such it has not updated it to support more recent versions of Django.

I'm sorry my prediction that logging in as an admin would give you access to the app. Did you try my "proper solution" of creating a login page? I'm happy to walk you through that solution if you need more assistance, but perhaps we should move that to email rather than clogging this thread. michael.brown@cfpb.gov

h10dinh commented 8 years ago

You are right, Mike. I will close this issue and move to email. Thanks,