The-WebOps-Club / fest-api

An API implementation for Saarang Shaastra like fests, including ERP and Mainsite and Mobile interface
12 stars 11 forks source link

Can someone tell me the purpose of these files in fest-api #98

Closed akshayutture closed 10 years ago

akshayutture commented 10 years ago

Can someone explain me the basic purpose of these files or if the purpose is not necessary for me to know

/apps/docs/migrations /apps/docs/authorize.py /apps/events/migrations /apps/wall/managers.py /apps/wall/search_indexes.py /apps/wall/signals.py /apps/wall/utils.py

AbdealiLoKo commented 10 years ago

Migration - check out python south

Authorize, manager, search, signals not important right now.

Utils is some gen file we put commonly used functions. These functions are used everywhere else On Jun 20, 2014 8:02 PM, "akshayutture" notifications@github.com wrote:

Can someone explain me the basic purpose of these files or if the purpose is not necessary for me to know

/apps/docs/migrations /apps/docs/authorize.py /apps/events/migrations /apps/wall/managers.py /apps/wall/search_indexes.py /apps/wall/signals.py /apps/wall/utils.py

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98.

akshayutture commented 10 years ago

Also, while trying to run the django server, I'm getting a message

ImportError: No module named apiclient

Any suggestions?

AbdealiLoKo commented 10 years ago

Install everything in configs/requirements.txt using the command : pip install -r configs/requirements.txt

^ assumes you have pip installed

On Fri, Jun 20, 2014 at 8:34 PM, akshayutture notifications@github.com wrote:

Also, while trying to run the django server, I'm getting a message

ImportError: No module named apiclient

Any suggestions?

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46688441 .

akshayutture commented 10 years ago

I already did that. But I had a problem installing the following

MySQL-python==1.2.5

Twisted==14.0.0 misaka==1.0.2

Any suggestions?

AbdealiLoKo commented 10 years ago

Windows ?

And youll ahve to tell us what the problem is.

@Sai praveen : I think he's using windows - can you tell ?

On Fri, Jun 20, 2014 at 8:41 PM, akshayutture notifications@github.com wrote:

I already did that. But I had a problem installing the following

MySQL-python==1.2.5 South==0.8.4 Twisted==14.0.0 misaka==1.0.2

Any suggestions?

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46689221 .

akshayutture commented 10 years ago

No I'm using ubuntu. Should I print the error here?

AbdealiLoKo commented 10 years ago

Yep

On Fri, Jun 20, 2014 at 8:47 PM, akshayutture notifications@github.com wrote:

No I'm using ubuntu. Should I print the error here?

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46690017 .

akshayutture commented 10 years ago

For mysql-python

akshay@akshay-Lenovo-IdeaPad-Z500:~/fest-api$ sudo pip install -r configs/requirements.txt [sudo] password for akshay: Downloading/unpacking MySQL-python==1.2.5 (from -r configs/requirements.txt (line 2)) Downloading MySQL-python-1.2.5.zip (108Kb): 108Kb downloaded Running setup.py egg_info for package MySQL-python sh: 1: mysql_config: not found Traceback (most recent call last): File "", line 14, in File "/home/akshay/fest-api/build/MySQL-python/setup.py", line 17, in metadata, options = get_config() File "setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "setup_posix.py", line 25, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found Complete output from command python setup.py egg_info: sh: 1: mysql_config: not found

Traceback (most recent call last):

File "", line 14, in

File "/home/akshay/fest-api/build/MySQL-python/setup.py", line 17, in

metadata, options = get_config()

File "setup_posix.py", line 43, in get_config

libs = mysql_config("libs_r")

File "setup_posix.py", line 25, in mysql_config

raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found


Command python setup.py egg_info failed with error code 1 Storing complete log in /home/akshay/.pip/pip.log

shahidhk commented 10 years ago

Check the readme.md

Install libmysqlclient-dev python-dev if not already installed

On Fri, Jun 20, 2014 at 8:49 PM, akshayutture notifications@github.com wrote:

For mysql-python

akshay@akshay-Lenovo-IdeaPad-Z500:~/fest-api$ sudo pip install -r configs/requirements.txt [sudo] password for akshay: Downloading/unpacking MySQL-python==1.2.5 (from -r configs/requirements.txt (line 2)) Downloading MySQL-python-1.2.5.zip (108Kb): 108Kb downloaded Running setup.py egg_info for package MySQL-python sh: 1: mysql_config: not found Traceback (most recent call last): File "", line 14, in File "/home/akshay/fest-api/build/MySQL-python/setup.py", line 17, in metadata, options = get_config() File "setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "setup_posix.py", line 25, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found Complete output from command python setup.py egg_info: sh: 1: mysql_config: not found

