Storages API modified_time() and timezones.

2013-10-18 Thread Ian Lewis
Hi, I'm trying to get a handle on the modified_time() method in the Storages API. I couldn't find any hints in the doc as to what the right way to implement the modified_time() method was in regard to timezones. Currently it looks like the default FileSystemStorage backend returns the modified tim

PyCon APAC CFP

2013-07-03 Thread Ian Lewis
Hey Django users! I wanted to get the word out that we are accepting talks for this year's PyCon APAC in Tokyo Japan. If you have ever wanted to visit Tokyo and you have a Python topic you are passionate about then this is your chance! The conference is formatted into 4 tracks, 2 Japanese and 2 E

Re: internal server error not sending message notification

2013-05-04 Thread Ian Lewis
Hi, Did you set your LOGGING configuration in your settings.py? If you happened to upgrade to Django 1.5 then the default LOGGING configuration went away and it will no longer sent emails to the admins without some configuration. This is described at the following url where it says "Prior to Djang

django-ical - iCalendar generation

2012-05-06 Thread Ian Lewis
Hey all, I just released a simple library for generating iCalendar feeds based on the syndication framework. For folks familiar with the syndication framework and how it works you should be able to get up and running with django-ical pretty quickly. Most people seem to be doing iCalendar feeds and

Re: Storing many to many fields

2012-03-18 Thread Ian Lewis
Hi, facebook_session.books_name is a RelatedManager on the Books model class. You need to add books to the list with the add() method. book = Books(book_name="name", book_category="category") book.save() facebook_session.books_name.add(book) See: https://docs.djangoproject.com/en/1.3/ref/models

Using the same storage backend for media and static files.

2011-11-05 Thread Ian Lewis
Hi, I'm a developer for django-storages who maintains the AWS S3 boto backend. I get a lot of requests and questions about how to use s3boto as a backend for both media and for the staticfiles contrib app but with different settings. The issue is that the storage backends are created without any

Re: Django form(s) for intermediary models

2011-01-26 Thread Ian Lewis
Hi, What you want to do here is use a Django "Formset" which contains your ModelForms. Since you want to show one form per person regardless of whether they are a member or not we can't use the modelformset_factory() and will have to do some manipulation of the initial data using the formset_facto

Re: Django 1.3 alpha 1 released

2010-11-11 Thread Ian Lewis
2010/11/12 Ɓukasz Rekucki > On 12 November 2010 01:16, hcarvalhoalves > wrote: > > What about having an official 1.3 feedback thread at django-developers > > list? ;) > > > > I'm liking the pack of small improvements coming in this release, and > > timing is very good, well done. I must say I'm

Re: Django Registration password reset problem

2010-10-06 Thread Ian Lewis
I just took a cursory look at this but did you make sure to add something like the following to your urlpatterns in urls.py? urlpatterns=patterns('', ... (r'^accounts/', include('django.contrib.auth.urls')), ... ) On Thu, Oct 7, 2010 at 1:29 AM, Joel Klabo wrote: > So now I am redire

Re: Separating application media from project media

2010-10-01 Thread Ian Lewis
> FWIW, even for a more canonical "integrated" website / webapp composed > of distinct django apps, "assets" (app specific css, js, images and > whatnot) management can sometimes be a pain. My own solution so far is > to keep all app-specific static stuff in a /medias/ subir of > the app and manual

Re: How to debug ORM filter stacking?

2010-09-25 Thread Ian Lewis
Are you sure you are saving the new QuerySet that gets created by the filter? I'm guessing you are doing something like: qs = MyModel.objects.filter(field1="somevalue") if condition: qs.filter("someothervalue") What you need to do is save the value of the second filter() call. qs = MyModel.o

Re: Django 1.3

2010-08-16 Thread Ian Lewis
Kenneth, >From my experience, South works well with mysql. However because sqlite doesn't provide support for some schema alterations such as dropping columns, it is as you said, pretty touchy. Ian On Mon, Aug 16, 2010 at 2:52 PM, Kenneth Gonsalves wrote: > On Mon, 2010-08-16 at 10:28 +1000, La

