Re: migrate does not store default values in the database

2014-10-24 Thread Jon Dufresne
On Fri, Oct 24, 2014 at 3:24 PM, Peter Coles wrote: > I'm trying out the migrations in Django 1.7 and I was surprised when my > migrations did not set default values in the database. Can someone share the > motivation for this functionality? (more details below) > > This was surprising given the d

Re: Is there a way to supress blank lines in the HTML?

2014-10-24 Thread Jon Dufresne
Try adding "import re" to the top to import the Python re module. On Fri, Oct 24, 2014 at 8:35 AM, Daniel Grace wrote: > Thanks people for the info. I was looking for a way to beautify the code, > rather than for performance / compression. In partic

Re: Is there a way to supress blank lines in the HTML?

2014-10-24 Thread Jon Dufresne
> If you need this for some performance reasons like html compression, you are > doing it wrong. > Instead you could use server-side GZIP compression when serving html which > will do the job much more efficiently. Just a heads up. Compressing dynamic responses over HTTPS is considered insecure

Re: Restricting file access to users who uploaded the file.

2014-10-21 Thread Jon Dufresne
On Tue, Oct 21, 2014 at 7:09 AM, Ben Lopatin wrote: > Presuming you're working with Nginx or > Apache and local files, you can use X-Accel-Redirects or X-Sendfile to do > this. Basically the request for a file is made to your Django app, e.g. > /files/some-file-name.doc, and the app checks if the

Re: File Storage API: save file to DB model and disk: separate disk path from file name

2014-10-17 Thread Jon Dufresne
On Fri, Oct 17, 2014 at 4:45 PM, Russell Keith-Magee wrote: > Achievable? probably. Easy? No. You're going to be digging in the weeds on > this one. > > If I were trying to do this, I wouldn't try and get this to work with the > existing FileField - I'd be writing my own Field definition. You can

File Storage API: save file to DB model and disk: separate disk path from file name

2014-10-17 Thread Jon Dufresne
Hi, I'm trying to use the File Storage API to create a custom handler for files. Here are my goals: Stored files are represented both in the database and on disk with the following model: class StoredFile(models.Model): name = models.CharField(max_length=255) path = models.CharField(max_

Nesting custom template tags

2014-03-29 Thread Jon Dufresne
Hi, I am trying to create a custom template tag that generates a repetitive HTML snippet. This tag is an anchor tag "a" with extra classes and styles, plus some logic to apply additional classes and styles. I want the syntax in the template to look something like: {% my_anchor URL %}this is te

Re: Model field's verbose_name from database?

2014-02-05 Thread Jon Dufresne
> Why not use dictionary to Map user-level names to database-fields I'm not sure I fully follow what you're suggesting. But it sounds like you're suggesting I move the configuration of field name out of the database and into a Python file using a dictionary to map actual fields to preferred field

Model field's verbose_name from database?

2014-02-04 Thread Jon Dufresne
Hi, I have a model with fields that allows the user to modify the user-facing names of these fields. Think "first name", "last name", "email", the user may prefer these be displayed as "given name", "surname", "email address". This is configured exactly once throughout the system. So in this examp

Re: Spammed with 'Invalid HTTP_HOST header' messages

2013-12-06 Thread Jon Dufresne
> Can you not add a filter to your logger handler? > http://stackoverflow.com/a/19534738 I will give this a shot. But what I don't understand is that the post claims that this is fixed in newer versions. I am using version 1.6. By "fixed" does he simply mean 500 error is now a 400 error? Or is h

Re: Spammed with 'Invalid HTTP_HOST header' messages

2013-12-06 Thread Jon Dufresne
On Fri, Dec 6, 2013 at 7:47 AM, Zach Borboa wrote: > SuspiciousOperation should now return a 400 error [1]. It is true, the response is a 400 Bad Request error, but I still receive emails going to my admins/managers email account. I thought 400 errors shouldn't be mailed out. I would prefer to av

Spammed with 'Invalid HTTP_HOST header' messages

2013-12-05 Thread Jon Dufresne
I am running Django 1.6. I receive a lot of false positive errors from my Django application when accessed with an invalid HTTP_HOST. I have verified that these are in fact HTTP_HOST values that I am not interested in. So I *do* want to return an error to the user. However, it doesn't help me as a

Re: Apache environment variables in Django 1.6

2013-11-22 Thread Jon Dufresne
> With you setup is it possible to run into some race conditions when two > simultaneous request coming for the first time when _application is still > uninitialized? That is a good question, to which I do not have a good answer. If you come across any issues with this solution I'd be interested

Re: Apache environment variables in Django 1.6

2013-11-21 Thread Jon Dufresne
On Thu, Nov 21, 2013 at 8:46 AM, Mike Starov wrote: > I encountered same issue in my deployment. Have you found a solution? > Yes I did. I am still not sure if this is a bug or intentional. It appears that in 1.6, settings.py is now imported *before* the first run of the WSGI application. Therefo