Traceback (most recent call last):

File "", line 14, in

File "/home/akshay/fest-api/build/MySQL-python/setup.py", line 17, in

metadata, options = get_config()

File "setup_posix.py", line 43, in get_config

libs = mysql_config("libs_r")

File "setup_posix.py", line 25, in mysql_config

raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

Command python setup.py egg_info failed with error code 1 Storing complete log in /home/akshay/.pip/pip.log

— Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46690263 .

Shahidh K Muhammed Undergraduate Student Department of Engineering Design Indian Institute of Technology Madras Chennai 600036 Mobile: (+91) 9496362472 http://shahidhkmuhammed.in

akshayutture commented 10 years ago

Thanx it got installed. But when I try to use python manage.py runserver I get

ImportError: No module named apiclient

Phoenix25 commented 10 years ago

isn't that part of google-api-python-client ? do sudo pip install google-api-pyhton-client

On Fri, Jun 20, 2014 at 9:13 PM, akshayutture notifications@github.com wrote:

Thanx it got installed. But when I try to use python manage.py runserver I get

ImportError: No module named apiclient

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46693356 .

shahidhk commented 10 years ago

pip install google-api-python-client

and use a virtual-env

On Fri, Jun 20, 2014 at 9:13 PM, akshayutture notifications@github.com wrote:

Thanx it got installed. But when I try to use python manage.py runserver I get

ImportError: No module named apiclient

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46693356 .

Shahidh K Muhammed Undergraduate Student Department of Engineering Design Indian Institute of Technology Madras Chennai 600036 Mobile: (+91) 9496362472 http://shahidhkmuhammed.in

AbdealiLoKo commented 10 years ago

Uhm, don't get confused with what he said about virtual env .... continue as you're doing for now.

Is setup done? On Jun 20, 2014 9:29 PM, "Shahidh K Muhammed" notifications@github.com wrote:

pip install google-api-python-client

and use a virtual-env

On Fri, Jun 20, 2014 at 9:13 PM, akshayutture notifications@github.com wrote:

Thanx it got installed. But when I try to use python manage.py runserver I get

ImportError: No module named apiclient

Reply to this email directly or view it on GitHub < https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46693356>

.

Shahidh K Muhammed Undergraduate Student Department of Engineering Design Indian Institute of Technology Madras Chennai 600036 Mobile: (+91) 9496362472 http://shahidhkmuhammed.in

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46695221 .

akshayutture commented 10 years ago

Yes setup is done. But I'm still getting

ImportError: No module named apiclient

when i try to run the server

AbdealiLoKo commented 10 years ago

Can you give whole stack trace? On Jun 20, 2014 9:46 PM, "akshayutture" notifications@github.com wrote:

Yes setup is done. But I'm still getting

ImportError: No module named apiclient

when i try to run the server

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46697121 .

akshayutture commented 10 years ago

I tried running it on virtualenv. I'm still getting the same error What do you mean by stack trace? On the terminal all I'm getting is

(fest-api2)akshay@akshay-Lenovo-IdeaPad-Z500:~/fest-api2/fest-api$ python manage.py runserver ImportError: No module named apiclient

I already used pip install google-api-python-client

Phoenix25 commented 10 years ago

Did you do a pip install google-api-python-client ?

On Fri, Jun 20, 2014 at 9:53 PM, akshayutture notifications@github.com wrote:

I tried running it on virtualenv. I'm still getting the same error What do you mean by stack trace? On the terminal all I'm getting is

(fest-api2)akshay@akshay-Lenovo-IdeaPad-Z500:~/fest-api2/fest-api$ python manage.py runserver

ImportError: No module named apiclient

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46697918 .

akshayutture commented 10 years ago

Thanx. pip install worked. . But now I'm getting

ImportError: No module named annoying.functions

Annoying is an installed app according to the global settings file

shahidhk commented 10 years ago

pip installed django-annoying

On Sat, Jun 21, 2014 at 10:25 AM, akshayutture notifications@github.com wrote:

Thanx. pip install worked. . But now I'm getting