Re: create table

2010-07-19 Thread Ian Lewis
Hi, On Tue, Jul 20, 2010 at 11:42 AM, pengbo xue wrote: > how can I create tables and foreignkey as below information. > > create a user object "models.User" and include kewords like this, > > username: modify the max_length of username to 32,default is 30. > email: > password: > is_staff: fals

Re: How to pass a raw ORDER_BY command or function call to a results query object?

2010-06-17 Thread Ian Lewis
In this case you want to use extra(). Assuming jobs is a QuerySet or Manager instance: jobs = jobs.extra(select={greatest_time': 'GREATEST(startTime, queueTime)'}) jobs = jobs.extra(order_by=['-greatest_time']) On Thursday, June 17, 2010, Kyle wrote: > Without any filtering, I can execute the fo

Re: Custom Form in a ModelFormset_Factory?

2010-05-18 Thread Ian Lewis
o any documentation that indicates > this (and other features) is an option? > > On May 18, 1:10 am, Ian Lewis wrote: >> Pass the form class to modelformset_factory() in the form argument. >> The factory will then use the AuthorForm class as the base form class >>

Re: Challenge with Annotate

2010-05-18 Thread Ian Lewis
27;)) ... Would that get you the group by and average field you were looking for? If not it might be easier to just write what you want as custom SQL. Ian On Tue, May 18, 2010 at 10:51 PM, Roland van Laar wrote: > On 05/18/2010 03:43 PM, Ian Lewis wrote: >> Roland, >> >&g

Re: Challenge with Annotate

2010-05-18 Thread Ian Lewis
Roland, Instead of using annotate, could you just add the avg_days_instock field as another key in the select argument to extra? Ian On Tue, May 18, 2010 at 9:03 PM, Roland van Laar wrote: > Hello, > > Question: How do I calculate the Average of a calculated field. > > My (simplified) models.py

Re: Extend User

2010-05-18 Thread Ian Lewis
If you don't need the name, surname etc. then don't use them. They are optional fields. You can also implement a custom form or view when the user registers that can make sure the email has not been previously registered. If you need to add additional fields then you should create a custom profile

Re: Error was: cannot import name validators

2010-05-18 Thread Ian Lewis
validators is a module that was added in Django 1.2. You probably have the wrong version of Django installed or are using Django 1.1 with a django application that requires Django 1.2. On Tue, May 18, 2010 at 6:01 PM, Pankaj Singh wrote: > pan...@pankaj-laptop:~/django_projects/pankaj$ python >

Re: Custom Form in a ModelFormset_Factory?

2010-05-18 Thread Ian Lewis
Pass the form class to modelformset_factory() in the form argument. The factory will then use the AuthorForm class as the base form class when it creates the modelform class for the formset. modelFormset = modelformset_factory(Author, form=AuthorForm) On Tue, May 18, 2010 at 7:08 AM, Michael Davi

Re: Retrieving an ID from a posted form

2010-04-22 Thread Ian Lewis
Nick, Because you won't get an id for your newly created object before you save it you'll need to send the email after you save the form. I'm assuming that ArtistFormFinal is a ModelForm but you can get the id using something like the following: myobj = form.save() send_mail(subject, "Your id is

Re: Getting error in Cloudwatch EC2 BOTO

2010-04-14 Thread Ian Lewis
Nitin, You will need to provide more information about the error you are getting and in what circumstances it is occurring if you would like someone to help you. Ian On Thu, Apr 15, 2010 at 2:10 PM, nitin shrimali wrote: > Hello guys > I am having error when performing Cloudwatch in Django. But

Re: save_model admin

2010-04-13 Thread Ian Lewis
If you are talking about Django's admin couldn't you implement it by overriding save_model as your subject seems to suggest? http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

Re: many to many based upon common field