Apache environment variables in Django 1.6

2013-11-20 Thread Jon Dufresne
Hi, I recently upgraded my Django application from 1.5 to 1.6. This application runs on Apache with mod_wsgi. After upgrading, Django seems unable to access environment variables set by Apache using SetEnv and SetEnvIf. Using Django 1.5 I was able to access this using the following recipe in wsgi.

Logging warnings inside settings.py

2013-11-01 Thread Jon Dufresne
Hi, I am trying to log warnings inside settings.py. I want to log warnings when settings (from an outside source) are not provided, but the application can continue. Is this possible? It seems like this might not work as logging requires settings.py in order to be configured, but I want to log ear

ModelMultipleChoiceField ignore invalid choices?

2013-10-07 Thread Jon Dufresne
Hi, I am using a ModelForm with a ModelMultipleChoiceField. I would like for this field to silently ignore invalid choices instead of creating a form error. Here is my use case: * User A opens form select model choice 1, 2, and 3 * User B (different browser) deletes model choice 3 entirely from s

Advice on deploying multiple Django instances to single Apache server

2013-08-23 Thread Jon Dufresne
Hi, I am getting ready to deploy my Django application. This application must serve several independent parties. In the past, I've done this with multiple instances of a PHP application on the server. Is this the right approach in the Django world? My server is running Apache and MySQL. Each inst

Adding custom WHERE conditions to query sets (MySQL user defined functions)

2013-08-20 Thread Jon Dufresne
Hi, My Django application was ported from a legacy application. This legacy application has some MySQL user defined functions that are frequently used in the WHERE clause of queries. Is it possible to use these stored functions and still return query sets? I want to do something like MyModel.obje

Re: Importing project URLs without a database

2013-08-01 Thread Jon Dufresne
On Thu, Aug 1, 2013 at 2:38 PM, Phil wrote: > Could you post the entire content of your script? There is no way those 2 > lines (and the necessary "os" import) can cause this error. > > > You are right. I investigated much deeper. Turns out this is what I did. 1. Script imported root URL conf 2.

Importing project URLs without a database

2013-08-01 Thread Jon Dufresne
Hi, I am trying to write a script that outputs information about all URLs in the project. The script should be able to do this without having a database populated or even created. Right now the script gets to the following line: os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")

Forms with fields created dynamically client side

2013-07-26 Thread Jon Dufresne
Hi, I am creating a form for the user to add, edit, and remove all tags in the database. The tag models are handled by taggit. The form will look like like _Tag1_[del] _Tag2_[del] __<--- User enters next tag here [add tag] Clicking add tag will fire some javascript to add a new

Re: Every view requires authentication

2013-07-18 Thread Jon Dufresne
On Thu, Jul 18, 2013 at 1:36 AM, Tom Evans wrote: > On Thu, Jul 18, 2013 at 1:11 AM, Jon Dufresne > wrote: > > Oh, I see what you're saying. The login_required does not need to be > added > > explicitly, because it is added implicitly by the authorization check. >

Re: Every view requires authentication

2013-07-17 Thread Jon Dufresne
On Wed, Jul 17, 2013 at 4:24 PM, Arnold Krille wrote: > Still interesting that you need authentication while not needing any > authorization... Oh, I see what you're saying. The login_required does not need to be added explicitly, because it is added implicitly by the authorization check. Yeah

Re: Every view requires authentication

2013-07-17 Thread Jon Dufresne
On Wed, Jul 17, 2013 at 1:25 PM, Arnold Krille wrote: > On Wed, 17 Jul 2013 11:22:36 -0700 Jon Dufresne > wrote:The standard-way depende on your views: > - If its function-based views, use the @login_required-decorator. > - For class-based views we use the LoginRequiredMixin from

Every view requires authentication

2013-07-17 Thread Jon Dufresne
My application requires an authenticated user for every view (with very few exceptions). Is there a standard correct way to handle this or should I roll my own middleware? I'm probably not the first have this requirement. -- You received this message because you are subscribed to the Google Group

Re: or-ing to QuerySets turns INNER into LEFT OUTER joins?

2013-07-16 Thread Jon Dufresne
I too would be interested to know if there is a solution. A LEFT OUTER JOIN can really hurt performance when an INNER JOIN are more appropriate,. On Mon, Jul 15, 2013 at 8:41 AM, Carsten Fuchs wrote: > Hi all, > > we have two queries/QuerySets Q_a and Q_b, each of which use INNER joins > in the

Re: [slightly offtopic] Which Python are people using on OSX?

2009-02-05 Thread Jon Dufresne
On Thu, Feb 5, 2009 at 1:07 PM, cjl wrote: > 1. Use the stock Python, slightly outdated 2.5.1, with weird and > incomplete modules. > 2. Compile Python myself from source. > 3. Use MacPorts Python. Anyone know why the nearly all of Xorg gets > built as a dependency? > 4. Use the macpython .dmg >