ImportError: No module named annoying.functions

Annoying is a installed up according to the global settings file

— Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46744716 .

Shahidh K Muhammed Undergraduate Student Department of Engineering Design Indian Institute of Technology Madras Chennai 600036 Mobile: (+91) 9496362472 http://shahidhkmuhammed.in

shahidhk commented 10 years ago

sorry, pip install django-annoying

On Sat, Jun 21, 2014 at 11:05 AM, Shahidh K Muhammed < shahidhkmuhammed@gmail.com> wrote:

pip installed django-annoying

On Sat, Jun 21, 2014 at 10:25 AM, akshayutture notifications@github.com wrote:

Thanx. pip install worked. . But now I'm getting

ImportError: No module named annoying.functions

Annoying is a installed up according to the global settings file

— Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46744716 .

Shahidh K Muhammed Undergraduate Student Department of Engineering Design Indian Institute of Technology Madras Chennai 600036 Mobile: (+91) 9496362472 http://shahidhkmuhammed.in

Shahidh K Muhammed Undergraduate Student Department of Engineering Design Indian Institute of Technology Madras Chennai 600036 Mobile: (+91) 9496362472 http://shahidhkmuhammed.in

AbdealiLoKo commented 10 years ago

Dei, google such stuff man ...

If it says no module means u gotta install something. So google for some library with django "django annoying"

On Sat, Jun 21, 2014 at 11:07 AM, Shahidh K Muhammed < notifications@github.com> wrote:

sorry, pip install django-annoying

On Sat, Jun 21, 2014 at 11:05 AM, Shahidh K Muhammed < shahidhkmuhammed@gmail.com> wrote:

pip installed django-annoying

On Sat, Jun 21, 2014 at 10:25 AM, akshayutture notifications@github.com

wrote:

Thanx. pip install worked. . But now I'm getting

ImportError: No module named annoying.functions

Annoying is a installed up according to the global settings file

Reply to this email directly or view it on GitHub < https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46744716>

.

Shahidh K Muhammed Undergraduate Student Department of Engineering Design Indian Institute of Technology Madras Chennai 600036 Mobile: (+91) 9496362472 http://shahidhkmuhammed.in

Shahidh K Muhammed Undergraduate Student Department of Engineering Design Indian Institute of Technology Madras Chennai 600036 Mobile: (+91) 9496362472 http://shahidhkmuhammed.in

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46745265 .

akshayutture commented 10 years ago

Thanx. My development server started successfully. But I cant syncdb now

When I tried with mysql I got

......(stack trace) raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

and with sqlite3 i'm getting

(fest-api2)akshay@akshay-Lenovo-IdeaPad-Z500:~/fest-api2/fest-api$ python manage.py syncdb Syncing... OperationalError: unable to open database file

Any suggestions as to what I can do?

AbdealiLoKo commented 10 years ago

Did you install everything in requirements.txt? You mentioned an error in MySQL right? Did you install it using pip? On Jun 21, 2014 4:53 PM, "akshayutture" notifications@github.com wrote:

Thanx. My development server started successfully. But I cant syncdb now

When I tried with mysql I got

......(stack trace) raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

and with sqlite3 i'm getting

(fest-api2)akshay@akshay-Lenovo-IdeaPad-Z500:~/fest-api2/fest-api$ python manage.py syncdb Syncing... OperationalError: unable to open database file

Any suggestions as to what I can do?

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46751159 .

akshayutture commented 10 years ago

as in install mysql using pip? No i didnt. I'll do it now

And I didn't understand the part about the tastypie installation

AbdealiLoKo commented 10 years ago

The tastypie installation is not required.

Yes I meamt the MySQL installation through pip On Jun 21, 2014 9:27 PM, "akshayutture" notifications@github.com wrote:

as in install mysql using pip?

And I didn't understand the part about the tastypie installation

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46757291 .

Phoenix25 commented 10 years ago

Do u have a mysql server running? did u install it explicitly?

On Sat, Jun 21, 2014 at 9:47 PM, AbdealiJK notifications@github.com wrote:

The tastypie installation is not required.

Yes I meamt the MySQL installation through pip

On Jun 21, 2014 9:27 PM, "akshayutture" notifications@github.com wrote:

as in install mysql using pip?

And I didn't understand the part about the tastypie installation

Reply to this email directly or view it on GitHub < https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46757291

.

— Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46757803 .

