Re: Setting an unusable password on an existing user
Thanks Andrew but I have a requirement where I have to programmatically set it to an unusable password based on a particular condition. I know this is a rare requirement but in the context of the application I am building it makes sense. :-) nav On Friday 21 September 2012 12:22 PM, Andrew Macgregor wrote: AFAIK you can set it to ! in the admin interface. Don't use the change password form, just enter ! into the password field on the Auth User table. I believe this will cause has_usable_password() to return False. Cheers, Andrew. On Friday, September 21, 2012 2:16:22 PM UTC+8, nav wrote: Hi, Is there any way to set the password of an existing user to and unusable value like none? I tried user.set_unusable_password() and subsequently user.save() but this did not work. Other than using this method is there a way to set the password to None or such like so that the user.has_usable_password() method will return False instead of True? Many Thanks, nav -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/yhVjvHQNUekJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Routing TCPIP requests/ responses to and from a Django app
On Fri, Sep 21, 2012 at 9:25 PM, Sithembewena Lloyd Dube wrote: > Hi everyone, > > What is the recommended way to configure a Django project to listen for and > respond to requests via the TCPIP protocol? I'm intrigued why you think there would be a a "recommended" way to do this. Django is a web framework. It exists to service HTTP requests. Outside of the limited capabilities of the development server (which, as the name suggests, shouldn't be used in production) it doesn't implement anything at the TCP/IP level. It uses the WSGI interface (or, optionally, the fCGI interface) to service HTTP requests, and relies on other tools to convert TCP/IP traffic into a WSGI request. The libraries that comprise Django could certainly be used for other purposes -- i.e., as a generic interface to database or input handling. However, I can't give you any real advice beyond "do what the docs already say", and pay some extra attention to what happens during the early stages of the request/response cycle in Django. In short -- you're in uncharted, and mostly undocumented territory. Yes, you may be able to use pieces of Django to active what you want. However, you're going to need to take the lead on this yourself. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Setting an unusable password on an existing user
This isn't that rare - it is a common UX requirement. Set the value to something that cannot hash to any input. Depending on your setup, '0' could work, or any other nonsense value. If you have a strict DB schema, IIRC, there are some magic values that SHA will never generate, but I'd have to look that up. Why not have a "this account cannot log in" flag? -j -- Sent from a phone, please excuse any terseness. On Sep 22, 2012, at 12:18 AM, Nandakumar Chandrasekhar wrote: > Thanks Andrew but I have a requirement where I have to programmatically set > it to an unusable password based on a particular condition. > > I know this is a rare requirement but in the context of the application I am > building it makes sense. :-) > > nav > > On Friday 21 September 2012 12:22 PM, Andrew Macgregor wrote: >> AFAIK you can set it to ! in the admin interface. Don't use the change >> password form, just enter ! into the password field on the Auth User >> table. I believe this will cause has_usable_password() to return False. >> >> Cheers, Andrew. >> >> On Friday, September 21, 2012 2:16:22 PM UTC+8, nav wrote: >> >>Hi, >> >>Is there any way to set the password of an existing user to and >>unusable value like none? >> >>I tried user.set_unusable_password() and subsequently user.save() >>but this did not work. >> >>Other than using this method is there a way to set the password to >>None or such like so that the user.has_usable_password() method will >>return False instead of True? >> >>Many Thanks, >>nav >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/yhVjvHQNUekJ. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django-behave
I've written a django-behave module to enable the use of the Behave BDD module inside Django's test framework. http://pypi.python.org/pypi/django-behave Basic functionality at present, but I'll be continuing development on it, and I am using it myself. If anyone would be interested in trying it out, I'd appreciate the feedback. Also, this is my first foray into writing a TestRunner; if anyone can point me at any documentation about how to do it well, I'd appreciate it. For example, what's the right way to work with other TestRunners such as nose? Rachel -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
[OT] I've created a Django application that allows you to view flickr galleries with minimalist design
Hi All, I'm a programmer and also an amateur photographer. And looking for a gallery software for my own photo site is that ended up learning is Python, Django and Linux (at my work I use only .net and c#). Because I also a flickr user I started to doing a "frontend" flickr using their API. If you want to try it just have http://flickrock.com/ to go and enter the web address of your photostream or your flickr url. You can also use http://flickrock.com/gsfc (change gscf with your flickr screen name). I'll appreciate comments, suggestions and even insults. Greetings all, Ezequiel. http://flickrock.com/mikelpierre PS: On the other hand, if any of you want to have your gallery with same design but with your own domain only have to point it at the same IP of flickrock.com and done. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: creating a button using dgango
Thanks Nik it working :) On Tuesday, September 18, 2012 10:40:59 PM UTC+2, Nikolas Stevenson-Molnar wrote: > > Does this get at what you want to accomplish? > https://docs.djangoproject.com/en/1.1/ref/contrib/formtools/form-wizard/ > > _Nik > > On 9/18/2012 1:00 PM, Ndlovu wrote: > > How do I add a simple button, that does fuction loading another > > *.html page. Basically a basic next button. > > > > My forms class looks like: > > > > forms.py: > > > > # -*- coding: utf-8 -*- > > from django import forms > > > > class ButtonForm(forms.Form): > > > > #what do put here as for the button > > ) > > > > > > The views class: > > > > views.py: > > > > # -*- coding: utf-8 -*- > > from django.shortcuts import render_to_response > > from django.template import RequestContext > > from django.http import HttpResponseRedirect > > from django.core.urlresolvers import reverse > > > > from myproject.myapp.forms import ButtonForm > > > > def list(request): > > > > #This is where I need to implement the button action. > > > > where I add the button on the *.html file: > > > > enctype="multipart/form-data"> > > {% csrf_token %} > > > > /> > > > > > > thanks. > > > > -- > > You received this message because you are subscribed to the Google > > Groups "Django users" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/django-users/-/6VXaVdPZnvIJ. > > To post to this group, send email to > > django...@googlegroups.com. > > > To unsubscribe from this group, send email to > > django-users...@googlegroups.com . > > For more options, visit this group at > > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/eR6IQ0nT9BMJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.4 and google app engine
Does it mean that few months ago newest django version for Google Cloud SQL was 1.4, and now they downgraded to 1.3? Or that was just a mistake? I am about to deal with the same problem, however I have finished my project, now I need to update it asap on GAE, but I just can not as newest version of SDK Django is 1.3, whereas my project is 1.4. Any ideas what should I do now? Please help guys:D On Sunday, June 17, 2012 5:49:15 PM UTC+2, Guevara wrote: > > In GAE only using django-norel, a fork of django with no join's queryset. > > https://developers.google.com/appengine/articles/django-nonrel > > Or using in Google Cloud SQL: > > https://developers.google.com/appengine/docs/python/cloud-sql/django > > But is a paying service. > > > 2012/6/17 Gebriel Abebe > > >> Please I want to know the same thing? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/bU3CTr2hjmQJ. >> >> To post to this group, send email to django...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> django-users...@googlegroups.com . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/zewtROlBqb8J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.4 and google app engine
On Sat, Sep 22, 2012 at 5:16 PM, neixetis wrote: > I am about to deal with the same problem, however I have finished my > project, now I need to update it asap on GAE, but I just can not as newest > version of SDK Django is 1.3, whereas my project is 1.4. Any ideas what > should I do now? Please help guys:D You can try the django 1.4 nonrel's version, although is currently in WIP state, I'm not sure how mature it is https://github.com/django-nonrel/django-1.4 The nonrel stable (1.3) works pretty well. -- Kind Regards -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Anyone using PyScripter to debug their Django apps?
Hi, The PyScripter FAQ has an entry about how to debug Django applications: https://code.google.com/p/pyscripter/wiki/FAQ#How_can_I_debug_Django_applications? Has anybody tried this out? It doesn't work for me. I can run my Django app but it ignores my breakpoints. See my post on the PyScripter group: https://groups.google.com/d/topic/pyscripter/8DDSjxJvxts/discussion Just curious if anybody got this working and could give me a hint. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/iFXSozF2zssJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
markup doesn't render mardown text in the templates
Hello, I am new to django and I am writing a simple blog application. For my app I am using markdown in order to write the texts. The issue is that the markdown plugin doesn't render my text files. I have attached my views.py and my template file Regards, Giorgos -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/VlwsKwJRKN8J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. {% extends "base.html" %} {% load markup %} {% block posts %} {% for post in posts %} {{ post.author }} {{ post.date }} {% if post.isInternalPost%} {{ post.content|markdown }} {% else %} {{ post.title }} {% autoescape off %} {{ post.content }} {% endautoescape %} {% endif %} {% endfor %} {% endblock %}# Copyright 2012 by Giorgos Tsiapaliokas # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA. from django.shortcuts import render_to_response from posts import Posts def home(request): p = Posts() print p.posts()[0]["content"] return render_to_response('posts.html', { "posts": p.posts() }) def posts(resquest, post_id): return render_to_response('posts.html', {})
Beginner problem linking pages from homepage?
Missing something basic here even after scouring web and running thru online tut a few times. Started a project 'mysite' and added twitter bootstrap then created a static homepage "index.html' to act as a simple launchpad to other more information & feature laden pages. Used direct_to_template to access the first page and it renders fine under the development server and a virtualenv (the latter is in the path). The homepage has a number of hrefs to the other pages which I filled in with './foo1', './foo2', etc. Using the hello function placed in ~/.../mysite/mysite/views.py, I've tried to branch off the main page as such in urls.py (goal is /homepage/foo1). *Note the extra code required in the file isn't represented here. from mysite.views import hello ... urlpatterns = patterns('', url(r'^foo1$', hello), url(r'^foo2$', hello), url(r'^foo3$', hello), url(r'^foo4$', hello), ) have also tried: urlpatterns = patterns('homepage', url(r'^foo1$', hello), url(r'^foo2$', hello), url(r'^foo3$', hello), url(r'^foo4$', hello), ) This causes the site to break with a 404 error even though I think I am supplying a correct regex and a toy function. I suspect there is something with the mysite views.py not being found but not sure. I have tried to more explicitly reference the views.py file with mysite.views.py trials. I am not even sure if philosophically this is considered a good practice of django. Thanks in advance for your assistance. V. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ojFywQSzpYsJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Installing a django project, database issue ?
I am installing the sunlight fondation's brisket and I am really new to python, and even more to django. So I downloaded on github the project : https://github.com/sunlightlabs/brisket. So, when I run the ./manage.py run server command, I get an error message. But I know nothing from python and django. Here's my database config : DATABASE_ENGINE = 'django.db.backends.mysql' DATABASE_NAME = 'brisker' DATABASE_USER = 'root' DATABASE_PASSWORD = 'euler;.' DATABASE_HOST = '127.0.0.1' DATABASE_PORT = '' So now here's the error message, am I supposed to install a package ? Unhandled exception in thread started by > Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in inner_run self.validate(display_num_errors=True) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 249, in validate num_errors = get_validation_errors(s, app) File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 36, in get_validation_errors for (app_name, error) in get_app_errors().items(): File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 146, in get_app_errors self._populate() File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 61, in _populate self.load_app(app_name, True) File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 76, in load_app app_module = import_module(app_name) File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module __import__(name) ImportError: No module named brisket.influence Could some one help ? Best, M. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/fJRgT-Cka1wJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.4 and google app engine
Thank you ver much for answer. Yes that could be a solution, however I need relational database :/ On Saturday, September 22, 2012 10:32:25 PM UTC+2, Gabriel [SGT] wrote: > > On Sat, Sep 22, 2012 at 5:16 PM, neixetis > > wrote: > > I am about to deal with the same problem, however I have finished my > > project, now I need to update it asap on GAE, but I just can not as > newest > > version of SDK Django is 1.3, whereas my project is 1.4. Any ideas what > > should I do now? Please help guys:D > > You can try the django 1.4 nonrel's version, although is currently in > WIP state, I'm not sure how mature it is > https://github.com/django-nonrel/django-1.4 > The nonrel stable (1.3) works pretty well. > > -- > Kind Regards > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/99OD-XWK3lkJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: [OT] I've created a Django application that allows you to view flickr galleries with minimalist design
hey Great job that's very good is there any chance you would be sharing the code? On Saturday, September 22, 2012 3:44:36 AM UTC-5, Ezequiel wrote: > > Hi All, > > I'm a programmer and also an amateur photographer. And looking for a > gallery software for my own photo site is that ended up learning is > Python, Django and Linux (at my work I use only .net and c#). > > Because I also a flickr user I started to doing a "frontend" flickr > using their API. If you want to try it just have http://flickrock.com/ > to go and enter the web address of your photostream or your flickr > url. You can also use http://flickrock.com/gsfc (change gscf with your > flickr screen name). > > I'll appreciate comments, suggestions and even insults. > > > Greetings all, > Ezequiel. > http://flickrock.com/mikelpierre > > PS: On the other hand, if any of you want to have your gallery with > same design but with your own domain only have to point it at the same > IP of flickrock.com and done. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/UjKKee-idcwJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: My "Contributors" page Conundrum
Okay Nick so your help really made a big difference. The generic view and urlconf helped a lot. Well I didn't figure out how to do Melvyn's recommendation but I was able to implement this another way. It's good but not perfect. Here's all the relevant files: - about models.py from django.db import models from django.forms import ModelForm class Contributor(models.Model): name = models.CharField(max_length=30) lowername = models.CharField(max_length=30) title = models.CharField(max_length=60) bio = models.CharField(max_length=5000) website = models.URLField() def __unicode__(self): return self.name class ContributorForm(ModelForm): class Meta: model = Contributor Basically, my key was to add another field called lowername. This field would hold the lowercase version of the contributors name. So for me it is "jjzolper". By doing this with your help I was able to make it happen. And continuing on: - about contributors (the page that lists all contributors so pulls it out of the database: {% extends "base.html" %} {% block HTMLTitle %}About{% endblock %} {% block CSSFiles %} {% endblock %} {% block JSFiles %} {% endblock %} {% block content %} Contributors {% for Contributor in Contributors_List %} http://www.madtrak.com/about/contributors/{{ Contributor.lowername }}">{{ Contributor.name }} Title: {{ Contributor.title }} {% endfor %} {% endblock %} After having created this new field in the database I could call that field as the relevant URL! The second key. Then it was simple from there on out with your code. the urlconf you described: - urls.py (r'^about/contributors/(?P[a-zA-Z]+)$', 'madtrak.about.views.contributor'), That value like you said is passed through this thing. It is sent to the view for a singular contributor: - about views.py def contributor(request, contributorname): contributor_object = Contributor.objects.filter(lowername = contributorname) return render_to_response('contributor.html', {'Contributor': contributor_object}, context_instance = RequestContext(request)) It tests to see based on the url for the request which entry corresponds to it. about contributor.html (singular so the relevant contributor) {% extends "base.html" %} {% block HTMLTitle %}About {{ Contributor.name }}{% endblock %} {% block CSSFiles %} {% endblock %} {% block JSFiles %} {% endblock %} {% block content %} {% for Contributor in Contributor %} Name: {{ Contributor.name }} Title: {{ Contributor.title }} Bio: {{ Contributor.bio }} Website: {{ Contributor.website }} {% endfor %} {% endblock %} Thanks again for the great advice. Currently this is my best implementation of my about contributor page. I really appreciate your kind words and help when doing this. If there is a better way I'm all ears! But this is what I'm going with for the time being! Thanks so much, JJ On Tuesday, August 28, 2012 1:50:09 AM UTC-4, Nick Santos wrote: > > Hi JJ, > > You're absolutely right that there is a better way to do this that doesn't > involve repetition. To start with, check out the docs under example on the > page for the URL dispatcher: > https://docs.djangoproject.com/en/dev/topics/http/urls/ - I'll walk you > through part of it though. > > First, let's take a look at how capture groups work. Capture groups allow > you to pass a variable portion of the url to a view, which is what you'll > need to do in order to have one definition that lets you have a generic > view that looks up the contributor. So, you can assign a view to a URL > where only part of it is known at the time of the definition, and pass the > unknown parts into the view. In your case, your url definition would look > like: > > urlpatterns = patterns('', > your other patterns... > (r'^about/contributor/(?P[a-zA-Z]+)/$', 'your.view.name > '), > possibly more patterns > ) > > So, what that (?P[a-zA-Z]+) says, in parts is that we want to > capture a value - designated by the parenthesis - to be passed to > your.view.name as a named parameter called contribname - this is defined > by the ?P. That value looks like text with at least one > character. The text definition is [a-zA-Z] (careful, this doesn't include > spaces right now)and the at least one is +, and comes between two slashes. > If you want to learn more about writing things like that, look into regular > expressions. > > Then, in your view, you can take that parameter and look up the relevant > contributor and make the view generic to something like: > > def contributor_page(request, contribname): > contrib_object = Contributor.objects.filter(name=contribname) > return render_to_response('contributor.html', {'Contributor': > contrib_object}, context_instance = RequestContext(request)) > > Then, in outputting your links, you can put the relevant name in the url, > etc. > > I hope that helps. Let me know if anything
Easiest way to access MySQL from Django on Mac OS X?...
Django users, What's the latest on the easiest way to access MySQL from Django on Mac OS X 10.6.8 (Snow Leopard)? I've Googled lots of info, but some may be outdated. Seems to be more complicated than it should be, especially since everything else to do with Django has been so easy. Here's what I've done and learned: - Followed MYSQLdb link in Django docs: https://docs.djangoproject.com/en/1.4/topics/install/#database-installation to: http://sourceforge.net/projects/mysql-python/ and downloaded: MySQL-python-1.2.3.tar.gz - More info at: http://mysql-python.sourceforge.net/ - Confirmed it is not already installed: % python Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb Traceback (most recent call last): File "", line 1, in File "MySQLdb/__init__.py", line 19, in import _mysql ImportError: No module named _mysql >>> % gunzip MySQL-python-1.2.3.tar.gz % tar -xvf MySQL-python-1.2.3.tar % less README - Lots of caveats. Has to be built and installed. Looks ugly. - Says it requires setuptools Python module. - Confirmed setuptools is not already installed, by trying the import statement that setup.py is going to do: % python >>> from setuptools import setup, Extension Traceback (most recent call last): File "", line 1, in ImportError: No module named setuptools >>> % python setup.py build - Got error, as expected: Traceback (most recent call last): File "setup.py", line 5, in from setuptools import setup, Extension ImportError: No module named setuptools Exit 1 % sudo python setup.py install - No. Didn't try. Not yet built. So now I need setuptools first. Am I starting down a long dependency chain of installs, or will this be easy? I have a Linux server, where it appears that I could use yum to do a painless install: % yum list all | grep -i mysql | grep -i py MySQL-python.x86_64 1.2.3-0.3.c1.1.8.amzn1 amzn-main Perhaps there's an easier way for Mac OS X also? Did some more Googling and found: http://stackoverflow.com/questions/1448429/how-to-install-mysqldb-python-data-access-library-to-mysql-on-mac-os-x which is a longish manual set of instructions by an author who wishes there were a better way, but another reply says to just use MacPorts to install it. Any advice? Thanks! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
set_language view, i18n_patterns and translated urls
Hi guys, I'm developing a website in three languages: English, Spanish and Italian. I let users change language through a select field {% csrf_token %} {% for language in LANGUAGES %} {% if language.0 == LANGUAGE_CODE %} {{language.1}} {% else %} {{language.1}} {% endif %} {% endfor %} For use i18n_patterns I added this statement in my settings TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.i18n', ) and added some urls to the urlpatterns with the i18n_patterns function in this way: urlpatterns = patterns( ... url(r'^i18n/', include('django.conf.urls.i18n')), ... ) urlpatterns += i18n_patterns('', # other urls i need to translate ) Now, if I go to the home (www.mysite.com) in get the url www.mysite.com/en (english is default language), and contents are translated in english (due to trans statement in templates). If I go to www.mysite.com/it/ writing the url in the address bar, contents are translated in italian, the selected option in select field is Italian and so on (it seems it works correctly!). BUT if I change the language though the select field (for example from spanish to italian) apparently doesn't happen nothing: the page is reloaded with the old language (spanish), but if I delete the language prefix from the address bar (calling www.mysite.com), when the page is reloaded I obtain www.mysite.com/it/, it seems the view work for a half or something. Before to use the language prefix in the urls, the language change work correcly, so there is something that doesn't work properly. I think it is cause of the prefix in the url, because the set_language view make a redirect to the same page (with the old address and not with the new). Am I missing something? How do you deal with this? Thanks in advance -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/2S_QskcUfXsJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Setting an unusable password on an existing user
On Sat, Sep 22, 2012 at 3:18 PM, Nandakumar Chandrasekhar wrote: > Thanks Andrew but I have a requirement where I have to programmatically set > it to an unusable password based on a particular condition. Andrew's given you the answer - it's just not clear that you've understood what the answer is. There are two ways to set a password on a user object: * Use the set_password() method on the user object. * Set the underlying password attribute directly. The set_password() method is just applying the password hashing logic and then saving the password field directly. If you want to set the hashed value -- or set an "unusable" value -- directly, you can do the same thing: >>> from django.contrib.auth.models import User, UNUSABLE_PASSWORD >>> user = User.objects.get(username='frank') >>> user.password u'sha1$911ee$25e954dc93f920c134ebaa067da7827922e474a6' >>> user.has_usable_password() True >>> user.set_password('foo') >>> user.password 'sha1$7h9Fpv6nLJt4$99f05f9b65569b617f32a448431736108e83be36' >>> user.has_usable_password() True >>> user.password = UNUSABLE_PASSWORD >>> user.save() >>> user.password '!' >>> user.has_usable_password() False Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django: language in field description in forms won't change
When I change language on my Django-powered site, everything works fine except the translation of the field descriptions in the forms. The description is still displayed in the old language. Only the forms already visited that session are affected. It seems like some sort of caching problem, but I don't use any caching (as far as I know) and all other parts of the site behave as expected (templates and random text using django.utils.translaction.ugettext work just fine). Summarized: 1. When I open the site and change language, and then visit a form: everything works as expected. All text is translated. 2. When I visit a form, change language and return to the form: everything is translated, but the form stays in the old language. 3. Restarting the web server forces the language to change: then Django behaves as in (1) for the current session. Until the language is changed again. Help is appreciated! Kind regards, Patrick -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/P3sRNFd-aaAJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to separate data having the same model but belonging to different users?
Question for an expert from a newbie: Could you decorate each model that has data that needs to be separated by departments? If so, you wouldn't have to remember to code the department filter on each retrieval. On Friday, September 21, 2012 10:06:35 PM UTC-4, Rohit Banga wrote: > > Hi Dennis > Thanks for summarizing the contents of the mails. > Do you foresee any problems with the Model Inheritance scheme? At my end I > am stuck at getting a way to achieve dynamic polymorphism - which is > probably because I am new to Python. > > I can create a new subclass for every Department I add. manage.py syncdb > creates the new table for every new department I add. Now I want to write > the application logic agnostic of the specific department. I want to load > the appropriate subclass dynamically at runtime. I haven't been able to do > this right now. > I can afford to create a new subclass everytime and run manage.py syndb > after that but cannot rewrite all the application logic all over again. > > I feel given the subclass name there should be an easy way in python to > get the subclass itself which I should use for the current user. > > At this point I should also mention there are a set of about 5-6 tables > (department being just one example) that I need to replicate for each new > department. I am thinking of doing it all via subclassing. That is I would > need to load as many subclass objects dynamically given the name of the > department. > If I can get the set of subclasses to use with a not too ugly looking code > is it still a terrible idea? > > Thanks > Rohit Banga > http://iamrohitbanga.com/ > > > On Fri, Sep 21, 2012 at 9:34 PM, Dennis Lee Bieber > > > wrote: > >> On Fri, 21 Sep 2012 17:54:06 -0400, Rohit Banga >> > declaimed the following in >> gmane.comp.python.django.user: >> >> > Thanks Nikolas. I think my example was not clear. >> > >> > But all the code is shared between the departments (another reason for >> you >> > to say use the same tables!). >> > I do not need to have the explicit department name in the code. I don't >> > know the name of the departments yet! (It is just a metaphor) >> > I just want to add behavior like PhysicsDepartment.objects.filter() or >> > create(), save() anywhere I want. >> > I want to work with the base class while loading the data from the >> subclass >> > at runtime. Simple polymorphism but with different database tables in >> the >> > backend. >> > >> >> I expect that over 95% of the responses will all emphasize using >> single set of tables, and a filter by the department (which is retrieved >> from the log-in authorization information) >> >> Anything else means you have to somehow dynamically: >> >> 1) use one database for authorization and; somehow OPEN a department >> database connection that the models will hook into instead of using a >> "load-time" database. That probably means you have to replace the Django >> database connection system with one that you call at run-time. IOW, you >> do not have a database configured in the normal manner -- but EVERY >> Django function that issues an SQL operation would have to do something >> like: >> >> if not dbConnection: >> dbName = authuserdepartmentname >> dbConnection = whateverapi(database=dbName,...) >> >> where dbConnection is whatever Django normally uses to track the >> database connection. >> >> >> 2) not use Django models defined at build time (ie, in code), but >> dynamically build the models at run-time so that you can specify the >> table name when accessed (sort of using code templates into which you >> substitute the needed table names which are then imported later -- good >> luck getting Django to recognize the validity of the models). >> >> >> 3) operate separate "servers" for each department. Each server would >> have its own location for datafiles, but you can probably share the >> application code via soft-links or maybe even one shared code directory. >> This is workable for those databases that allow connections defined by >> file name/path (SQLite, embedded Firebird) but not for those using a >> dedicated database server (MySQL, PostgreSQL) -- because the file "name" >> will be fixed, but the data path would be relative to the "web server" >> URL. Of course, if you have many departments, you end up with many >> "servers" on different ports: >> >> http://server.localhost:8080/ Physics >> http://server.localhost:8081/ Mathematics >> >> or your server on port 80 rewrites URLs >> >> http://physics.server.localhost/ => server.localhost:8080 >> http://mathematics.server.localhost/ => server.localhost:8081 >> or >> http://physics.server.localhost/ => >> http://server.localhost/physics >> >> where the directory structure is something like >> >> physics/ >> app1-> softlink to common/app1 >> data/ >> sqlite.db >> >> ma
Re: Beginner problem linking pages from homepage?
On 23 September 2012 06:40, Vincent Fulco wrote: > Missing something basic here even after scouring web and running thru online > tut a few times. > > Started a project 'mysite' and added twitter bootstrap then created a static > homepage "index.html' to act as a simple launchpad to other more information > & feature laden pages. Used direct_to_template to access the first page and > it renders fine under the development server and a virtualenv (the latter is > in the path). The homepage has a number of hrefs to the other pages which I > filled in with './foo1', './foo2', etc. > > Using the hello function placed in ~/.../mysite/mysite/views.py, I've tried > to branch off the main page as such in urls.py (goal is /homepage/foo1). > *Note the extra code required in the file isn't represented here. > > from mysite.views import hello > ... > urlpatterns = patterns('', >url(r'^foo1$', hello), >url(r'^foo2$', hello), >url(r'^foo3$', hello), >url(r'^foo4$', hello), > ) > > have also tried: > > urlpatterns = patterns('homepage', >url(r'^foo1$', hello), >url(r'^foo2$', hello), >url(r'^foo3$', hello), >url(r'^foo4$', hello), > ) > > This causes the site to break with a 404 error even though I think I am > supplying a correct regex and a toy function. I suspect there is something > with the mysite views.py not being found but not sure. I have tried to more > explicitly reference the views.py file with mysite.views.py trials. If you haven't already, enable DEBUG in mysite/settings.py. Your 404 page should then indicate which URL regular expressions it has checked. Are the above URL regular expressions in that list? Is ROOT_URLCONF in mysite/settings.py set to 'mysite.urls'? I just created a toy project with that urls.py and it worked fine. > I am not even sure if philosophically this is considered a good practice of > django. Thanks in advance for your assistance. V. Generally you would not create a views.py in your project directory (mysite/mysite is your project directory). You would usually create an app (mysite/manage.py startapp appname), create your views, app-level URLs, models etc. in there, and then reference them in your project urls.py by including your app's urls.py. Also, generally you would reference the view using a string, instead of the actual view function itself. This saves you from having to import every view, and avoid clashes in larger projects where you may have view functions with the same name in different apps. In the second urls.py you posted, the first parameter to patterns, where you have 'homepage' specified, is used to shorten these view function strings - that parameter is appended to your url definitions, i.e. you could use the following urls.py instead - urlpatterns = patterns('mysite', url(r'^foo1$', 'hello'), url(r'^foo2$', 'hello'), url(r'^foo3$', 'hello'), url(r'^foo4$', 'hello'), ) ... and Django will append 'mysite' to all the view function strings, turning them into 'mysite.hello'. See https://docs.djangoproject.com/en/dev/topics/http/urls/#the-view-prefix > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/ojFywQSzpYsJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django: language in field description in forms won't change
you probably are using ugettext and should be using ugettext_lazy On Sat, Sep 22, 2012 at 8:44 PM, Patrick wrote: > When I change language on my Django-powered site, everything works fine > except the translation of the field descriptions in the forms. The > description is still displayed in the old language. Only the forms already > visited that session are affected. > > It seems like some sort of caching problem, but I don't use any caching (as > far as I know) and all other parts of the site behave as expected (templates > and random text using django.utils.translaction.ugettext work just fine). > > Summarized: > > When I open the site and change language, and then visit a form: everything > works as expected. All text is translated. > When I visit a form, change language and return to the form: everything is > translated, but the form stays in the old language. > Restarting the web server forces the language to change: then Django behaves > as in (1) for the current session. Until the language is changed again. > > Help is appreciated! > > Kind regards, Patrick > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/P3sRNFd-aaAJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- "The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde |_|0|_| |_|_|0| |0|0|0| (\__/) (='.'=)This is Bunny. Copy and paste bunny (")_(") to help him gain world domination. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to separate data having the same model but belonging to different users?
Thats interesting Bill. Are you talking about something like this? http://stackoverflow.com/questions/3276700/django-model-subclass-without-changing-database-name Thanks Rohit Banga http://iamrohitbanga.com/ On Sat, Sep 22, 2012 at 8:15 PM, Bill Beal wrote: > Question for an expert from a newbie: Could you decorate each model that > has data that needs to be separated by departments? If so, you wouldn't > have to remember to code the department filter on each retrieval. > > > On Friday, September 21, 2012 10:06:35 PM UTC-4, Rohit Banga wrote: > >> Hi Dennis >> Thanks for summarizing the contents of the mails. >> Do you foresee any problems with the Model Inheritance scheme? At my end >> I am stuck at getting a way to achieve dynamic polymorphism - which is >> probably because I am new to Python. >> >> I can create a new subclass for every Department I add. manage.py syncdb >> creates the new table for every new department I add. Now I want to >> write the application logic agnostic of the specific department. I want to >> load the appropriate subclass dynamically at runtime. I haven't been able >> to do this right now. >> I can afford to create a new subclass everytime and run manage.py syndb >> after that but cannot rewrite all the application logic all over again. >> >> I feel given the subclass name there should be an easy way in python to >> get the subclass itself which I should use for the current user. >> >> At this point I should also mention there are a set of about 5-6 tables >> (department being just one example) that I need to replicate for each new >> department. I am thinking of doing it all via subclassing. That is I would >> need to load as many subclass objects dynamically given the name of the >> department. >> If I can get the set of subclasses to use with a not too ugly looking >> code is it still a terrible idea? >> >> Thanks >> Rohit Banga >> http://iamrohitbanga.com/ >> >> >> On Fri, Sep 21, 2012 at 9:34 PM, Dennis Lee Bieber >> wrote: >> >>> On Fri, 21 Sep 2012 17:54:06 -0400, Rohit Banga >>> declaimed the following in >>> gmane.comp.python.django.user: >>> >>> > Thanks Nikolas. I think my example was not clear. >>> > >>> > But all the code is shared between the departments (another reason for >>> you >>> > to say use the same tables!). >>> > I do not need to have the explicit department name in the code. I don't >>> > know the name of the departments yet! (It is just a metaphor) >>> > I just want to add behavior like PhysicsDepartment.objects.**filter() >>> or >>> > create(), save() anywhere I want. >>> > I want to work with the base class while loading the data from the >>> subclass >>> > at runtime. Simple polymorphism but with different database tables in >>> the >>> > backend. >>> > >>> >>> I expect that over 95% of the responses will all emphasize using >>> single set of tables, and a filter by the department (which is retrieved >>> from the log-in authorization information) >>> >>> Anything else means you have to somehow dynamically: >>> >>> 1) use one database for authorization and; somehow OPEN a department >>> database connection that the models will hook into instead of using a >>> "load-time" database. That probably means you have to replace the Django >>> database connection system with one that you call at run-time. IOW, you >>> do not have a database configured in the normal manner -- but EVERY >>> Django function that issues an SQL operation would have to do something >>> like: >>> >>> if not dbConnection: >>> dbName = authuserdepartmentname >>> dbConnection = whateverapi(database=dbName,..**.) >>> >>> where dbConnection is whatever Django normally uses to track the >>> database connection. >>> >>> >>> 2) not use Django models defined at build time (ie, in code), but >>> dynamically build the models at run-time so that you can specify the >>> table name when accessed (sort of using code templates into which you >>> substitute the needed table names which are then imported later -- good >>> luck getting Django to recognize the validity of the models). >>> >>> >>> 3) operate separate "servers" for each department. Each server would >>> have its own location for datafiles, but you can probably share the >>> application code via soft-links or maybe even one shared code directory. >>> This is workable for those databases that allow connections defined by >>> file name/path (SQLite, embedded Firebird) but not for those using a >>> dedicated database server (MySQL, PostgreSQL) -- because the file "name" >>> will be fixed, but the data path would be relative to the "web server" >>> URL. Of course, if you have many departments, you end up with many >>> "servers" on different ports: >>> >>> http://server.localhost:8080/ Physics >>> http://server.localhost:8081/ Mathematics >>> >>> or your server on port 80 rewrites URLs >>> >>> >>> http://physics.server.**localhost/
Re: How to separate data having the same model but belonging to different users?
I don't think so. The question actually had a different point, namely "When I put a decorator on my model, how do I keep the original name for the table?" It didn't specify what the decorator does. There is a link to a doc on proxy models, but it appears that they create multiple tables. I should think that if you have a foreign key to the department in all tables that must be segregated by department, you could create a decorator that would apply a filter with the department key. But I don't know how to do it. On Saturday, September 22, 2012 11:23:16 PM UTC-4, Rohit Banga wrote: > > Thats interesting Bill. > Are you talking about something like this? > > http://stackoverflow.com/questions/3276700/django-model-subclass-without-changing-database-name > > Thanks > Rohit Banga > http://iamrohitbanga.com/ > > > On Sat, Sep 22, 2012 at 8:15 PM, Bill Beal > > wrote: > >> Question for an expert from a newbie: Could you decorate each model that >> has data that needs to be separated by departments? If so, you wouldn't >> have to remember to code the department filter on each retrieval. >> >> >> On Friday, September 21, 2012 10:06:35 PM UTC-4, Rohit Banga wrote: >> >>> Hi Dennis >>> Thanks for summarizing the contents of the mails. >>> Do you foresee any problems with the Model Inheritance scheme? At my end >>> I am stuck at getting a way to achieve dynamic polymorphism - which is >>> probably because I am new to Python. >>> >>> I can create a new subclass for every Department I add. manage.py >>> syncdb creates the new table for every new department I add. Now I want >>> to write the application logic agnostic of the specific department. I want >>> to load the appropriate subclass dynamically at runtime. I haven't been >>> able to do this right now. >>> I can afford to create a new subclass everytime and run manage.py syndb >>> after that but cannot rewrite all the application logic all over again. >>> >>> I feel given the subclass name there should be an easy way in python to >>> get the subclass itself which I should use for the current user. >>> >>> At this point I should also mention there are a set of about 5-6 tables >>> (department being just one example) that I need to replicate for each new >>> department. I am thinking of doing it all via subclassing. That is I would >>> need to load as many subclass objects dynamically given the name of the >>> department. >>> If I can get the set of subclasses to use with a not too ugly looking >>> code is it still a terrible idea? >>> >>> Thanks >>> Rohit Banga >>> http://iamrohitbanga.com/ >>> >>> >>> On Fri, Sep 21, 2012 at 9:34 PM, Dennis Lee Bieber >> > wrote: >>> On Fri, 21 Sep 2012 17:54:06 -0400, Rohit Banga declaimed the following in gmane.comp.python.django.user: > Thanks Nikolas. I think my example was not clear. > > But all the code is shared between the departments (another reason for you > to say use the same tables!). > I do not need to have the explicit department name in the code. I don't > know the name of the departments yet! (It is just a metaphor) > I just want to add behavior like PhysicsDepartment.objects.**filter() or > create(), save() anywhere I want. > I want to work with the base class while loading the data from the subclass > at runtime. Simple polymorphism but with different database tables in the > backend. > I expect that over 95% of the responses will all emphasize using single set of tables, and a filter by the department (which is retrieved from the log-in authorization information) Anything else means you have to somehow dynamically: 1) use one database for authorization and; somehow OPEN a department database connection that the models will hook into instead of using a "load-time" database. That probably means you have to replace the Django database connection system with one that you call at run-time. IOW, you do not have a database configured in the normal manner -- but EVERY Django function that issues an SQL operation would have to do something like: if not dbConnection: dbName = authuserdepartmentname dbConnection = whateverapi(database=dbName,..**.) where dbConnection is whatever Django normally uses to track the database connection. 2) not use Django models defined at build time (ie, in code), but dynamically build the models at run-time so that you can specify the table name when accessed (sort of using code templates into which you substitute the needed table names which are then imported later -- good luck getting Django to recognize the validity of the models). 3) operate separate "servers" for each department. Each server would have its own