Django phonegap CORS
Hello I'm am stuck in a problem dealing with an CORS request from a phonegap app to an django application. What I have so far is the following: - a regular django web project - a phonegap app build on angularJS for some settings. - The idea is, that users can use the app to store relevant server informations like host, port, etc. - The app requests a token from the django project that identifies the user and uses it for further page loads. - Via a link or other redirect the app calls the django site and log in the user At the moment i can call the django site by using the app but the user has to log in manally. This has to be automated. Therefore i added the "REST Framework" and "JWT auth" to the django project. a curl call to the project results in a correct JWT token. curl -X POST -d "username=djangoadmin&password=secret" http: //192.168.1.183:8080/api-token-auth/ Well the question is now how to implement this call in the app due the CORS situation. I tried some examples like - http://www.html5rocks.com/en/tutorials/cors/ - http://jamesbrewer.io/2014/10/31/json-web-token-authentication-part-two/ but all failed :) another try was: var params = "username=" + user + "&password=" + passwd; var xhr = Utils.createCORSRequest('GET', '192.168.1.183:8080/api-token-auth/'); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader("Content-length", params.length); xhr.onload = function () { console.log(this.responseText); }; xhr.send(params); So far i would say my knowledge for the CORS situation via JQuery is a bit too low. Maybe someone has an idea how to request the token inside the app and later on use it to call the django site and make an auto login. Any help welcome :) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/34f27d1f-a282-477e-87d8-dffbfa62de2e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django phonegap CORS
Thank you for your reply Filipe The question behind was: How to implement a cross domain communication between a phonegap App and a django web project You're right I forgot the django site for the server-side headers in my mind. I'll give it a try with the plugin and test how far i come with it. Thanx again. Am Donnerstag, 12. März 2015 00:29:56 UTC+1 schrieb Filipe Ximenes: > > Not 100% sure I understood your question, but it seems that you are trying > to overcome the CORS only from the frontend side when you should be > treating it from the Django side. > Could you take a look on this package: > https://github.com/ottoyiu/django-cors-headers > > If it suits your needs, a good idea is to have your API endpoints > beginning with something like "/api/{whatever you want}" and set: > > CORS_ORIGIN_ALLOW_ALL = True > > CORS_URLS_REGEX = r'^/api/.*$' > -- > > > *Filipe Ximenes*+55 (81) 8245-9204 > > *Vinta Software Studio*http://www.vinta.com.br > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3316570b-4461-4bf1-968b-3f1ec9ebdee8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django phonegap CORS
Thanks to Filipe, the asynchronous request to django is working correctly. A request to the endpoint url results in a JSON response with the token in it. But now I have another gap in my "logic". Inside this angular app the django site is requested via a call like this, to takeover control from the app. var ref = window.open(url, '_self', 'location=yes'); ref.addEventListener('exit', function(event) { alert(event.type); }); The question is, how can I make a call the restricted view on the django site with the token included, to log in the user. Would it be a possibility to add the token as GET argument to the url? too many trees in this forest :) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/00ca9fea-316e-405b-95ba-3bc554a0274d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django phonegap CORS
Hello Filipe Thank you for the reply. Well the $http object was till now unknown for me.. there we can see how poor my AngularJS knowledge is till now. But as far as i understood the documentation i am not able to bring up a browser window by this that takes over the control of the app. The idea behind all is the following, maybe i did not describe it well. The App is only thought a a "startUp wrapper" with stored credentials in form of a login token. That token is claimed in a first asynchronous request with user credentials asked for interactively. Later on when the token is known, the app only sets the headers an calls the django web page where the user gets logged in due the header automatically. At the moment I was using the JWT (http://getblimp.github.io/django-rest-framework-jwt/) to claim a token. But i do not know how to use this to let the user been logged in with the call of a browser window. Maybe I need tho turn over to TokenBasedAuthentification like described in (http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication)? But then I will still have the same problem... How to bring the token into the headers and thenn call a page from the server rendered inside the browser in UI mode (not in the app as sub page) My idea was, that an phonegap app is nothing more than a browser rendered app. When I can create a request to a server to claim an Auth Token and be able to set this into the headers, the next Ui request to the server (launching another browser window by window.open()) will let me call directly to a restricted view. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/db6f6050-b1b9-4ea4-9729-94a3184c5e82%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Django phonegap CORS
Hello Filipe The idea with the inAppBrowser was great. I allready was using this plugin but not that way Solution for me looks like the following: 1. I'm still using djangorestframework-jwt in the first to check the user credentials - token given from server = credentials OK - no token in response = wrong credentials 2. launch the inApp browser in "hidden mode" for the login screen and inject the credentials by script 3. use callbacvk from injection to turn inApp browser in "visible mode" Many Thanx for our help Am Freitag, 13. März 2015 21:33:36 UTC+1 schrieb Filipe Ximenes: > > Alright, I think I got what you want now. > > The first solution that comes to mind is to perform everything in the > browser. That way, you will first perform "window.open()" and then show a > "login view" from django server. > > I don't have any experience with Phonegap, but it seems that this can also > help you: > > http://docs.phonegap.com/en/edge/cordova_inappbrowser_inappbrowser.md.html#addEventListener > > Maybe if you attach a "loadstart" event to the browser and save user > credentials to "localStorage" or a cookie, using the method described here: > > http://blogs.telerik.com/appbuilder/posts/13-12-23/cross-window-communication-with-cordova's-inappbrowser > > Since everything will be working in a common browser application (not a > single page application, or phonegap app), I'd suggest you to work with > default Django cookie session and not with a token based authentication. > This will be simpler since once you set the cookie, the browser will take > care off passing it over page requests and you will not need to make > customisations to your Django views regarding authentication. > > On Fri, Mar 13, 2015 at 4:53 PM, Florian Auer > wrote: > >> Hello Filipe >> >> Thank you for the reply. >> Well the $http object was till now unknown for me.. there we can see how >> poor my AngularJS knowledge is till now. >> >> But as far as i understood the documentation i am not able to bring up a >> browser window by this that takes over the control of the app. >> >> >> The idea behind all is the following, maybe i did not describe it well. >> >> The App is only thought a a "startUp wrapper" with stored credentials in >> form of a login token. >> That token is claimed in a first asynchronous request with user >> credentials asked for interactively. >> Later on when the token is known, the app only sets the headers an calls >> the django web page where the user gets logged in due the header >> automatically. >> >> At the moment I was using the JWT ( >> http://getblimp.github.io/django-rest-framework-jwt/) to claim a token. >> But i do not know how to use this to let the user been logged in with the >> call of a browser window. >> Maybe I need tho turn over to TokenBasedAuthentification like described >> in ( >> http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication >> )? >> But then I will still have the same problem... How to bring the token >> into the headers and thenn call a page from the server rendered inside the >> browser in UI mode (not in the app as sub page) >> >> My idea was, that an phonegap app is nothing more than a browser rendered >> app. >> When I can create a request to a server to claim an Auth Token and be >> able to set this into the headers, the next Ui request to the server >> (launching another browser window by window.open()) will let me call >> directly to a restricted view. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com . >> To post to this group, send email to django...@googlegroups.com >> . >> Visit this group at http://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/db6f6050-b1b9-4ea4-9729-94a3184c5e82%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/db6f6050-b1b9-4ea4-9729-94a3184c5e82%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > > > *Filipe Ximenes*+55 (81) 8245-9204 > > *Vinta Software Studio*http://www.vinta.com.br > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/164005fc-c287-4e8e-bff1-563be5fe0492%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Django 1.6 Nginx with static files outside project folder
Hello. It seems im stuck in the try to deploy my django project, consisting of multiple apps, to the production server at the point of serving the static files from the preferred directory. system details: - CentOS 6.5 - Django 1.6.4 - green Unicorn python server - Nginx webserver - python 3.3.5 pyvenv layout: |-webapps | |-sonar | | |-bin | | |-include | | |-lib #site-packages folder insite | | |-logs #server logfiles | | |-run #sock files | | |-static#collected static files | | |-myproject | | | |-[app folders] | | | |-requirements.txt | | | |-static #central static location for development | | | |-[...] | | | |-myproject | | | | |-settings.py | | | | |-[...] settings.py (shortend) # -*- coding: utf-8 -*- # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) DEBUG = True TEMPLATE_DEBUG = True ALLOWED_HOSTS = ['127.0.0.1'] TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', 'django.template.loaders.eggs.Loader', ) TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media', 'django.core.context_processors.static', 'django.core.context_processors.request', 'django.contrib.messages.context_processors.messages' ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', [...] ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) #START addition or userauth app INSTALLED_APPS += ( 'userauth', ) LOGIN_URL = '/benutzer/anmelden/' LOGOUT_URL = '/benutzer/abmelden/' LOGIN_REDIRECT_URL = '/' #END addition or userauth app #START Mobile Detection -> based on mobileESP MIDDLEWARE_CLASSES += ( 'mobileesp.middleware.MobileDetectionMiddleware', ) #END Mobile Detection INSTALLED_APPS += ( 'south', ) #fix for mysqlConector: http://www.robberphex.com/2014/02/317 SOUTH_DATABASE_ADAPTERS = { 'default': 'south.db.mysql' } #END addition for south DB Migration Tool #START addition for dajax (0.6) INSTALLED_APPS += ( 'dajaxice', 'dajax' ) STATICFILES_FINDERS += ( 'dajaxice.finders.DajaxiceFinder', ) ROOT_URLCONF = 'myproject.urls' WSGI_APPLICATION = 'myproject.wsgi.application' DATABASES = { 'default': { 'ENGINE': 'mysql.connector.django', 'NAME': 'myproject', 'USER': 'root', 'PASSWORD': 'tekkoadmin', 'HOST': '127.0.0.1', 'PORT': '3306' } } LANGUAGE_CODE = 'de' TIME_ZONE = 'Europe/Berlin' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) STATIC_ROOT = '/webapps/sonar3/static/' #production STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), #'/webapps/sonar3/static/', #not jet used ) TEMPLATE_DIRS = ( os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'templates/desktop'), os.path.join(BASE_DIR, 'templates/tablet'), os.path.join(BASE_DIR, 'templates/mobile'), ) # define if services should use multithreading SERVICES_USE_THREADS = False nginx.conf upstream sonar_app_server { # fail_timeout=0 means we always retry an upstream even if it failed # to return a good HTTP response (in case the Unicorn master nukes a # single worker for timing out). server unix:/webapps/sonar3/run/gunicorn.sock fail_timeout=0; } server { listen 8001; server_name myproject.de; client_max_body_size 4G; access_log /webapps/sonar3/logs/nginx-access.log; error_log /webapps/sonar3/logs/nginx-error.log; location /static { alias /webapps/sonar3/static; } location /media { alias /webapps/sonar3/media; } location / { # an HTTP header important enough to have its own Wikipedia entry: # http://en.wikipedia.org/wiki/X-Forwarded-For proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # enable this if and only if you use HTTPS, this helps Rack # set the proper protocol for doing redirects: # proxy_set_header X-Forwarded-
Re: Django 1.6 Nginx with static files outside project folder
Hi Yes thats correct, but i checked the static directory in /webapps/sonar3/static and the files for the admin page and the plugin specific files also are present here. But the system tries to load them from /webapps/sonar3/myproject/static. Am Samstag, 20. September 2014 00:55:40 UTC+2 schrieb Collin Anderson: > > so if you go to http://myproject.de:8001/static/some-file-in-myproject.css > it works fine, but if you go to > http://myproject.de:8001/static/admin/js/jquery.js you get a 404 Not > Found? > > Are the files you're looking for actually in webapps/sonar3/static? > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e21d689c-ccec-4882-9418-0cd4ecb5037b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
transpose values_list result from ORM
Hi I have a ORM query that results something like this: +-+-+---+ | date | key | value | +-+-+---+ | 201312 | A | 123 | | 201312 | B | 223 | | 201312 | C | 133 | | 201311 | A | 173 | | 201311 | B | 463 | | 201311 | C | 463 | +-+-+---+ As far as i know, django cannot transpose a query so i need do get this into the following format in another way: +-+-+-+-+ | date | A | B | C | +-+-+-+-+ | 201312 | 123 | 223 | 133 | | 201311 | 173 | 463 | 463 | +-+-+-+-+ I tried something like a loop and the setdefault(), but my knowledge in python seems to be too poor. kzlist = XYZ.objects.filter(...).values_list('date', 'key', 'value') data = {} for kz in klist: data.setdefault(kz['date'], {}).update({'%s' % kz['key'] : kz['value']}) Has anyone an advice to solve this little problem? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d3d3247f-57f6-49fa-9ec0-df25a6690e71%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: transpose values_list result from ORM
Hi the original variant was claiming a type mismatch: Traceback (most recent call last): File "", line 2, in TypeError: tuple indices must be integers, not str The same with your code example. Maybe the reason is that date is not an integer as it looks like, but a string representation of it? Am Donnerstag, 2. Oktober 2014 20:03:39 UTC+2 schrieb Collin Anderson: > > Assuming "klist" is a typo, your setdefault code _should_ give you > something close to what you want, though not exactly in a table. What > happens when you try? > > I simplified your code slightly: > data = {} > for kz in kzlist: # assuming klist was a typo > data.setdefault(kz['date'], {})[kz['key']] = kz['value'] # slightly > simpler > > How are you displaying the information? > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8bfcb92e-1957-4333-8b45-59c906b84112%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: transpose values_list result from ORM
Ha, I think i got it the result from my databes is a values_list with tupels that cannot be acced via name. I have to use the indizes: for kz in kzlist: data.setdefault(kz[1], {})[kz[0]] = kz[2] Am Sonntag, 5. Oktober 2014 16:07:02 UTC+2 schrieb Florian Auer: > > Hi > > the original variant was claiming a type mismatch: > Traceback (most recent call last): > File "", line 2, in > TypeError: tuple indices must be integers, not str > > The same with your code example. > Maybe the reason is that date is not an integer as it looks like, but a > string representation of it? > > Am Donnerstag, 2. Oktober 2014 20:03:39 UTC+2 schrieb Collin Anderson: >> >> Assuming "klist" is a typo, your setdefault code _should_ give you >> something close to what you want, though not exactly in a table. What >> happens when you try? >> >> I simplified your code slightly: >> data = {} >> for kz in kzlist: # assuming klist was a typo >> data.setdefault(kz['date'], {})[kz['key']] = kz['value'] # slightly >> simpler >> >> How are you displaying the information? >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e4eda96c-435e-43c9-8a08-d9ebc35a15fc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
django & gunicorn: KeyError with active log-config setting
Hi I wanted to let my gunicorn server to log its config into a dedicated file. Therefore I added an extra line: exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \ --name $NAME \ --workers $NUM_WORKERS \ --user=$USER --group=$GROUP \ --log-level=debug \ --bind=unix:$SOCKFILE \ --log-file=$ERRLOG \ --access-logfile=$LOGFILE \ --log-config=$CONFLOG # added this line with the \ before But when i start the server with supervisorctl i receive a "KeyError" for the formatters. Traceback (most recent call last): File "/webapps/sonar3/tekkoSONAR/../bin/gunicorn", line 11, in sys.exit(run()) File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/app/wsgiapp.py" , line 74, in run WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/app/base.py", line 185, in run super(Application, self).run() File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/app/base.py", line 71, in run Arbiter(self).run() File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/arbiter.py", line 57, in __init__ self.setup(app) File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/arbiter.py", line 88, in setup self.log = self.cfg.logger_class(app.cfg) File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/glogging.py", line 175, in __init__ self.setup(cfg) File "/webapps/sonar3/lib/python3.3/site-packages/gunicorn/glogging.py", line 203, in setup disable_existing_loggers=False) File "/usr/local/lib/python3.3/logging/config.py", line 70, in fileConfig formatters = _create_formatters(cp) File "/usr/local/lib/python3.3/logging/config.py", line 103, in _create_formatters flist = cp["formatters"]["keys"] File "/usr/local/lib/python3.3/configparser.py", line 937, in __getitem__ raise KeyError(key) KeyError: 'formatters' - log file exists - permissions math Keeping the --log-config out of the command, everything start correctly. Any help / idea welcome -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f186205f-8feb-4d32-8d41-7f41a9b9bfdb%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
nested inclusion tag that takes context
Hi folks I have written 2 simple inclusion tags where one is nested inside the other. (settings.html uses the {% version %} tag) Both ones refer to the request object inside the context. The reason for this is, that I have a middleware that sets some flag variables to determine what type of client i'm serving. code example: @register.inclusion_tag('inclusion/settings.html', takes_context=True) def settings(context): request = context['request'] #needed for the template return {'is_mobile:': request.is_mobile, 'is_tablet': request.is_tablet, 'is_phone': request.is_phone, 'user': request.user } @register.inclusion_tag('inclusion/version.html', takes_context=True) def version(context): request = context['request'] version_nr = '0.0.0' version_date = '01.01.1970' f = open(os.path.join(BASE_DIR, 'version.txt'), 'r') for line in f: token = line.split(':') if token[0] == 'version': version_nr = token[1] elif token[0] == 'datum': version_date = token[1] f.close() return {'is_mobile:': request.is_mobile, 'is_tablet': request.is_tablet, 'is_phone': request.is_phone, 'version_nr': version_nr, 'version_date': version_date } If i now user the {% version %} tag inside the settings.html th system complains that context['request'] is not defined for the version() function. It seems I can fix this by putting the request object into the return object of the settings funktion like: @register.inclusion_tag('inclusion/settings.html', takes_context=True) def settings(context): request = context['request'] return {'request': request, 'is_mobile:': request.is_mobile, 'is_tablet': request.is_tablet, 'is_phone': request.is_phone, 'user': request.user } But is this the correct way? Also interesting is: If I leave out the addiotion sending the request insite the result of settings back, the context object inside the version function seems to have an unnamed property at the second index that may to be some kind of request object. [{'None': None, 'True': True, 'False': False}, {'is_mobile:': True, 'user': >, 'is_phone': False, 'csrf_token': .__proxy__ object at 0x054A7828>, 'is_tablet': True} ] -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/54e95b28-adb2-46af-8e5d-d55b0d60780c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
PyDev 3.4.1 & Django 1.7: undefined variable from Import
Hi folks I'am new to django and try to follow the tutorial to digg into the code. I am using eclipse 4.3.SR2 with PyDev 3.4.1 and Django 1.7.b2 (because of the new features) In Tutorial Part 3 (https://docs.djangoproject.com/en/1.7/intro/tutorial03/) the database API is used to get the latest 5 objects latest_question_list = Question.objects.order_by('-pub_date')[:5] But my eclipse/PyDev does not resolve the objects correctly. "Question. objects" will e resolved bot not further on. This leads to the problem that PyDev is claiming about a "undefined variable from import: order_by" I know that I can turn off this in the settings, but I would like to know if there is a way to bring this auto-completion feature to work. The application is running correctly an on the python shell the auto-completion is also working. So therefor I would think it is a PyDev problem or did I just missed to add something to the config? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/13b3436a-402e-47ef-acfd-23fdbaf5166a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Django 1.6.4 debug-toolbar confusing error
Hi I am running 2 django 1.6.4 projects, both with debug toolbar enabled. The first one ist a simple project, following the a cookbook tutorial and the toolbar works fine inside. The second project ist the one, I'll wnated to start the real development in. But there every call to the most panels give me a 500 error: Internal Server Error: /__debug__/render_panel/ Traceback (most recent call last): File "C:\Python33\lib\site-packages\django\core\handlers\base.py", line 114, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Python33\lib\site-packages\debug_toolbar\views.py", line 19, in render_panel content = panel.content File "C:\Python33\lib\site-packages\debug_toolbar\panels\__init__.py", line 87, in content return render_to_string(self.template, self.get_stats()) File "C:\Python33\lib\site-packages\django\template\loader.py", line 162, in render_to_string t = get_template(template_name) File "C:\Python33\lib\site-packages\django\template\loader.py", line 138, in get_template template, origin = find_template(template_name) File "C:\Python33\lib\site-packages\django\template\loader.py", line 127, in find_template source, display_name = loader(name, dirs) File "C:\Python33\lib\site-packages\django\template\loader.py", line 43, in __call__ return self.load_template(template_name, template_dirs) File "C:\Python33\lib\site-packages\django\template\loader.py", line 49, in load_template template = get_template_from_string(source, origin, template_name) File "C:\Python33\lib\site-packages\django\template\loader.py", line 149, in get_template_from_string return Template(source, origin, name) File "C:\Python33\lib\site-packages\debug_toolbar\panels\templates\panel.py", line 71, in new_template_init old_template_init(self, template_string, origin, name) File "C:\Python33\lib\site-packages\django\template\base.py", line 125, in __init__ self.nodelist = compile_string(template_string, origin) File "C:\Python33\lib\site-packages\django\template\base.py", line 153, in compile_string return parser.parse() File "C:\Python33\lib\site-packages\django\template\base.py", line 278, in parse compiled_result = compile_func(self, token) File "C:\Python33\lib\site-packages\django\template\defaulttags.py", line 806, in do_for nodelist_loop = parser.parse(('empty', 'endfor',)) File "C:\Python33\lib\site-packages\django\template\base.py", line 278, in parse compiled_result = compile_func(self, token) File "C:\Python33\lib\site-packages\django\template\defaulttags.py", line 573, in cycle PendingDeprecationWarning, stacklevel=2) PendingDeprecationWarning: 'The `cycle` template tag is changing to escape its arguments; the non-autoescaping version is deprecated. Load it from the `future` tag library to start using the new behavior. [23/May/2014 11:59:50] "GET /__debug__/render_panel/?store_id=e6eeea46ebc04510bf489db8336adf0f&panel_id=SettingsPanel HTTP/1.1" 500 14196 the main difference is with this project, that it has a template dependency, using a mysql connector instead of sqlite. >From my point of view I dont knwo whats the problem. settings.py: # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) SECRET_KEY = 'xxx' DEBUG = True TEMPLATE_DEBUG = True ALLOWED_HOSTS = ['127.0.0.1'] # Application definition INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'cockpit', ) MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) #START addition for DEBUG-TOOLBAR INSTALLED_APPS += ( 'debug_toolbar', ) MIDDLEWARE_CLASSES += ( 'debug_toolbar.middleware.DebugToolbarMiddleware', ) INTERNAL_IPS = ('127.0.0.1',) #DEBUG_TOOLBAR_CONFIG = {'INTERCEPT_REDIRECTS': False} #deprecated #END addition for DEBUG-TOOLBAR #START addition or userauth app INSTALLED_APPS += ( 'userauth', ) #START Mobile Detection -> based on mobileESP MIDDLEWARE_CLASSES += ( 'mobileesp.middleware.MobileDetectionMiddleware', ) #END Mobile Detection ROOT_URLCONF = 'myProjectName.urls' WSGI_APPLICATION = 'myProjectName.wsgi.application' # Database # https://docs.djangoproject.com/en/1.6/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'mysql.connector.django', 'NAME': 'myProjectName', 'USER': 'root', 'PASSWORD': 'x', 'HOST': '127.0.0.1', 'PORT': '3306'