akshayutture commented 10 years ago

I used sudo apt-get install mysql-client-5.5 and pip install mysql-python

When I tried to check the connection and then syncdb these are the error messages I got

(fest-api2)akshay@akshay-Lenovo-IdeaPad-Z500:~/fest-api2/fest-api$ mysqladmin -u root -p status Enter password: mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists! (fest-api2)akshay@akshay-Lenovo-IdeaPad-Z500:~/fest-api2/fest-api$ python manage.py syncdb Syncing... OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")

akshayutture commented 10 years ago

And sorry for asking so many questions, but I cannot contribute to fest-api until i get this running

AbdealiLoKo commented 10 years ago

Seems like you've forgotten your MySQL password?

Try mysql -u root -p .... then enter your password. See if it gives you that error. If yes, uninstall mysql-server.

Install mysql-client and mysql-srrver using apt-get again

You installed python MySQL through apt get I assume? On Jun 22, 2014 1:02 AM, "akshayutture" notifications@github.com wrote:

And sorry for asking so many questions, but I cannot contribute till i get this running

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46762613 .

akshayutture commented 10 years ago

Thanx. It happened. syncdb worked. Tables created. Do I have to worry about this?

Not synced (use migrations):

AbdealiLoKo commented 10 years ago

So, read up on south. South says that you need to run 'python manage.py migrate' So do that ... that's what the syncdb said

And oserror, change your media paths and stuffstuff in settings ... search for the path it gave in the error and change that to a folder which exists On Jun 22, 2014 12:20 PM, "akshayutture" notifications@github.com wrote:

akshayutture commented 10 years ago

Okay. Thanx a lot!!

I am now getting the following error and the possible reason for that is - the login.html extends base.html and base.html has the following line somewhere in the beginning {% include 'base/meta.html' %} but there is no meta.html file in the templates/base folder

The error message is

TemplateDoesNotExist at /login/

base/meta.html

Request Method: GET Request URL: http://localhost:8000/login/?next=/ Django Version: 1.5.4 Exception Type: TemplateDoesNotExist Exception Value:

base/meta.html

Exception Location: /home/akshay/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/django/template/loader.py in find_template, line 139 Python Executable: /home/akshay/fest-api2/bin/python Python Version: 2.7.3 Python Path:

['/home/akshay/fest-api2/fest-api', '/home/akshay/.pythonbrew/pythons/Python-2.7.5/lib', '/home/akshay/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages', '/home/akshay/fest-api2/lib/python2.7', '/home/akshay/fest-api2/lib/python2.7/plat-linux2', '/home/akshay/fest-api2/lib/python2.7/lib-tk', '/home/akshay/fest-api2/lib/python2.7/lib-old', '/home/akshay/fest-api2/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/home/akshay/fest-api2/local/lib/python2.7/site-packages']

Server time: Sun, 22 Jun 2014 12:43:58 +0530 Template-loader postmortem

Django tried loading these templates, in this order:

Using loader django.template.loaders.filesystem.Loader:
    /home/akshay/fest-api2/fest-api/files/templates/base/meta.html (File does not exist)
AbdealiLoKo commented 10 years ago

Yep, exactly right.

There's a meta.sample in files/templates/base ... copy and paste it as meta.html On Jun 22, 2014 1:02 PM, "akshayutture" notifications@github.com wrote:

Okay. Thanx a lot!!

I am now getting the following error and the possible reason for that is - the login.html extends base.html and base.html has the following line somewhere in the beginning {% include 'base/meta.html' %} but there is no meta.html file in the templates/base folder

The error message is

TemplateDoesNotExist at /login/

base/meta.html

Request Method: GET Request URL: http://localhost:8000/login/?next=/ Django Version: 1.5.4 Exception Type: TemplateDoesNotExist Exception Value:

base/meta.html

Exception Location: /home/akshay/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/django/template/loader.py in find_template, line 139 Python Executable: /home/akshay/fest-api2/bin/python Python Version: 2.7.3 Python Path:

['/home/akshay/fest-api2/fest-api', '/home/akshay/.pythonbrew/pythons/Python-2.7.5/lib',

'/home/akshay/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages', '/home/akshay/fest-api2/lib/python2.7', '/home/akshay/fest-api2/lib/python2.7/plat-linux2', '/home/akshay/fest-api2/lib/python2.7/lib-tk', '/home/akshay/fest-api2/lib/python2.7/lib-old', '/home/akshay/fest-api2/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/home/akshay/fest-api2/local/lib/python2.7/site-packages']