2010-04-13 Thread Ian Lewis
wizard, Would it make sense to use the intermediate table to hold the field? Using the stack overflow example: class Edi856(models.Model): pass class Order(models.Model): edi = models.ManyToManyField(Edi856, through='PoNum') def in_edi(self): '''Has the edi been processed?''

Re: CSRF and Caching

2010-04-13 Thread Ian Lewis
There is the possibility that the token could be cached in html if you are using the cache template tag. Otherwise the token shouldn't be cached. On Wed, Apr 14, 2010 at 3:31 AM, scoopseven wrote: > Is there any possibility that CSRF tokens could be cached by memcache > causing chaos on a django

Re: urllib2: post request to a django form

2010-04-13 Thread Ian Lewis
Try running the server locally using the devserver and posting to it. You can invoke python's debugger when the post is recieved on the server side by adding some code like the following: import pdb;pdb.set_trace() On Wed, Apr 14, 2010 at 7:30 AM, bfrederi wrote: > I'm attempting to re-route us

Re: Override Delete Function

2010-04-12 Thread Ian Lewis
Tom, You could try doing this clear logic in a pre_delete signal. You might have to test out the timing of when the signals get called but it should call pre_delete for all deleted models. In this case it would call pre_delete on model2 before model1 but you should be able to get what you are look

Re: Django Newbie seeking for advice

2010-04-12 Thread Ian Lewis
Mr. Yu, On Tue, Apr 13, 2010 at 9:56 AM, Mister Yu wrote: > > 1. can you suggest an up-to-date(django 1.1) book which can guide a > newbie to a higher level? ebook is ok, free is more than ok :) > I think the semi-official Django book is where most people start. It's available online and curre

Re: Serving https with runserver

2010-03-01 Thread Ian Lewis
I can think of a number of reasons why you would want to test SSL behavior on your local machine before running it on a production server. Setup can be pretty annoying for one. I wrote a blog post on how to do this very thing a while back. I used stunnel, as Janusz mentioned, to test SSL redirect

Re: Set language on per page basis

2010-02-25 Thread Ian Lewis
BTW: django-cms does something similar to what you are trying to do. You can check out it's implementation here: http://github.com/digi604/django-cms-2.0/blob/master/cms/middleware/multilingual.py 2010/2/25 Ian Lewis : > In process_request you have access to the request object which kno

Re: Set language on per page basis

2010-02-25 Thread Ian Lewis
In process_request you have access to the request object which knows the current path (request.path). You can use that to determine which language to show the page in. Or if you are determining the language based on a url parameter you can look at request.GET Ian On Thu, Feb 25, 2010 at 8:24 AM,

Re: NoReverseMatch:

2010-01-16 Thread Ian Lewis
Bhaskar, The error means that there is either no defined URL called 'tellfriend' or it requires some kind of argument, like a user id, to generate the URL. Having two separate forms with different actions is no problem. Fixing the URL reversing should clear up your issue. Ian On Sunday, Janua

Re: form with loop over fields?

2009-11-11 Thread Ian Lewis
andraeas, You can define a choice field that takes a callable as it's choices. That way you could use the current year and loop over the subsequent years to create the list you need. Just return a two tuple that can be used as the choices for a normal field in your function. class LazyChoiceFiel

Smipple - Social Code Snippets

2009-06-28 Thread Ian Lewis
Hi all, I just wanted to let everyone know about a site I created for sharing code snippets in a social way. You can check it out at http://www.smipple.net/. Smipple allows you to save, organize, and share snippets with others easily. The best part though is that you can follow other people who ha

Re: Odd ModelForm problem

2009-06-24 Thread Ian Lewis
I'm not sure why it might work on one server but not on another unless the version of Django was different but as far as I know form.slug is not really guaranteed to exist. Normally it gets added to form.fields or somesuch by the forms metaclass. The actual data from the post request should also n

Re: Processing multiple forms on one page

2009-06-24 Thread Ian Lewis
Oleg, You can set a parameter in your post request that allows you to differentiate between the two POST requests. But a more clean approach would be to just have the different forms POST to different urls(views) and the redirect back to the profile page if there is an error or do whatever. Ian

Re: Amazon S3 for File Uploads

2009-06-12 Thread Ian Lewis
Max, Just from glancing over the options you have below none of them looked particularly good to me. The first is only a file field so depending on what you are doing it may not work for you. The second seemed reasonable but has no options for setting things like http headers for files or more adv

Re: Question about ForeignKeys and subclasses

2009-06-03 Thread Ian Lewis
Rex, My appologies. Though the feature is in 1.0 I gave a link to the 1.1 documentation. Django 1.0 docs: http://docs.djangoproject.com/en/1.0/topics/db/models/#id7 2009/6/3 Ian Lewis > Rex, > > Django parent model instances will also have a property equal to the > lowercase

Re: comments error

2009-06-03 Thread Ian Lewis
Looks like the next parameter doesn't really work though. See: http://groups.google.com/group/django-users/browse_thread/thread/109763039cef5c3d/470d678e46d7dfe0?hl=en&lnk=gst And: http://code.djangoproject.com/ticket/8968 2009/6/3 Ian Lewis > Iperk, > > Is this perhaps wh

Re: comments error

2009-06-03 Thread Ian Lewis
Iperk, Is this perhaps what you are looking for? http://docs.djangoproject.com/en/dev/ref/contrib/comments/#redirecting-after-the-comment-post On Mon, Jun 1, 2009 at 6:38 AM, lperk wrote: > > Does someone know how to redirect posted comment to another page if > you have your own form for sendi

Re: Question about ForeignKeys and subclasses

2009-06-03 Thread Ian Lewis
Rex, Django parent model instances will also have a property equal to the lowercase name of the subclass. So for Animal instances that happen to be a Duck you can do something like "my_room.animal.duck" to get the Duck instance. Depending on what you are doing you might want to try that. It's reas

Storage API and Uploading to http based storage

2009-05-21 Thread Ian Lewis
I have run into an issue and was wondering how I might be able to solve it in the best way: For storage backends that are http based some (such as S3) require that you submit a Content-Length header upfront. This is not necessarily a problem for the save method which takes a file like object sinc

UploadHandlers and the Storage API

2009-05-21 Thread Ian Lewis
Hi all, I am currently using an implementation of the django.files.storage API to read/write files from Amazon S3 using the django storage API. This has worked well except for in cases where one wants to read from one stream and write to the storage API. One case I am running into is that I would

Re: Changing default app url in development server

2009-02-03 Thread Ian Lewis
What are you trying to do? If your development appserver is conflicting with a locally installed apache then why not just use a different port? python manage.py runserver 8001 2009/2/4 knight > > Hi, > > My question is: > > Is there a way to change my default app url in development server > fro

Re: Bug? Related manager not working for custom manager?

2008-11-19 Thread Ian Lewis
John, Try checking the log output of the database server to see what is different about the SQL. Perhaps some kind of caching is going on where the manager is caching the results of it's queries? On Thu, Nov 20, 2008 at 11:21 AM, John M <[EMAIL PROTECTED]> wrote: > > I have a model with a custom

Re: MySQL deadlocking issues

2008-11-18 Thread Ian Lewis
ick <[EMAIL PROTECTED]> > wrote: >> On Wed, 2008-11-19 at 10:21 +0900, Ian Lewis wrote: >> > I've run into the following error in a SQL DB envornment and was >> > wondering if any one else had run into problems with Deadlocking with >> > MySQL. Wh

MySQL deadlocking issues

2008-11-18 Thread Ian Lewis
I've run into the following error in a SQL DB envornment and was wondering if any one else had run into problems with Deadlocking with MySQL. What would be the proper way to handle this kind of error in Django? Do most folks simply catch the OperationalError and show some sort of error to the use