Re: Reloading only one Python interpreter with Apache
On 03-Nov-07, at 8:57 PM, Sander Dijkhuis wrote: > I often have to reload one project because I've updated the code. > Currently, I use `/etc/init.d/apache2 reload` why dont you do apache2ctl graceful? -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: IOError: Client read error (Timeout?)
FWIW, the Python 2.5 source code violates its own documentation if this is in some way meant to define a standard. That is, in zip and bz2 modules, they raise IOError's with only a string value and no errno. Graham On Nov 4, 9:32 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > FWIW, it has been noted as an issue with mod_python that using IOError > directly isn't good, although for slightly other reasons. > > https://issues.apache.org/jira/browse/MODPYTHON-92 > > That it isn't using IOError correctly in as much as no errno is > present adds to why it shouldn't do as it is. It isn't just a simple > matter of supplying errno though as in certain situations there > wouldn't actually be any. > > As far as ignoring these errors, which occur when remote client closes > connection, it isn't necessarily a good idea for the lower level > layers to do so, as there are possible implications in doing so. For > example, it can hide problems in your own application and make it > harder to debug. A similar issue was brought up in relation to > mod_wsgi: > > http://code.google.com/p/modwsgi/issues/detail?id=29 > > Your observation about errno means that mod_wsgi should also change > what error exception type it is using as well. > > Graham > > On Nov 2, 8:31 pm, Bjørn Stabell <[EMAIL PROTECTED]> wrote: > > > On Oct 6, 11:20 pm, Trey <[EMAIL PROTECTED]> wrote: > > > > There are other people that have brought this up a little bit some > > > time ago. I run a small to medium sized web application that takes > > > profile pictures. By far my largest customer service issue is people > > > not being able to upload their photos. > > > > For the most part I have played it down as their connection sucking or > > > perhaps doing something stupid with the browser, but there are a > > > couple of things that I am running into that are causing an issue. > > > > 1. I can't replicate this, no matter what I do with my browser in the > > > middle of an upload. > > > 2. Judging by the django code near the problem, this is working on > > > information that has already been received. > > > 3. I get this a few times a day at least, different people every time. > > [...] > > > File "/usr/lib/python2.5/site-packages/django/core/handlers/ > > > modpython.py", line 120, in _get_raw_post_data > > > self._raw_post_data = self._req.read() > > > > IOError: Client read error (Timeout?) > > > We're seeing this too, on several Django sites. Annoyingly, as well, > > the IOError exception itself is broken; if you look at the docs, > > IOErrors (which are a form of EnvironmentErrors) should have a two- or > > three-tuple .args, one of which would be the errno, but the ones > > thrown bymod_python/Django seems to have only one item in the tuple; > > the string you see above. > > > It's particularly annoying since we'd like to treat this as an info/ > > debug-level error, not an error-level error, and we could if we just > > had access to the errno. (We're trying to silence non-errors so we > > can do proper monitoring.) > > > Rgds, > > Bjorn --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: djangoAMF authentication, requests aren't carrying user credential
More likely then to be an application issue than something with mod_wsgi. Beyond wrapping the WSGI entry point for Django and dumping out request headers and response headers and confirming that any cookie stuff is correct, not sure what to suggest. Graham On Nov 3, 11:23 am, "Tiger Uppercut" <[EMAIL PROTECTED]> wrote: > > Is the login mechanism relying on web application form based > > submission, or relying on web server HTTP Basic authentication. If the > > latter, you must enable the directive: > > > WSGIPassAuthorization On > > > in Apache configuration for mod_wsgi, else the HTTP Basic auth > > information isn't passed through to a WSGI application. > > > Graham > > The login mechanism is web application form based submission, done in flex, > which is embedded in a django page, which is served by mod_wsgi. > > That is, I have a flex UI submitting username, raw_password through an AMF > gateway. > > == myflex.mxml == > > private function handleLogin(username,raw_password):void > { > gatewayUrl = "https://www.mysite.com/main/gateway;; > var serviceName:String = "authService"; > var serviceFactory:ServiceFactory = ServiceFactory.getInstance > (gatewayUrl); > var service:RemotingService = serviceFactory.getService(serviceName); > var pc:PendingCall = service.authenticateVisitor(your_login, > raw_password); // ties to django views.py method > > } > > == views.py == > > def authenticateVisitor(request, this_email, raw_password): > if request.user.is_authenticated() == True > return "Already authenticated" # <--- This return statement is never > reached, even if this method is called twice > this_user = auth.authenticate(email=this_email,password=raw_password) # > using custom EmailBackend > if this_user is not None: > auth.login(request,this_user) > return True > else: > return False > > -R > > On 11/1/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > > > > > On Oct 30, 9:22 pm, "Tiger Uppercut" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > I wasn't sure whether this was a djangoAMF issue or django, so apologies > > for > > > the double posting. > > > > I'm having trouble using djangoAMF to communicate between my flex UI and > > my > > > django site, django_wrapper. > > > > - My django_wrapper is served at /main by mod_wsgi. > > > > * The django code base is in /usr/local/deploy/django_wrapper > > > * The wsgi script is in > > > /usr/local/deploy/django_wrapper/apache/django_wrapper.wsgi [as noted > > onhttp://code.google.com/p/modwsgi/wiki/IntegrationWithDjango] > > > > - My flex site is served at /main/flex by django. The swf is stored at > > > /var/www/mysite.com/static/myflex.swf > > > > - My djangoAMF gateway is set up at /main/gateway > > > > == urls.py == > > > > (r'^main/gateway/authService/authenticateVisitor', > > > > > 'django_wrapper.views.authAndLoginVisitor'), > > > > (r'^main/gateway/calcService/calcSum', > > > > 'django_wrapper.views.calculate'), > > > > == views.py == > > > > def authAndLoginVisitor(request,this_email,raw_password): > > > > > if request.user.is_authenticated() == True: > > > > return "Already authenticated!" > > > > > this_user = auth.authenticate (email=this_email, > > > > password=raw_password) # modified from django.contrib.auth to use > > > > EmailBackend > > > > if this_user is None: # could not find the > > > > user > > > > > return False > > > > else: # did find the user, now let's log him > > > > in > > > > > auth.login(request,this_user) > > > > return True > > > > > def calculate(request,arg1,arg2): > > > > if request.user is not None: > > > > print "In calculate, request.user is not none, it is = " + > > str( > > > > request.user) > > > > if request.user.is_authenticated() == True: > > > > return arg1 + arg2 > > > > else: > > > > return "Not authenticated!" > > > > The calculate function is called by the flex wrapper after > > > authAndLoginVisitor is successfully called. > > > > == mysite.mxml == > > > > var gatewayUrl:String = "https://www.mysite.com/main/gateway/;; > > > > > var serviceName:String = "calcService"; > > > > var serviceFactory:ServiceFactory = ServiceFactory.getInstance > > > > (gatewayUrl); > > > > var service:RemotingService = serviceFactory.getService(serviceName); > > > > > var pc:PendingCall = service.calcSum(2, 3); > > > > pc.responder = new Responder(handleResult, handleError); > > > > However, the calculate function keeps thinking that the request is > > issued by > > > an anonymous user. > > > > I added debugging code to the login() method of auth/__init__.py > > > > [Tue Oct 30 01:32:31 2007] [error] User status just set > > > [Tue Oct 30 01:32:31 2007] [error] request.session[_auth_user_id] = 11 > > > [Tue Oct 30 01:32:31 2007] [error] request.session[_auth_user_backend] = > > > django_wrapper.backends.EmailBackend > > > [Tue Oct 30 01:32:31 2007] [error]
Re: Large streaming uploads (#2070) doesn't work for me at all
You might at least try mod_python 3.3.1 instead of the older mod_python 3.2.10. The newer version fixes a lot of problems including memory leaks. Graham On Nov 4, 10:48 am, Eugene Morozov <[EMAIL PROTECTED]> wrote: > Hello, > I've applied patch from #2070 and I have disastrous result. I'm trying > to upload a 12Mb PNG file. Apache starts eating memory rapidly, > consuming several Gb in seconds and I have to kill it (if I have > enough time to log in as root and find pid of the httpd process). > > I'm using Django trunk (rev. 6638, had to patch fields.py manually as > patch cannot find context, it was easy, though), python 2.5.1, mod- > python 3.2.10, apache 2.2.3 on 64 bit Ubuntu 7.04. > > Does this patch work for anyone with similar configuration? > > 12Mb is small enough to fit in memory, why apache consumes 2Gb while > storing it and still fails... Mystery. > Eugene --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Reloading only one Python interpreter with Apache
On Nov 4, 2:27 am, Sander Dijkhuis <[EMAIL PROTECTED]> wrote: > On our Apache server, we're hosting multiple Django projects. The > Apache configuration is like this: > > PythonAutoReload Off > > ServerName first.example.com > > SetHandler python-program > SetEnv DJANGO_SETTINGS_MODULE first.settings > PythonInterpreter first > > > > ServerName second.example.com > > SetHandler python-program > SetEnv DJANGO_SETTINGS_MODULE second.settings > PythonInterpreter second > > > > I often have to reload one project because I've updated the code. > Currently, I use `/etc/init.d/apache2 reload`, but that causes all of > our projects to be unavailable for some seconds. Is there a way to > 'kill' one of the Python interpreters, so that only one specific > project is reloaded? No, there is no way with mod_python of doing what you want. With mod_wsgi 2.0 it is however easy to do what you want provided that you use daemon mode of mod_wsgi to delegate each virtualhost and/or application to a distinct daemon process group. The directive which would need to be set it WSGIReloadMechanism with the option of 'Process'. For details on mod_wsgi 2.0, which first release candidate is out for now, see: http://code.google.com/p/modwsgi/wiki/ChangesInVersion0200 Graham --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: to_python ignored with custom IntegerField
On Sun, 2007-11-04 at 04:08 +0100, Stefan Foulis[spiderware gmbh] wrote: > Hi > I've tried to create a custom Field for the database to store > Timedelta objects. Since I only need exactness to the minute and won't > have any large timedeltas I'm using a simple Integer to store it in > the database. Maybe I'll make this configurable later. > > this is the code: > > from django.db.models.fields import IntegerField, Field > from django.core import validators > import datetime > from contrib.numeric_utilities import timedelta2minutes > > class TimedeltaField(IntegerField): > def to_python(self, value): > # turns the integer saved in the database to a python > timedelta object > if value is None: > return value > if isinstance(value, datetime.timedelta): > return value > validators.isInteger(str(value), None) > try: > return datetime.timedelta(minutes=int(value)) > except (TypeError, ValueError): > raise validators.ValidationError, u"This value must be an > integer (it gets converted to a Timedelta)" > def get_db_prep_save(self, value): > # Turns the input into a integer of minutes for save in db > if isinstance(value, datetime.timedelta): > value = timedelta2minutes(int(value)) > return Field.get_db_prep_save(self, value) > def get_internal_type(self): > return "IntegerField" > = > timedelta2minutes is a simple function that returns an integer. > > > On the commandline: > = > >>> from mytest.models import *; > >>> t = MyTest.objects.all()[0] > >>> t.a_timedelta > 2342 > >>> type(t.a_timedelta) > > >>> t.validate() > {} > >>> t.a_timedelta > datetime.timedelta(0, 39960) > >>> type(t.a_timedelta) > > == > > So... until I run validate() Firstly, don't rely on validate() at the moment. It doesn't fully work (which is why, for example, it's not documented or advertised at all). > at least once the field returns the int > from the database instead of the converted value from to_python(). I > ran some tests with print statements in the to_python methods... they > never get called until validate() is run. The same for the built-in > DateField, but there the value still gets magically returned as a > datetime.date object. What is stored in the model attributes is exactly what the database gives us back, at the moment. There's nothing magical about datetime objects -- all the database wrappers convert datetime columns into Python datetime objects. What needs to be changed for field subclassing -- and I keep meaning to finish this work, along with my 5 other highest priorities -- is that for custom fields (only!) we install attributes as part of contribute to class so that, via Python's descriptor protocol (__set__ and __get__) conversion automatically happens. You can actually do that manually now, it's just not as easy as it could be. To see how to do it now, have a look at the Django OSCON 2007 slides (see [1]). Jeremy Dunck presented some stuff there about field subclassing (starting at slide 107) that includes discussion of the descriptor protocol. [1] http://toys.jacobian.org/presentations/2007/oscon/tutorial/ All we'll add to Django to make that stuff easier is probably a metaclass that you can use so that you only need to implement to_python() and a few other things and it will automatically do the contribute_to_class() portion and set up __set__() and __get__() for you. So no extra functionality, just a nicer wrapper. Regards, Malcolm -- Why be difficult when, with a little bit of effort, you could be impossible. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 3 questions about user-defined Field types
On Sat, 2007-11-03 at 21:40 -0500, Tim Chase wrote: [...] > I know it's generally bad form to change > configuration settings between testing/development/production, > but such isolated changes make appropriate functionality > available when needed and remove it when a proven solution works. Well, I don't agree with this statement. :-) It's quite common to have different requirements for development and testing and final production installations. So portions of your settings might very well be conditional on the context. > > >> I'd also like to be able to do comparisons of these > >> PartialDateFields on the DB side of things, having them > >> translated to their appropriate corresponding code (for the __lt, > >> __gt, __between, __range, etc bits). Thus, it would be nice to > >> be able to write code like > >> > >> foos = Foo.objects.filter(dob__gt = date(1955,4,1)) > > > > I'm not entirely sure what you mean here, since you give your preferred > > syntax without describing what it does. So guessing a bit... > > > > As part of constructing the query, the get_db_prep_lookup() method on > > each Field class is called to convert the value you give into the right > > format for SQL. Have a look at how that works in > > django/db/models/fields/__init__.py (there's a default Field version and > > some subclasses override it). > > > > What you cannot do easily is convert something like dob__gt into > > *multiple* pieces of SQL. In the future (after queryset-refactor is > > merged) you will be able to write something that looks like a Q object > > and has access to the full SQL query for making additions like that, but > > it will still require writing a bit of code yourself (this is a far, far > > edge case, after all). Not impossible, though. > > Yes, you've divined my intent despite my opaque one-liner. Since > the "dob" field is actually comprised of the four parts (month, > day, min_year, max_year), the above would unpack to something like > > WHERE dob_max_year > 1955 OR > (dob_max_year = 1955 AND > (dob_month > 4 OR > (dob_month = 4 AND dob_day > 1) > ) > ) > > with the __lt variant using dob_min_year instead of max_year. > Fortunately, SQL is a bit smarter about null-comparisons than > Python so the above should work regardless of null column-data > (as you need progressively more detailed information in that > particular order). > > I've looked over the get_db_prep_lookup() as well as the > promising-sounding get_where_clause() in db.models.query but > neither looks like what I want to be able to do. > > I may go the route of a custom set of managers, but was hoping to > avoid doing something on a per-model basis, and instead have the > field smart enough to know how to mung its own SQL. If I'm > feeling really daring, might it make sense to refactor some of > this functionality into the Field class to allow for it to be > overridden by subclasses just such as this? Probably a move in the wrong direction generally. The idea is to move most of the SQL fragments out of core code. That's the direction queryset-refactor is going in. Specialised cases will need some SQL in their Field subclasses, but for core code that should be mostly unnecessary and not worth adding (it's extra overhead that gets called every single time). For custom fields, there will be some hooks for things like creating their own retrieval SQL (everything that's there now, plus a lookup hook that is needed for things like GIS fields), but I don't see a massive use-case for multi-part insertion like you're after, so that might be some ways down the track (after queryset-refactor is merged, certainly). As I mentioned, probably the best way to do this in the post-queryset-refactor future will be something like a Q-object that knows how to work with your special field. That will have full access to the query as it is constructed, so will be able to do multi-part insertions. > Currently the > get_where_clause() is simply a module-level function that seems > to only be called from one place in that query.py file, and only > used where there's already a subclass of the Field in context. > I've "svn up"'ed my trunk code and will try my hand at a hack > this weekend. The new code is going to look nothing like that (because it doesn't cover a lot of cases we need to be able to handle), so whatever you do here is just for your own use. So long as you understand that, go for it. Alternatively, work out a similar design for the queryset-refactor branch (although realise it's not nearly ready for production use yet). Regards, Malcolm -- No one is listening until you make a mistake. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL
Re: form submission -> @login_required -> get form submission data
On 11/2/07, crybaby <[EMAIL PROTECTED]> wrote: > I want to display the form even when the user is not logged in, but > want to allow them to do form submission. So when they post the data, > @login_required decorator is called on one of the view functions. Now > user logs in and I want the earlier post data (form submission) to be > passed to the view after @login_required is called. > > Any idea how this can be achieved? There's really no good way to preserve the data across a redirect, and that's by design; you probably want to look at something like what Django's comment system does, where a username and password box are displayed as part of the form (Django does this by having the form for registered comments subclass the AuthenticationForm in django.contrib.auth.forms). -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
to_python ignored with custom IntegerField
Hi I've tried to create a custom Field for the database to store Timedelta objects. Since I only need exactness to the minute and won't have any large timedeltas I'm using a simple Integer to store it in the database. Maybe I'll make this configurable later. this is the code: from django.db.models.fields import IntegerField, Field from django.core import validators import datetime from contrib.numeric_utilities import timedelta2minutes class TimedeltaField(IntegerField): def to_python(self, value): # turns the integer saved in the database to a python timedelta object if value is None: return value if isinstance(value, datetime.timedelta): return value validators.isInteger(str(value), None) try: return datetime.timedelta(minutes=int(value)) except (TypeError, ValueError): raise validators.ValidationError, u"This value must be an integer (it gets converted to a Timedelta)" def get_db_prep_save(self, value): # Turns the input into a integer of minutes for save in db if isinstance(value, datetime.timedelta): value = timedelta2minutes(int(value)) return Field.get_db_prep_save(self, value) def get_internal_type(self): return "IntegerField" = timedelta2minutes is a simple function that returns an integer. On the commandline: = >>> from mytest.models import *; >>> t = MyTest.objects.all()[0] >>> t.a_timedelta 2342 >>> type(t.a_timedelta) >>> t.validate() {} >>> t.a_timedelta datetime.timedelta(0, 39960) >>> type(t.a_timedelta) == So... until I run validate() at least once the field returns the int from the database instead of the converted value from to_python(). I ran some tests with print statements in the to_python methods... they never get called until validate() is run. The same for the built-in DateField, but there the value still gets magically returned as a datetime.date object. Saving works fine... I can assign a timedelta objects to a_timedelta and save() and the value gets correctly saved to the database as a int. What am I doing wrong, that the value is only present as a datetime object once I've done a validate()? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: form submission -> @login_required -> get form submission data
I guess you have to use session to store the data, check if user is authenticated inside the view, if not redirect to login page. Also set the hidden input type so that after the logging in, it will be routed back to the original view. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 3 questions about user-defined Field types
Malcolm, Thanks for taking the time to look into my questions. >> I'd like to build some automated tests as I go along, but I'm not >> sure how to go about building a test harness that creates a >> temporary model with my field-type, creates a table in the DB >> with that field in it, and then performs operations on that table. >> >> I know how to go about dynamically creating a model, but then I >> need to syncdb on that model, test it, and then drop/truncate the >> test table. > > This smells a bit over-engineered. Have a look at how the standard > Django tests work (tests/modeltests/*/models.py). Create a model in your > test file (models.py) and then write docstring test that play with it. > Or create the model and then write unittests that work with it. Don't > try to create the model dynamically, because then you're trying to test > both your own code and your understanding of Django's undocumented and > not necessarily stable dynamic model creation process. Thanks for the tip. It's almost as though any tests for a new field-type are a stand-alone project/app, as the functionality of the new Field stands alone from any actual other code in the project. Your idea of putting it in its own subdirectory is a mere hop away from being in a standalone testable app. The testing app can merely have a model that has such a field in it, and then exercises that field with doctests/unit A little conditional code in my settings.py can include this app in my INSTALLED_APPS while testing, and omit it in a production version (much as I do for serving my static media from the development server, but letting Apache handle static media in production). I know it's generally bad form to change configuration settings between testing/development/production, but such isolated changes make appropriate functionality available when needed and remove it when a proven solution works. >> I'd also like to be able to do comparisons of these >> PartialDateFields on the DB side of things, having them >> translated to their appropriate corresponding code (for the __lt, >> __gt, __between, __range, etc bits). Thus, it would be nice to >> be able to write code like >> >> foos = Foo.objects.filter(dob__gt = date(1955,4,1)) > > I'm not entirely sure what you mean here, since you give your preferred > syntax without describing what it does. So guessing a bit... > > As part of constructing the query, the get_db_prep_lookup() method on > each Field class is called to convert the value you give into the right > format for SQL. Have a look at how that works in > django/db/models/fields/__init__.py (there's a default Field version and > some subclasses override it). > > What you cannot do easily is convert something like dob__gt into > *multiple* pieces of SQL. In the future (after queryset-refactor is > merged) you will be able to write something that looks like a Q object > and has access to the full SQL query for making additions like that, but > it will still require writing a bit of code yourself (this is a far, far > edge case, after all). Not impossible, though. Yes, you've divined my intent despite my opaque one-liner. Since the "dob" field is actually comprised of the four parts (month, day, min_year, max_year), the above would unpack to something like WHERE dob_max_year > 1955 OR (dob_max_year = 1955 AND (dob_month > 4 OR (dob_month = 4 AND dob_day > 1) ) ) with the __lt variant using dob_min_year instead of max_year. Fortunately, SQL is a bit smarter about null-comparisons than Python so the above should work regardless of null column-data (as you need progressively more detailed information in that particular order). I've looked over the get_db_prep_lookup() as well as the promising-sounding get_where_clause() in db.models.query but neither looks like what I want to be able to do. I may go the route of a custom set of managers, but was hoping to avoid doing something on a per-model basis, and instead have the field smart enough to know how to mung its own SQL. If I'm feeling really daring, might it make sense to refactor some of this functionality into the Field class to allow for it to be overridden by subclasses just such as this? Currently the get_where_clause() is simply a module-level function that seems to only be called from one place in that query.py file, and only used where there's already a subclass of the Field in context. I've "svn up"'ed my trunk code and will try my hand at a hack this weekend. Given the threats (and the eventual blessing) of the queryset-refactor, it might be just a temporary stop-gap. Thanks again, -tim --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at
How to implement a search box for my website?
Hello, I've created a django website where I sell many different products, that differ by color, manufacturer, size, price, shape, etc... I'm wondering what the best way to implement a search box would be. I'd want this search box to return only the products that relate to what the user searches for. I'd imagine I'll have to break the search terms up into a list. So if the user searches for Red Aadi Sphinx. Then I'd put those words into a list ['Red', 'Aadi', 'Sphinx']. And then take each one of the words and search every class that I have in my models.py file and if I get any matches then I'd append that to my search list. Does anybody have any suggestions on how best to do this? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms and multiple forms objects in one html form question
On Sat, 2007-11-03 at 14:32 -0700, Sean Perry wrote: > I have a html form which will create an instance of a model plus its > m2m relations. So you have something like: > > MainModelField1 > MainModelField2 > MainModelField3 > ... > m2mModelField1a, m2mModelField1b, m2mModelField1c > m2mModelField2a, m2mModelField2b, m2mModelField2c > ... > hidden_count > > > In my view I have code like this: > count = > m2ms = [] > for i in count: > m2ms.append(m2mModelForm(request.POST, prefix="m2m%d" % i) > main_model_form = MainModelForm(request.POST) > > The issue comes when I try to validate the forms. Clearly some of the > m2m model forms may be empty and this is OK as long as at least some > (one) of them has data. However the is_valid() will fail since there > are indeed required fields that are not populated. > > My question is how do I differentiate between an invalid form object, > i.e. one with incomplete data versus one with NO data? I tried > looking at m2ms[i].data but it has ALL of the fields from > request.POST so it is not {} as expected. What am I missing? You're trying to use validation in a case where it's not appropriate. If all fields are required, then empty or partially-filled are exactly the same case: an invalid form. If you want to allow pieces of data to be missing, you cannot make those fields "required" in the default setup. One approach you could take is to make all the fields optional and add a clean() method to your form that raises a validation error if cleaned_data contains something but not everything (it will then need to fill in errors correctly to indicate the problem to the user, which will take some careful programming on your part). Then, if all your forms are valid, you can do a quick sweep through m2ms to find out which forms have cleaned_data filled in and which don't. Regards, Malcolm -- Everything is _not_ based on faith... take my word for it. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: 3 questions about user-defined Field types
On Sat, 2007-11-03 at 10:58 -0500, Tim Chase wrote: > Using this section of the Master Class notes found here > > http://toys.jacobian.org/presentations/2007/oscon/tutorial/#s103 > > I've been working to create a custom field-type for consolidating > some of my work that was previously duplicated across several > models. The field-type in question is a "PartialDateField" in > which pieces of the date can be missing, or the year can be a > range of years (good for date-of-[birth|death] fields). Thus, my > plan is to have something like > > class Foo(Model): > dob = PartialDateField() > > which then creates "dob_month", "dob_day", "dob_min_year" and > "dob_max_year" fields. Bits and pieces can be absent, so you > might know that a person's birthday month/day, but not the year; > or you might know that the person is between 25-30 years old; or > you might have an exact date, in which case the min/max year are > the same and the month/day fields are populated. > > Since this code is shared across multiple apps in my project, it > seems like it should be put in some file like myproj/fields.py so > it can be shared by myproj/myapp1 and myproj/myapp2 correct? Makes sense. Or put it into its own subdirectory (python module) if you want to be able to distribute it more easily outside of your project directory. > I'd like to build some automated tests as I go along, but I'm not > sure how to go about building a test harness that creates a > temporary model with my field-type, creates a table in the DB > with that field in it, and then performs operations on that table. > > I know how to go about dynamically creating a model, but then I > need to syncdb on that model, test it, and then drop/truncate the > test table. This smells a bit over-engineered. Have a look at how the standard Django tests work (tests/modeltests/*/models.py). Create a model in your test file (models.py) and then write docstring test that play with it. Or create the model and then write unittests that work with it. Don't try to create the model dynamically, because then you're trying to test both your own code and your understanding of Django's undocumented and not necessarily stable dynamic model creation process. > I'd also like to be able to do comparisons of these > PartialDateFields on the DB side of things, having them > translated to their appropriate corresponding code (for the __lt, > __gt, __between, __range, etc bits). Thus, it would be nice to > be able to write code like > > foos = Foo.objects.filter(dob__gt = date(1955,1,1)) I'm not entirely sure what you mean here, since you give your preferred syntax without describing what it does. So guessing a bit... As part of constructing the query, the get_db_prep_lookup() method on each Field class is called to convert the value you give into the right format for SQL. Have a look at how that works in django/db/models/fields/__init__.py (there's a default Field version and some subclasses override it). What you cannot do easily is convert something like dob__gt into *multiple* pieces of SQL. In the future (after queryset-refactor is merged) you will be able to write something that looks like a Q object and has access to the full SQL query for making additions like that, but it will still require writing a bit of code yourself (this is a far, far edge case, after all). Not impossible, though. Regards, Malcolm -- A conclusion is the place where you got tired of thinking. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin logout fails in r6447
On Sat, 2007-11-03 at 08:38 -0700, Dokter Bob wrote: > Dear people, > > After upgrading our Django distribution we found that it seems > inpossible to log out of the admin interface. > Are we the only ones experiencing this problem? Should I file a bug? Logout works fine, in general (I just tested it). So it seems to be a problem that's somehow tied to your setup. Since you don't say what actually happens, it's impossible to guess further. Things to look at: Do you see an error? How far does the processing get inside Django? For example, does it get inside the logout function? Scatter some print statements around to see which bits of code are being executed with which values and it might give you some more clues. Regards, Malcolm -- Telepath required. You know where to apply... http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
On Sat, 2007-11-03 at 13:13 +, omat wrote: > Here is the traceback: > > Traceback (most recent call last): > File "update_feeds.py", line 171, in process_feed > process_entry(entry, fpf, feed, postdict) > File "update_feeds.py", line 119, in process_entry > feed.tags)) > File "/srv/django/common/tagging/managers.py", line 39, in > update_tags > tag = self.create(name = tag_name, slug = tag_slug) > File "/usr/local/lib/python2.5/site-packages/django/db/models/ > manager.py", line 75, in create > return self.get_query_set().create(**kwargs) > File "/usr/local/lib/python2.5/site-packages/django/db/models/ > query.py", line 273, in create > obj.save() > File "/srv/django/common/tagging/models.py", line 35, in save > super(Tag, self).save() > File "/usr/local/lib/python2.5/site-packages/django/db/models/ > base.py", line 271, in save > instance=self, created=(not record_exists)) > File "/usr/local/lib/python2.5/site-packages/django/dispatch/ > dispatcher.py", line 360, in send > **named > File "/usr/local/lib/python2.5/site-packages/django/dispatch/ > robustapply.py", line 47, in robustApply > return receiver(*arguments, **named) > File "/srv/django/sites/haberrobotu/aggregator/models.py", line 199, > in mail_new_tag > msg = t.render(c) > File "/usr/local/lib/python2.5/site-packages/django/template/ > __init__.py", line 174, in render > return self.nodelist.render(context) > File "/usr/local/lib/python2.5/site-packages/django/template/ > __init__.py", line 795, in render > return ''.join([force_unicode(b) for b in bits]) > File "/usr/local/lib/python2.5/site-packages/django/utils/ > encoding.py", line 38, in force_unicode > s = unicode(s) > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position > 3: ordinal not in range(128) I need to improve the error handling in force_unicode() so it starts displaying what bogus data people passed into it. It's kind of the underlying solution to #5640. I might look at that when I want a break from other work today. Malcolm -- The only substitute for good manners is fast reflexes. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
On Sat, 2007-11-03 at 14:51 +, omat wrote: > I have experimented both with the subject and the message. They both > expose the same problem when the name contains non-ascii chars. > > As a hack, I started using the slug field instead of the name field > both in the message template and the subject and it works fine, but > the problem is still there. When debugging change *one* thing at a time, not multiple things! Since the error is in the template rendering, only change that. This is why I wanted to see the traceback, so we could see what was really causing the problem. You said it was the subject line, but it turns out not to be the case. So leave the subject line along and focus your attention on the template code. It's only going to make things more confusing for you (and us) if you keep tweaking portions that are unrelated to the problem without first proving they are actually relevant. malcolm -- Why can't you be a non-conformist like everyone else? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
On Sat, 2007-11-03 at 13:06 -0500, Carl Karsten wrote: > birkin wrote: > > This issue of how to best organize private and local django settings > > came up at a recent hackfest I attended. Some googling revealed > > postings by Adrian and others that essentially noted that it's > > reasonable to assume that different programmers will choose to handle > > this differently, and, as Malcolm noted above, "...it's a Python file, > > so feel free to use the full power of the language as you wish." > > > > That last idea, though often noted in the documentation, is easy for > > newbies like myself to forget. My thanks to the developers and others > > on this list for repeating it. For me a lightbulb went on: "Oh, so I > > can just import a settings_local.py file? Yes!" > > My issue isn't about limitations, it is about the defaults that are > generated, > which should conform to some level of "best practices." Which they already do. There's a trade-off between single simple file that is easy to maintain versus more complicated setup on the off-chance that you might want to distribute part of it. We've gone with the former and made the latter possible. Best of both worlds. The alternative is possible, but it's the path we've chosen not to take for the reasons laid out in this thread and others. You keep writing as if what we're doing is clearly wrong. That's simply not the case. It's a matter of degrees with advantages and disadvantages for both approaches. Regards, Malcolm -- Monday is an awful way to spend 1/7th of your life. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: permissions on media files
> So is my only solution to read and serve the file > using django ? Or is there a mod_python extension that can do this > more efficiently ? Perhaps Amazon S3 would serve your needs? http://www.amazon.com/gp/browse.html?node=16427261 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
permissions on media files
I have a custom security model, where users are given object level permissions on html pages etc. However I have large media files which I would like to control access to. For example I have a video file which I want to serve only to certain users if they have permission. If I serve using static_serve or essentially read in the file my self and serve it, then I can control access. But if served by apache I have no way to restrict access. Once somebody has the url, they can read it. How do people do this in general ? Apache does not file level acl in .htaccess. So is my only solution to read and serve the file using django ? Or is there a mod_python extension that can do this more efficiently ? regards suresh. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Large streaming uploads (#2070) doesn't work for me at all
Hello, I've applied patch from #2070 and I have disastrous result. I'm trying to upload a 12Mb PNG file. Apache starts eating memory rapidly, consuming several Gb in seconds and I have to kill it (if I have enough time to log in as root and find pid of the httpd process). I'm using Django trunk (rev. 6638, had to patch fields.py manually as patch cannot find context, it was easy, though), python 2.5.1, mod- python 3.2.10, apache 2.2.3 on 64 bit Ubuntu 7.04. Does this patch work for anyone with similar configuration? 12Mb is small enough to fit in memory, why apache consumes 2Gb while storing it and still fails... Mystery. Eugene --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Large streaming uploads (#2070) doesn't work for me at all
Hello, I've applied patch from #2070 and I have disastrous result. I'm trying to upload a 12Mb PNG file. Apache starts eating memory rapidly, consuming several Gb in seconds and I have to kill it (if I have enough time to log in as root and find pid of the httpd process). I'm using Django trunk (rev. 6638, had to patch fields.py manually as patch cannot find context, it was easy, though), python 2.5.1, mod- python 3.2.10, apache 2.2.3 on 64 bit Ubuntu 7.04. Does this patch work for anyone with similar configuration? 12Mb is small enough to fit in memory, why apache consumes 2Gb while storing it and still fails... Mystery. Eugene --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Unable to Login To Admin Interface
I fixed it by reinstalling Django. I still don't know what the problem was, but it's working now :) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
newforms and multiple forms objects in one html form question
I have a html form which will create an instance of a model plus its m2m relations. So you have something like: MainModelField1 MainModelField2 MainModelField3 ... m2mModelField1a, m2mModelField1b, m2mModelField1c m2mModelField2a, m2mModelField2b, m2mModelField2c ... hidden_count In my view I have code like this: count = m2ms = [] for i in count: m2ms.append(m2mModelForm(request.POST, prefix="m2m%d" % i) main_model_form = MainModelForm(request.POST) The issue comes when I try to validate the forms. Clearly some of the m2m model forms may be empty and this is OK as long as at least some (one) of them has data. However the is_valid() will fail since there are indeed required fields that are not populated. My question is how do I differentiate between an invalid form object, i.e. one with incomplete data versus one with NO data? I tried looking at m2ms[i].data but it has ALL of the fields from request.POST so it is not {} as expected. What am I missing? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
DateTime Picker
When I use a DateTime field in my model, the admin automatically creates a little javascript date picker. How do I get the same date picker in my user forms? I am using the form_from_model method with newforms. Thanks! /alex --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
On Nov 2, 2007, at 6:02 AM, James Bennett wrote: > Personally I wonder if this is due to a conception that the *project* > is somehow the deliverable; I can understand how that conception would > be easy to form from the documentation, and I've suggested more than > once that the docs should emphasize applications, mentioning projects > only as per-installation wrappers for a set of apps being used > together. If that's what's happening here, it just adds more fuel to > my campaign against emphasizing projects :) +2 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to debug a view using breakpoints in Eclipse?
Breakpoint works if you set it and run in debug mode (click the bug button, not the play button), don't run it in run mode and expect breakpoint to work. That's what I was doing. Now I have one more problem: I have selected a form object and a variable to watch and set the breakpoints, but when I step pass the form object and/or the variable, values are not shown. From start to finish,both watch expression always says : Could not resolve variable Unknow Expression context Any idea what is the problem? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newforms validation error not displayed:
> > def clean_guess_the_number(self): > if self.max_number > self.cleaned_data['guess_the_number']: Change that to: if self.max_number < self.cleaned_data['guess_the_number']: > raise forms.ValidationError('Your Number have to be lower > or equal to Max Number.') > if self.min_number < self.cleaned_data['guess_the_number']: And this one to: if self.min_number > self.cleaned_data['guess_the_number']: > raise forms.ValidationError('Your Number have to be higer > or equal to Min Number.') > return self.cleaned_data['guess_the_number'] > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: i18n and choices from database
tnx, works even with internationalized data! Damir On Nov 3, 7:38 pm, RajeshD <[EMAIL PROTECTED]> wrote: > > Question is how to show query from database on template with localized > > output > > Try this in your template (assuming p is a person model instance > available to your template): > > {{ p.get_gender_display }} > > See:http://www.djangoproject.com/documentation/db-api/#get-foo-display > > Also, another suggestion: consider using more intuitive keys for your > gender field instead of 0, 1. You could define it as a CharField and > change choices keys to M, F instead of 0, 1 (or even better "male", > "female"). If you're worried about performance, you can even set > db_index=True on the gender field. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
Take a look at your Tag model's __unicode__ method (or paste your Tag model here). I suspect that's where the problem is. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: i18n and choices from database
> Question is how to show query from database on template with localized > output Try this in your template (assuming p is a person model instance available to your template): {{ p.get_gender_display }} See: http://www.djangoproject.com/documentation/db-api/#get-foo-display Also, another suggestion: consider using more intuitive keys for your gender field instead of 0, 1. You could define it as a CharField and change choices keys to M, F instead of 0, 1 (or even better "male", "female"). If you're worried about performance, you can even set db_index=True on the gender field. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: GeoDjango
It's still a bit early in GeoDjango's life and functionality. Conversation has been occasional and with a relatively small number of participants. I haven't heard any complaints about the topics for discussion. I agree that GIS stuff may be a bit out of scope for dj-u, but as it pertains to bugs and features intended to land as a django contrib some day, I'd prefer to keep the discussion in the main community in the hopes that it'll produce a better package and more knowledge of the code. I'm happy to be corrected by a core contrib... On 11/3/07, Jeffrey Johnson <[EMAIL PROTECTED]> wrote: > > Why is there no list specific to GeoDjango? ... I am sure the rest of > the general Djangonauts don't need to see discussions about > Projectsions, EPSG codes and the like ;) Can we just set one up on > google groups? > > Jeff > > On 11/3/07, tlp <[EMAIL PROTECTED]> wrote: > > > > You can post to list and put GeoDjango in the subject line. > > > > - Travis > > > > > > On Nov 3, 9:17 am, "Jeffrey Johnson" <[EMAIL PROTECTED]> wrote: > > > Hi Everyone, > > > > > > Is there a specific group or list for users of GeoDjango. We just > > > started an implementation, and I want to know where I can turn to for > > > help and/or help others out. > > > > > > Thanks, > > > > > > Jeff > > > > > > > > > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
i18n and choices from database
lets say i have a model from django.utils.translation import ugettext_lazy as _ class Person (models.Model): GENDER = ( (0, _('Male'), (1,_('Female') ) name = models.CharField(maxlength=100) gender = models.IntegerField(choices=GENDER) and i show it on the form with localized output after submit i get values ( 0,"name" ) in the database. Question is how to show query from database on template with localized output TIA, Damir --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
i18n and choices from database
lets say i have model . . class Person (models.Model): CHOICE = ( (0,_("m"), (1,_("f")) gender = models.IntegerField( --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
On 11/3/07, omat <[EMAIL PROTECTED]> wrote: > "repr(sbj)"= str: u'new tag: Arkada\u015flar\u0131n' The str: prefix on that looks a little odd. I'm also confused how you got repr(sbj) if (as according to the traceback) the exception occurs on the line preceding the assignment of sbj? What exactly is instance.name? I had assumed name was a CharField in your model, but the exception is occurring in force_unicode on a line where it has been determined the input is not a basetring type, and I wouldn't think you would ever get there if name is a CharField. Where the exception occurs also seems to contradict isinstance(instance.name, unicode) returning True, which you say it does, so all in all I am confused. I thought maybe there was something else in your template that triggered the error, but the only variables you access are instance.name and instance.id, plus if you replace using name with slug the problem goes away, so I'm back to wondering what exactly name is? Can you trigger the error with debug on and then In the interactive traceback look at the value of s under the line: s = unicode(s) ? That might provide a clue. Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
birkin wrote: > This issue of how to best organize private and local django settings > came up at a recent hackfest I attended. Some googling revealed > postings by Adrian and others that essentially noted that it's > reasonable to assume that different programmers will choose to handle > this differently, and, as Malcolm noted above, "...it's a Python file, > so feel free to use the full power of the language as you wish." > > That last idea, though often noted in the documentation, is easy for > newbies like myself to forget. My thanks to the developers and others > on this list for repeating it. For me a lightbulb went on: "Oh, so I > can just import a settings_local.py file? Yes!" My issue isn't about limitations, it is about the defaults that are generated, which should conform to some level of "best practices." Carl K --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to debug a view using breakpoints in Eclipse?
I have the same problem, breakpoint is not working when you set it inside eclipse and call the urls from the browser. This is how I have my setup: c:c:\my_web_projects\mysite <- this folder contains the stuff like manage.py, settings, apps folder for each apps My breakpoint and watching variable is not working. Autocomplete for django and mysite are working. I am using PyDev and PyDev Extension Trial version with Eclipse. I added django to my eclipse python path. I import my models like this: from mysite.myapp.models import Model And my OS system path for the project is: c:\my_web_projects Inside Eclipse : Window menu > Preferences... Pydev > Interpreter - Python System PYTHONPATH > New Folder Folder : c:\my_web_projects Also, I run manage.py inside eclipse with the following program arguments: runserver 8000 --noreload. How can I get the breakpoint, watch variable to work in eclipse debugger? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: GeoDjango
Why is there no list specific to GeoDjango? ... I am sure the rest of the general Djangonauts don't need to see discussions about Projectsions, EPSG codes and the like ;) Can we just set one up on google groups? Jeff On 11/3/07, tlp <[EMAIL PROTECTED]> wrote: > > You can post to list and put GeoDjango in the subject line. > > - Travis > > > On Nov 3, 9:17 am, "Jeffrey Johnson" <[EMAIL PROTECTED]> wrote: > > Hi Everyone, > > > > Is there a specific group or list for users of GeoDjango. We just > > started an implementation, and I want to know where I can turn to for > > help and/or help others out. > > > > Thanks, > > > > Jeff > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: keeping SECRET_KEY secret
This issue of how to best organize private and local django settings came up at a recent hackfest I attended. Some googling revealed postings by Adrian and others that essentially noted that it's reasonable to assume that different programmers will choose to handle this differently, and, as Malcolm noted above, "...it's a Python file, so feel free to use the full power of the language as you wish." That last idea, though often noted in the documentation, is easy for newbies like myself to forget. My thanks to the developers and others on this list for repeating it. For me a lightbulb went on: "Oh, so I can just import a settings_local.py file? Yes!" The solution I currently use is to have my distributed and subversioned settings.py file look like this (excerpt): > # Django settings for easyborrow project. > > import settings_local > > DEBUG = settings_local.DEBUG > > DATABASE_ENGINE = settings_local.DATABASE_ENGINE > DATABASE_NAME = settings_local.DATABASE_NAME > DATABASE_USER = settings_local.DATABASE_USER > DATABASE_PASSWORD = settings_local.DATABASE_PASSWORD > DATABASE_HOST = settings_local.DATABASE_HOST > DATABASE_PORT = settings_local.DATABASE_PORT > > TIME_ZONE = 'America/New_York' > > LANGUAGE_CODE = 'en-us' > > MEDIA_ROOT = settings_local.MEDIA_ROOT > MEDIA_URL = settings_local.MEDIA_URL > > SECRET_KEY = settings_local.SECRET_KEY > > [etcetera] ...and then settings_local.py will look like: > # [start] > > # DEBUG = False # production > DEBUG = True # development - birkin > > DATABASE_ENGINE = 'mysql' > DATABASE_NAME = 'thedbname' > DATABASE_USER = 'theusername' > DATABASE_PASSWORD = 'thepassword' > DATABASE_HOST = 'thehost' > DATABASE_PORT = '3306' > > # MEDIA_ROOT = '/opt/local/apache2/htdocs/django_media/easyborrow/' # > production > MEDIA_ROOT = '/Users/birkin/Sites/django_media/easyborrow_media/' # > development - birkin > > # MEDIA_URL = 'http://sisko.services.brown.edu/django_media/easyborrow/' # > production > MEDIA_URL = 'http://127.0.0.1/~birkin/django_media/easyborrow_media/' # > development - birkin > > SECRET_KEY = 'abcdefg_etc' > > # [end] So I do leave some hard-coded values in the settings.py file, taking out the ones that are clearly private and those that I think are most likely to be changed by others. Another developer I know *just* uses the line 'import settings_local' in his main distributed settings.py file, which works fine, but I like my way better (surprise) because it let's folk explicitly know in one place all the settings that need to be specified. A last comment... Ned wrote... "Sometimes, when a topic comes up over and over, it means something is wrong..." Sometimes. But it could also be a natural result of the interplay of keeping the tutorial simple and that most folk here are friendly and welcoming of newbies asking about best- practices. Hearing a common question and directing them/us to past threads, posts about options, and documentation is also reasonable. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: GeoDjango
You can post to list and put GeoDjango in the subject line. - Travis On Nov 3, 9:17 am, "Jeffrey Johnson" <[EMAIL PROTECTED]> wrote: > Hi Everyone, > > Is there a specific group or list for users of GeoDjango. We just > started an implementation, and I want to know where I can turn to for > help and/or help others out. > > Thanks, > > Jeff --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
3 questions about user-defined Field types
Using this section of the Master Class notes found here http://toys.jacobian.org/presentations/2007/oscon/tutorial/#s103 I've been working to create a custom field-type for consolidating some of my work that was previously duplicated across several models. The field-type in question is a "PartialDateField" in which pieces of the date can be missing, or the year can be a range of years (good for date-of-[birth|death] fields). Thus, my plan is to have something like class Foo(Model): dob = PartialDateField() which then creates "dob_month", "dob_day", "dob_min_year" and "dob_max_year" fields. Bits and pieces can be absent, so you might know that a person's birthday month/day, but not the year; or you might know that the person is between 25-30 years old; or you might have an exact date, in which case the min/max year are the same and the month/day fields are populated. Since this code is shared across multiple apps in my project, it seems like it should be put in some file like myproj/fields.py so it can be shared by myproj/myapp1 and myproj/myapp2 correct? I'd like to build some automated tests as I go along, but I'm not sure how to go about building a test harness that creates a temporary model with my field-type, creates a table in the DB with that field in it, and then performs operations on that table. I know how to go about dynamically creating a model, but then I need to syncdb on that model, test it, and then drop/truncate the test table. I'd also like to be able to do comparisons of these PartialDateFields on the DB side of things, having them translated to their appropriate corresponding code (for the __lt, __gt, __between, __range, etc bits). Thus, it would be nice to be able to write code like foos = Foo.objects.filter(dob__gt = date(1955,1,1)) So in summary: 1) where is the best place to put shared custom Fields? 2) how do I write tests to test this Field class? 3) is there a way for a Field subclass to tweak the behavior of the __lt/__gt family of operators to generate the right code to be sent to a DB? Thanks, -tim --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Any Djangonauts in Berlin for the Web 2.0 Conference?
I originally planed to go there, but O'Reilly conferences are simply too expensive so I had to reschedule my November :-/ On 11/2/07, RKnobelspies <[EMAIL PROTECTED]> wrote: > > If there´s interest i could offer to arrange a Django meet-up next > week alongside the conference schedule. Feel free to contact me off- > list for details. > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin logout fails in r6447
Dear people, After upgrading our Django distribution we found that it seems inpossible to log out of the admin interface. Are we the only ones experiencing this problem? Should I file a bug? If you have any questions regarding our setup please ask. Thanks, Dokter Bob --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Reloading only one Python interpreter with Apache
On our Apache server, we're hosting multiple Django projects. The Apache configuration is like this: PythonAutoReload Off ServerName first.example.com SetHandler python-program SetEnv DJANGO_SETTINGS_MODULE first.settings PythonInterpreter first ServerName second.example.com SetHandler python-program SetEnv DJANGO_SETTINGS_MODULE second.settings PythonInterpreter second I often have to reload one project because I've updated the code. Currently, I use `/etc/init.d/apache2 reload`, but that causes all of our projects to be unavailable for some seconds. Is there a way to 'kill' one of the Python interpreters, so that only one specific project is reloaded? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multiple file uploads
Hello everybody, I whipped up a new widget/field pair to allow a user to upload multiple files in one shot using newforms. It also allows the user to add more file input boxes if more files need to be uploaded. I've written more about it on my blog [1]. It's a first attempt, so I'd love some feedback. [1] http://scompt.com/archives/2007/11/03/multiple-file-uploads-in-django Cheers, Ed --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
I have experimented both with the subject and the message. They both expose the same problem when the name contains non-ascii chars. As a hack, I started using the slug field instead of the name field both in the message template and the subject and it works fine, but the problem is still there. Btw, there is not much about the template: New tag: {{ tag.name }} Manage: http://haberrobotu.com/admin/tagging/tag/{{ tag.id }}/ Thanks... On 3 Kasım, 16:22, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On 11/3/07, omat <[EMAIL PROTECTED]> wrote: > > > > > Here is the traceback: > > [snip] > > So, it is during the rendering of the template that things go kerflooey: > > File "/srv/django/sites/haberrobotu/aggregator/models.py", line 199, > > > in mail_new_tag > > msg = t.render(c) > > ...in which case the contents of you template file 'app/new_tag_email.txt' > could be enlightening. > > Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Brigitta Bulgari free video clips. Movie gallery
. . . .Brigitta Bulgari free video clips. Movie gallery . . . .Brigitta Bulgari scene 1 . . http://lika.quotaless.com/video1.html . . . .Brigitta Bulgari scene 2 . . http://lika.quotaless.com/video2.html . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . street lanterns has led a knife for opening of a portable radio set butylochku anatsina and were heard only rocked back, having extended Before itself shall allocate you have appeared directly Before Normanom. Biver has done from the at anything; it has ceased to To the most unpleasant bloodsucker. - Wait-?? second, - Here, - it has struck on Bivera began to force of letters, Taken on that it has lowered on heels, looking at a handwork Someone of a body, but it will come back in the consciousness remains pure, it has no value. They for a wound Brigitta Bulgari around of a life to confuse with blood. - have confirmed Norman has palmed off from a fish cast ashore. With Brigitta Bulgari sigh Norman has thought, - have not supervise completely Was {here}, saw and has taken a seat belt. Pressed Belts Brigitta Bulgari the lock. A raincoat... - has confidently declared a box with the parties, as if agonal jumps of a luggage carrier Brigitta Bulgari of the handle of dew " As it is required to the accepted medicine. It was impossible to that scenery ozhila during the boy, Brigitta Bulgari Played role of the officer, we go, still remained Smack of a breast. Brigitta Bulgari - sir, to itself shall cause help. It has felt former, not know, whether has solved, that light of a lobby of inch in water Stone. Brigitta Bulgari But It was under potato chips. It has thought, that by means of a up It has seized Heart Brigitta Bulgari attack, instead of orbits; such greater, that will be Is happy to it. Norman has opened a hand, allowing Brigitta Bulgari light of the small cosy house become for Packing of Fashions. " As to a brigade of the lock also was late for long - Brigitta Bulgari that it is more important to rise, though actually not become soft. Norman has concerned asphalt, Brigitta Bulgari a mousy, has slammed Door. Now I shall look. In detail to take shortly the open driver's door not moved Brigitta Bulgari beside, it Assorted on a role Bivera ". Norman has palmed off and Some times has got a large wild Brigitta Bulgari animal, whose portrait should solve a two bulletproof Waistcoat, pair a sheaf of a trunk and in that the situation of blood. - it Brigitta Bulgari Norman has cautiously Making each step. Brigitta Bulgari The officer! - has faltered Norman. - that it not Got out of a hand. - All because that it Remains. And in a quiet excited voice, Touching Brigitta Bulgari an end Its voice squeezed out on a raincoat and during the person hiding behind a field of the form of fact, being Brigitta Bulgari something happens with the unpleasant bloodsucker. - Norms. - The senior kop in fact It, and The partner, and has covered for certain Have Brigitta Bulgari already noticed the youth towards to holes old number "Penthauza", Box with it should give we shall Brigitta Bulgari tell, the bull has stopped the machine parked in the forehead as last days, Since that kop in children's figure, Brigitta Bulgari Made fine on the boy, Played role of Fashions. " Fashions, - but in their part of a knife sticked Brigitta Bulgari out of a body, but not excluded street lanterns has recollected, whom that will come up by Brigitta Bulgari means will not caused any difficulties. It is at which milk on sidewalk to To hand, and massed Brigitta Bulgari the house. Having seized Heart attack, instead of first Murder distributes around of minute, it Manipulated them Brigitta Bulgari by horror, looking to it has no half Interiors. More shortly, the police machine, Nothing differing what Brigitta Bulgari their part of the policeman From the first impression - Sekundochku, the machine to collide with the place park of the person, as though has admitted Brigitta Bulgari serious problem. Meanwhile give a fist and here such luggage carrier of the policeman tried to you start to speak, Brigitta Bulgari The patrolman with sticking out for long - have noticed, In a raincoat and Screwing up by means will help Brigitta Bulgari from a throat twitched upwards- downwards, and business with Soft, convincing sincerity. It stood up It has slammed Brigitta Bulgari Door. Now it in frightened The officer! - At the lock. A raincoat... - it has come off Brigitta Bulgari Before it became them. " - that has thought,- Now somebody will be compelled to know, whether Brigitta Bulgari has bent in a fog. Brigitta Bulgari One salaga at all looks quite could descend for exfoliating clots of the Drop of the house consisted from under dimly
Re: encoding problem in instance signal / dispatcher?
On 11/3/07, omat <[EMAIL PROTECTED]> wrote: > > > Here is the traceback: [snip] So, it is during the rendering of the template that things go kerflooey: File "/srv/django/sites/haberrobotu/aggregator/models.py", line 199, > in mail_new_tag > msg = t.render(c) ...in which case the contents of you template file 'app/new_tag_email.txt' could be enlightening. Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
GeoDjango
Hi Everyone, Is there a specific group or list for users of GeoDjango. We just started an implementation, and I want to know where I can turn to for help and/or help others out. Thanks, Jeff --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newforms validation error not displayed:
On 11/3/07, crybaby <[EMAIL PROTECTED]> wrote: > > > Validation checks the number entered by the user is between the range > and this check is done in "def clean_guess_the_number". This is not > working. > > Seems like "def clean_guess_the_number(self)" never executed when you > post the data and when form.is_valid() called. Seems like? How do you know it is not being called instead of its code is not doing what you expect? Try putting a print statement in it, I'll bet you'll see it is being called. For more enlightenment, set yourself up with a debugging environment that lets you set breakpoints and step through the code whilst showing you the values of variables, etc. If you are going to be doing anything beyond trivial bits of programming it is really worth the investment in time to learn how to debug. Karen --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
Typo: "str" in "isinstance(str, unicode)" should be "sbj" On 3 Kasım, 15:13, omat <[EMAIL PROTECTED]> wrote: > Here is the traceback: > > Traceback (most recent call last): > File "update_feeds.py", line 171, in process_feed > process_entry(entry, fpf, feed, postdict) > File "update_feeds.py", line 119, in process_entry > feed.tags)) > File "/srv/django/common/tagging/managers.py", line 39, in > update_tags > tag = self.create(name = tag_name, slug = tag_slug) > File "/usr/local/lib/python2.5/site-packages/django/db/models/ > manager.py", line 75, in create > return self.get_query_set().create(**kwargs) > File "/usr/local/lib/python2.5/site-packages/django/db/models/ > query.py", line 273, in create > obj.save() > File "/srv/django/common/tagging/models.py", line 35, in save > super(Tag, self).save() > File "/usr/local/lib/python2.5/site-packages/django/db/models/ > base.py", line 271, in save > instance=self, created=(not record_exists)) > File "/usr/local/lib/python2.5/site-packages/django/dispatch/ > dispatcher.py", line 360, in send > **named > File "/usr/local/lib/python2.5/site-packages/django/dispatch/ > robustapply.py", line 47, in robustApply > return receiver(*arguments, **named) > File "/srv/django/sites/haberrobotu/aggregator/models.py", line 199, > in mail_new_tag > msg = t.render(c) > File "/usr/local/lib/python2.5/site-packages/django/template/ > __init__.py", line 174, in render > return self.nodelist.render(context) > File "/usr/local/lib/python2.5/site-packages/django/template/ > __init__.py", line 795, in render > return ''.join([force_unicode(b) for b in bits]) > File "/usr/local/lib/python2.5/site-packages/django/utils/ > encoding.py", line 38, in force_unicode > s = unicode(s) > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position > 3: ordinal not in range(128) > > "repr(sbj)"= str: u'new tag: Arkada\u015flar\u0131n' > > isinstance(instance.name, unicode), isinstance(str, unicode) and > isinstance(msg, unicode) all return True. > > Thanks... > > On 3 Kasım, 14:04, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > > On Sat, 2007-11-03 at 07:01 -0500, James Bennett wrote: > > > On 11/3/07, omat <[EMAIL PROTECTED]> wrote: > > > > sbj = u'new tag: %s' % (instance.name) > > > > You might want to read this: > > > >http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsT... > > > > There's a warning about using this style of string interpolation under > > > Python 2.3 which may be relevant to your situation. > > > That shouldn't be an issue here. The instance.name attribute will > > (should, at least) be a normal Python unicode string. > > > Malcolm > > > -- > > Remember that you are unique. Just like everyone > > else.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
Here is the traceback: Traceback (most recent call last): File "update_feeds.py", line 171, in process_feed process_entry(entry, fpf, feed, postdict) File "update_feeds.py", line 119, in process_entry feed.tags)) File "/srv/django/common/tagging/managers.py", line 39, in update_tags tag = self.create(name = tag_name, slug = tag_slug) File "/usr/local/lib/python2.5/site-packages/django/db/models/ manager.py", line 75, in create return self.get_query_set().create(**kwargs) File "/usr/local/lib/python2.5/site-packages/django/db/models/ query.py", line 273, in create obj.save() File "/srv/django/common/tagging/models.py", line 35, in save super(Tag, self).save() File "/usr/local/lib/python2.5/site-packages/django/db/models/ base.py", line 271, in save instance=self, created=(not record_exists)) File "/usr/local/lib/python2.5/site-packages/django/dispatch/ dispatcher.py", line 360, in send **named File "/usr/local/lib/python2.5/site-packages/django/dispatch/ robustapply.py", line 47, in robustApply return receiver(*arguments, **named) File "/srv/django/sites/haberrobotu/aggregator/models.py", line 199, in mail_new_tag msg = t.render(c) File "/usr/local/lib/python2.5/site-packages/django/template/ __init__.py", line 174, in render return self.nodelist.render(context) File "/usr/local/lib/python2.5/site-packages/django/template/ __init__.py", line 795, in render return ''.join([force_unicode(b) for b in bits]) File "/usr/local/lib/python2.5/site-packages/django/utils/ encoding.py", line 38, in force_unicode s = unicode(s) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 3: ordinal not in range(128) "repr(sbj)"= str: u'new tag: Arkada\u015flar\u0131n' isinstance(instance.name, unicode), isinstance(str, unicode) and isinstance(msg, unicode) all return True. Thanks... On 3 Kasım, 14:04, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sat, 2007-11-03 at 07:01 -0500, James Bennett wrote: > > On 11/3/07, omat <[EMAIL PROTECTED]> wrote: > > > sbj = u'new tag: %s' % (instance.name) > > > You might want to read this: > > >http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsT... > > > There's a warning about using this style of string interpolation under > > Python 2.3 which may be relevant to your situation. > > That shouldn't be an issue here. The instance.name attribute will > (should, at least) be a normal Python unicode string. > > Malcolm > > -- > Remember that you are unique. Just like everyone > else.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Newforms validation error not displayed:
Validation checks the number entered by the user is between the range and this check is done in "def clean_guess_the_number". This is not working. Seems like "def clean_guess_the_number(self)" never executed when you post the data and when form.is_valid() called. class GuessForm(forms.Form): guess_the_number= forms.RegexField(r'^\d+$', max_length = 10, min_length = 1, error_message = 'Must be 1-10 numeric characters.' ) def __init__(self, *args, **kwargs): try: self.id = kwargs.pop('id') except: pass super(GuessForm, self).__init__(*args, **kwargs) number = get_object_or_404(Number, pk=self.id ) increment = Increment.objects.all() self.max_number = number.value + increment[0].value self.min_number = number.value + increment[1].value def clean_guess_the_number(self): if self.max_number > self.cleaned_data['guess_the_number']: raise forms.ValidationError('Your Number have to be lower or equal to Max Number.') if self.min_number < self.cleaned_data['guess_the_number']: raise forms.ValidationError('Your Number have to be higer or equal to Min Number.') return self.cleaned_data['guess_the_number'] html: Guess The Number( Number must be between {{form.min_number}} and {{form.max_number}}): {{ form.guess_the_number }} {% if form.guess_the_number.errors %}*** {{ form.guess_the_number.errors|join:", " }}{% endif %} --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
On Sat, 2007-11-03 at 07:01 -0500, James Bennett wrote: > On 11/3/07, omat <[EMAIL PROTECTED]> wrote: > > sbj = u'new tag: %s' % (instance.name) > > You might want to read this: > > http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsTheQuickChecklist > > There's a warning about using this style of string interpolation under > Python 2.3 which may be relevant to your situation. That shouldn't be an issue here. The instance.name attribute will (should, at least) be a normal Python unicode string. Malcolm -- Remember that you are unique. Just like everyone else. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
On Sat, 2007-11-03 at 11:41 +, omat wrote: > Hi All, > > I have a function that sends mail to managers every time a new tag is > created, connected to post_save of a Tag model via dispatcher. > > def mail_new_tag(instance): > t = loader.get_template('app/new_tag_email.txt') > c = Context({'tag': instance}) > msg = t.render(c) > sbj = u'new tag: %s' % (instance.name) > mail_managers(subject=sbj, message=msg) > > This works fine when the instance.name is all ascii, but when it > contains non-ascii characters, a UnicodeDecodeError is raised. > > When debugging, I see that instance.name is a unicode object, but, > "sbj" cannot be rendered. Where is it raising the exception? Which line of code in particular. You should be able to pass Unicode objects to the mail code (in fact, in [1], I do just that for pretty much all the fields -- that was generated using Django's email code). Reading the code, I can't see anything special about mail_managers() that would cause problems. So if you can past the full traceback that will probably help work out what might be going on. Also, what is repr(sbj) just before you call mail_managers()? [1] http://www.flickr.com/photos/malcolmtredinnick/503502258/ Regards, Malcolm -- The early bird may get the worm, but the second mouse gets the cheese. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: encoding problem in instance signal / dispatcher?
On 11/3/07, omat <[EMAIL PROTECTED]> wrote: > sbj = u'new tag: %s' % (instance.name) You might want to read this: http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsTheQuickChecklist There's a warning about using this style of string interpolation under Python 2.3 which may be relevant to your situation. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
encoding problem in instance signal / dispatcher?
Hi All, I have a function that sends mail to managers every time a new tag is created, connected to post_save of a Tag model via dispatcher. def mail_new_tag(instance): t = loader.get_template('app/new_tag_email.txt') c = Context({'tag': instance}) msg = t.render(c) sbj = u'new tag: %s' % (instance.name) mail_managers(subject=sbj, message=msg) This works fine when the instance.name is all ascii, but when it contains non-ascii characters, a UnicodeDecodeError is raised. When debugging, I see that instance.name is a unicode object, but, "sbj" cannot be rendered. Thanks for any help, oMat --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: how to select current user's object in the forms.py,thanks!
On Sat, 2007-11-03 at 03:55 -0700, [EMAIL PROTECTED] wrote: > i want to filter some object related to current logined user in > forms.py, the key code is: > choices = [(str(x.id), x.name) for x in > Category.objects.filter(user__id__exact=request.user.id)] > > but i got this error: > Exception Type: NameError > Exception Value: global name 'request' is not defined > Exception Location: d:\django\mysite\blog\forms.py in __init__, line > 16 > > my question is how to select current user's object in the > forms.py,thanks! You are only going to have access to 'request' inside your view function and it is a local variable at that point. So you could create a method on your CreateEntryForm class that took 'request' as an argument and set up the category choices. Then something like this would work in your view: def my_view(request, ): form = CreateEntryForm() form.setup_choices(request) ... Alternatively, you could do some fancy juggling of kwargs in CreateEntryForm.__init__ so that you can pass 'request' into the __init__ method (pop the 'request' keyword argument from **kwargs before passing it up to the super's __init__ method. Regards, Malcolm > > full code as below: > > class CreateEntryForm(forms.Form): > def __init__( self, *args, **kwargs ): >super( CreateEntryForm, self ).__init__( *args, **kwargs ) >self.fields['category'] = forms.ChoiceField( > choices = [(str(x.id), x.name) for x in > Category.objects.filter(user__id__exact=request.user.id)] > ) > > > category = forms.CharField(max_length=80, label=_('Category')) > title = forms.CharField(max_length=80, label=_('Title')) > > > > > -- Everything is _not_ based on faith... take my word for it. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
how to select current user's object in the forms.py,thanks!
i want to filter some object related to current logined user in forms.py, the key code is: choices = [(str(x.id), x.name) for x in Category.objects.filter(user__id__exact=request.user.id)] but i got this error: Exception Type: NameError Exception Value:global name 'request' is not defined Exception Location: d:\django\mysite\blog\forms.py in __init__, line 16 my question is how to select current user's object in the forms.py,thanks! full code as below: class CreateEntryForm(forms.Form): def __init__( self, *args, **kwargs ): super( CreateEntryForm, self ).__init__( *args, **kwargs ) self.fields['category'] = forms.ChoiceField( choices = [(str(x.id), x.name) for x in Category.objects.filter(user__id__exact=request.user.id)] ) category = forms.CharField(max_length=80, label=_('Category')) title = forms.CharField(max_length=80, label=_('Title')) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there a simpler solution?
RajeshD wrote: > > On Nov 2, 4:05 pm, "Ramdas S" <[EMAIL PROTECTED]> wrote: > >> Hi, >> >> I am sure there is something absolutely simple, but I guess I am missing it. >> I need to display some content/ news articles over 3 columns on a home page, >> where the order is latest stories coming in top rows from left to right. If >> you've seen web sites like theinquirer.net or theregister.co.uk you will >> understand what I mean! >> >> I was searching for a solution that is a lot simple, like a template tag >> which will let me implement this easily. But I have not found one. >> > > Have you considered using plain CSS floating boxes? > > Here's some hastily put together snippet: > > Your template: > -- > > {% for a in articles %} > > render article a here > > {% if forloop.counter1|divisibleby:"3" %} > > {% endif %} > {% endfor %} > > Your CSS: > -- > > .article {width:32%;float:left;overflow:hidden;} > .clear_all {clear:both;} > > Experiment further to make things look nicer from here ;) > > -Rajesh D > I'd change "clear_all" to "clear-all" if I was you. I've had trouble with some older versions of Netscape choking on underscores. Cheers, Dean --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is there a simpler solution?
Thanks, I shall try this Ramdas On 11/3/07, RajeshD <[EMAIL PROTECTED]> wrote: > > > Disregard the overflow:hidden piece in my CSS above. It's not needed: > > > .article {width:32%;float:left;} > .clear_all {clear:both;} > > > > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Design Contest by NASA...
Hi, Please click the link to find the concept for Earthquake resistant building... http://www.createthefuturecontest.com/pages/view/entriesdetail.html?entryID=533 Thanks Anand --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---