Server time: Sun, 22 Jun 2014 12:43:58 +0530 Template-loader postmortem

Django tried loading these templates, in this order:

Using loader django.template.loaders.filesystem.Loader: /home/akshay/fest-api2/fest-api/files/templates/base/meta.html (File does not exist)

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46774574 .

akshayutture commented 10 years ago

Also I had previously gotten the following error

ImproperlyConfigured at /login/

The storage backend of the staticfiles finder <class 'django.contrib.staticfiles.finders.DefaultStorageFinder'> doesn't have a valid location.

I just removed the 'django.contrib.staticfiles.finders.DefaultStorageFinder' line in staticfile_finders in global_settings. Is that okay?

akshayutture commented 10 years ago

There's no meta.html. the only files in base are base.html notifs.html settings.html topbar.html messages.html rightbar.html sidebar.html users.html Do I have to use settings.html?

AbdealiLoKo commented 10 years ago

:@ Saipraveen you didn't add it back after you deleted it

Just make a blank file named meta.html for now On Jun 22, 2014 1:13 PM, "akshayutture" notifications@github.com wrote:

There's no meta.html. the only files in base are base.html notifs.html settings.html topbar.html messages.html rightbar.html sidebar.html users.html Do I have to use settings.html?

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46774722 .

AbdealiLoKo commented 10 years ago

Hey, akshay, the first thing you're gonna do when you finish setup is update the readme ok ^_^

akshayutture commented 10 years ago

Also I had previously gotten the following error

ImproperlyConfigured at /login/

The storage backend of the staticfiles finder doesn't have a valid location.

I just removed the 'django.contrib.staticfiles.finders.DefaultStorageFinder' line in staticfile_finders in global_settings. Is that okay?

And should the readme be detailed. Like should I write what all to change in settings and all?

AbdealiLoKo commented 10 years ago

Please do it na? It'll be helpful next time On Jun 22, 2014 8:26 PM, "akshayutture" notifications@github.com wrote:

Also I had previously gotten the following error

ImproperlyConfigured at /login/

The storage backend of the staticfiles finder doesn't have a valid location.

I just removed the 'django.contrib.staticfiles.finders.DefaultStorageFinder' line in staticfile_finders in global_settings. Is that okay?

And should the readme be detailed. Like should I write what all to change in settings and all?

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46783110 .

akshayutture commented 10 years ago

Ya no problem.... Just tell me if what I did in the above file is alright or what? Because online I read that 'django.contrib.staticfiles.finders.DefaultStorageFinder' line in staticfile_finders in global_settings iss not necessary

akshayutture commented 10 years ago

Login page opened successfully and I populated data but when I try to login with any id I get the following error

DoesNotExist at /identity

No exception supplied

Request Method: GET Request URL: http://localhost:8000/identity Django Version: 1.5.4 Exception Type: DoesNotExist Exception Location: /home/akshay/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/django/db/models/fields/related.py in get, line 279

AbdealiLoKo commented 10 years ago

Ah, thats because you're not a coord, core nor supercoord.

Whats the user id and password ur using ?

On Tue, Jun 24, 2014 at 10:34 AM, akshayutture notifications@github.com wrote:

Login page opened successfully and I populated data but when I try to login with any id I get the following error

DoesNotExist at /identity

No exception supplied

Request Method: GET Request URL: http://localhost:8000/identity Django Version: 1.5.4 Exception Type: DoesNotExist Exception Location: /home/akshay/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/django/db/models/fields/related.py in get, line 279

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46932451 .

akshayutture commented 10 years ago

webops_coord2 1

AbdealiLoKo commented 10 years ago

Weird .. Check urls.py for /identity ... Find the view for it. Go to that view and check which line is giving the error by putting "print" statements everywhere

On Tue, Jun 24, 2014 at 10:41 AM, akshayutture notifications@github.com wrote:

webops_coord2 1

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#issuecomment-46932754 .

akshayutture commented 10 years ago

def login_user(request): """ A view to handle the baisc login methods in ERP

    Args:
        request:   The HTTP Request

    Kwargs:
        kwargs**:  None

    Returns:
        IF login was successful : redirects to `home.views.home()`

        ELSE : renders the `pages/login.html`
        > Context variables in the `pages/login.html` :-
            - global_context_variables : misc.utils.global_context()
            - login_form : `users.forms.LoginForm`

    Raises:
        None

    Daemon Tasks:
        - Sets various django.contrib.messages depending on actions takes in the view
        - Authenticates and logs in a django.contrib.auth.User

"""
if request.user.is_authenticated(): # Check if user is already logged in
    if hasattr(request.session, "role"):
    print 1
        return redirect("apps.home.views.home")
    else:
    print 2
        return HttpResponseRedirect(reverse("identity")) # Redirect to home page

# Logic
login_form = LoginForm()
print 3
# POST Logic
if request.method == "POST": # Check if POST data is there for the LoginForm
    login_form = LoginForm(request.POST)
    if login_form.is_valid():
    print 4
        # Checks for username and password
        username = login_form.cleaned_data["username"][:30] # As django truncates username field upto 30 chars
        password = login_form.cleaned_data["password"]

        # Authenticates user against database
        user = authenticate(username=username, password=password)
        # if user is None:
        #     # User password combination was invalid ... Maybe superuser ?
        #     superusers = User.objects.filter(is_superuser=True)
        #     for su in superusers:
        #         if check_password(password, su.password):
        #             user = get_object_or_None(User, username=username)
        #             if user:
        #                 user.backend = settings.AUTHENTICATION_BACKENDS[0]

        if user is not None:
    print 5
            if user.is_active:
                login(request, user) # Logs in the User
                #if ( not hasattr(user, "erp_profile") ): # No erp_profile ! Ask them to fill up forms
                #    return HttpResponseRedirect(reverse("profile")) # Redirect to home page    
                return HttpResponseRedirect(reverse("identity")) # Redirect to home page
            else:
                login_form.errors.update( {
                    "submit" : ["The user has been deactivated."],
                } )

        else: # errors appeared
            print 6
            login_form.errors.update( {
                "submit" : ["The username or password is incorrect"],
            } )
            messages.error(request, strings.LOGIN_ERROR_INACTIVE)
    else:
    print 7
        pass
# import pdb; pdb.set_trace()
# Return
print 8
local_context = {
    "current_page" : "login",
    "login_form": login_form,
}
return render_to_response("pages/login.html", local_context, context_instance= global_context(request, token_info=False))
akshayutture commented 10 years ago

Above is views.py. what printed in terminal is given below

3 8 true [24/Jun/2014 10:50:28] "GET /login/?next=/ HTTP/1.1" 200 3456 [24/Jun/2014 10:50:28] "GET /static/dajaxice/dajaxice.core.js HTTP/1.1" 200 16236 [24/Jun/2014 10:50:28] "GET /static/json/user_list.json HTTP/1.1" 304 0 [24/Jun/2014 10:50:28] "GET /static/json/subdept_list.json HTTP/1.1" 304 0 [24/Jun/2014 10:50:28] "GET /static/json/page_list.json HTTP/1.1" 304 0 [24/Jun/2014 10:50:28] "GET /static/json/dept_list.json HTTP/1.1" 304 0 3 4 5 [24/Jun/2014 10:50:38] "POST /login/ HTTP/1.1" 302 0 Internal Server Error: /identity Traceback (most recent call last): File "/home/akshay/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response response = callback(request, _callback_args, _callback_kwargs) File "/home/akshay/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view return view_func(request, _args, _kwargs) File "/home/akshay/fest-api2/fest-api/apps/users/views.py", line 256, in identity role_id = request.user.erp_profile.coord_relations.first().id AttributeError: 'ManyRelatedManager' object has no attribute 'first'

akshayutture commented 10 years ago

And now the error I'm getting is

AttributeError at /identity 'ManyRelatedManager' object has no attribute 'first' Request Method: GET Request URL: http://localhost:8000/identity Django Version: 1.5.4 Exception Type: AttributeError Exception Value:
'ManyRelatedManager' object has no attribute 'first' Exception Location: /home/akshay/fest-api2/fest-api/apps/users/views.py in identity, line 256

AbdealiLoKo commented 10 years ago

Yaayy ^_^

On Tue, Jun 24, 2014 at 4:34 PM, akshayutture notifications@github.com wrote:

Closed #98 https://github.com/The-WebOps-Club/fest-api/issues/98.

Reply to this email directly or view it on GitHub https://github.com/The-WebOps-Club/fest-api/issues/98#event-134499236.