How to do 2-ModelForm-in-1-CVB right?

2013-09-25 Thread Adam
Hi,

I am trying to handle 2 ModelForm in 1 view. Is that possible with CBV 
solution? Does any best practise exist?

Here is the problem in details.

## models.py

class UserProfile(HasJPAddresses, models.Model):

user = models.OneToOneField(User)
birthdate = models.DateField(default='1900-01-01')

## forms.py

class UserProfileUpdateForm(forms.ModelForm):
class Meta:
model = UserProfile

class UserUpdateForm(forms.ModelForm):
class Meta:
model = User
fields = ['first_name', 'last_name']

## views.py

class UserProfileUpdateView(FormView): <<< How could I handle two 
forms at once in a view? 

Thanks,
/Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Restrict access to user-uploaded files to authorized users

2013-09-25 Thread m1chael
I think Xsendfile is what you want


On Wed, Sep 25, 2013 at 12:51 PM, Mattias Linnap  wrote:

> > Are there any obvious solutions that I have over looked?  Or am I stuck
> having to use django to serve the files?
>
> Depending on the security that you aim to achieve, one option would be to
> add a custom file storage implementation that overrides
> https://github.com/django/django/blob/master/django/core/files/storage.py#L63to
>  give all uploads randomly generated filenames - and therefore
> unguessable URLs. In addition, Apache can be configured to redirect any
> accesses to non-existing files in the media directory to a login page.
>
> Only the original uploading user would know the URL, and be able to access
> the file. However, this approach would still allow the user to share a
> direct link to the file to other people.
>
> Mattias
>
>
>
> On Tue, Sep 24, 2013 at 9:53 PM, J Y  wrote:
>
>> I am buliding a tool that needs to have the ability to allow user to
>> upload a file, and the file should only be accessible by the user who
>> uploaded it.  It seems that the MEDIA_ROOT directory must be placed in the
>> public www directory for front end web servers Apache to serve the file,
>> which currently does not restrict access to any of the uploaded files.
>>  What I am looking for is a way that I can lock it down so that if they try
>> to access the file directly, I would bring up a login screen and they must
>> authenticate before I give them access to it.
>>
>> I did some searching around, and found various solutions to the problem,
>> but none of them sounds like it would work for me.  My requirements are:
>>
>> 1. My front-end web server must be Apache
>> 2. Apache setup and config cannot be changed to accommodate my site alone
>> (unless it's a config I can easily override in .htaccess)
>> 3. Users should not have to log in twice (If they authenticated against
>> django already, no reason to ask them to login to Apache again)
>> 3. Use django to serve the files as a last resort
>>
>> Here are some of the solutions I found:
>>
>> 1. Update nginx/apache config to hook into django's user's database.
>>  This looks like it would ask the user to login again via Apache's login
>> mechanism, plus it doesn't look like it would work with alternative
>> authentication backend (I am using django-auth-ldap)
>> 2. Use django-sendfile, not possible because it requires installing
>> plugins to Apache
>> 3. Serve files through django.  Not recommended by django, so I am loath
>> to try it
>> 4. Override the MEDIA_ROOT behavior in urls.py and implement my own file
>> serving behavior.  This sounds not all that far off from #3.
>>
>> Are there any obvious solutions that I have over looked?  Or am I stuck
>> having to use django to serve the files?
>>
>> Thanks for any advice,
>>
>> Jack
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-09-25 Thread Cal Leeming [Simplicity Media Ltd]
+1 for virtualenvwrapper, don't know how I survived without this!!

Cal


On Wed, Sep 25, 2013 at 9:59 PM, Roberto López López
wrote:

>
> Check virtualenvwrapper
>
> http://virtualenvwrapper.readthedocs.org/en/latest/
>
>
>
>
> On 09/25/2013 08:06 PM, Jorge Arevalo wrote:
>
> Fine. I don't think my boss is going to pay for PyCharm license, so I'll
> probably go for Eclipse now (I don't really like it too much, but if works,
> it's ok for me)
>
>  About virtualenv, is there any method to provide something like a script
> to create a virtualenv, install the needed software and have a working
> environment in a few commands? Something like "vagrantfile for virtualenv"
> http://docs.vagrantup.com/v2/vagrantfile/index.html
>
>  Again, many thanks for your useful insights
>
> On Tuesday, September 17, 2013 4:29:14 PM UTC+2, Vernon D. Cole wrote:
>>
>>  Answering the other half of your question:  The choice of IDE is not
>> nearly as important as its ease of integration with your dvcs.  If you are
>> already familiar with a good one, don't change.
>>
>> On my present project, my boss and I are both using PyCharm, and my other
>> co-worker is using Eclipse, since he is more comfortable (and therefore,
>> more productive) with it. Both IDE's have good integration with git (my
>> least favourite dvcs, but the boss's choice) and our sharing is done using
>> a group private repository on github.  This is on Ubuntu Linux, it all
>> works well.   In the evening hours, I use PyCharm on Windows 7 to
>> contribute to an open source project hosted on bitbucket using mercurial.
>> Both projects end up being tested on the same Linode.
>>
>> Yes, use virtualenv.  I also made the mistake of thinking of it as a
>> virtual computer.  It is not.  It is only a method of separating Python
>> library directories so that you can experiment with different
>> configurations easily.  It does not slow anything down, and actually makes
>> installation of packages easier.  Use virtualenvwrapper to make switching
>> environments easy.  PyCharm also supports virtual environments as well as
>> django projects. It is commercial, and suffers from a few Java
>> idiosyncrasies, but the boss paid for the license ;-) so I don't mind.
>>
>>--
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
>
> Roberto López López
> System Developer
> Parallab, Uni Computing+47 55584091
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-09-25 Thread Roberto López López

Check virtualenvwrapper

http://virtualenvwrapper.readthedocs.org/en/latest/



On 09/25/2013 08:06 PM, Jorge Arevalo wrote:
> Fine. I don't think my boss is going to pay for PyCharm license, so
> I'll probably go for Eclipse now (I don't really like it too much, but
> if works, it's ok for me)
>
> About virtualenv, is there any method to provide something like a
> script to create a virtualenv, install the needed software and have a
> working environment in a few commands? Something like "vagrantfile for
> virtualenv" http://docs.vagrantup.com/v2/vagrantfile/index.html
>
> Again, many thanks for your useful insights
>
> On Tuesday, September 17, 2013 4:29:14 PM UTC+2, Vernon D. Cole wrote:
>
> Answering the other half of your question:  The choice of IDE is
> not nearly as important as its ease of integration with your
> dvcs.  If you are already familiar with a good one, don't change.
>
> On my present project, my boss and I are both using PyCharm, and
> my other co-worker is using Eclipse, since he is more comfortable
> (and therefore, more productive) with it. Both IDE's have good
> integration with git (my least favourite dvcs, but the boss's
> choice) and our sharing is done using a group private repository
> on github.  This is on Ubuntu Linux, it all works well.   In the
> evening hours, I use PyCharm on Windows 7 to contribute to an open
> source project hosted on bitbucket using mercurial. Both projects
> end up being tested on the same Linode.
>
> Yes, use virtualenv.  I also made the mistake of thinking of it as
> a virtual computer.  It is not.  It is only a method of separating
> Python library directories so that you can experiment with
> different configurations easily.  It does not slow anything down,
> and actually makes installation of packages easier.  Use
> virtualenvwrapper to make switching environments easy.  PyCharm
> also supports virtual environments as well as django projects. It
> is commercial, and suffers from a few Java idiosyncrasies, but the
> boss paid for the license ;-) so I don't mind.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-09-25 Thread Vernon D. Cole
Yes, I like to have three levels, too.  I call the middle one "staging".
You can tear it down and build it up again as many times as needed to get
it right.

A ten-year-old PC will work fine for staging practice. Blow the dust out
(the dust affects cooling and leads to poor reliability), load Ubuntu, and
park it in an unused corner somewhere.  My home-office Linux box is a Dell
desktop purchased at a University surplus sale for $20 six or seven years
ago. It runs Apache, MySQL, Asterisk, and the Python program that regulates
the lights and heat in our Iguana enclosure. The most expensive component
(other than the iguana) is a $50 UPS.  Much easier than trying to make your
production machine do double duty.

I use a structured settings module to switch back-and-forth between the
three levels.  Look at the manage.py and the formhub/settings directory in
https://github.com/vernondcole/formhub for an example how to do that.
Also look at requirements.pip in that repository for an idea how to load
most of the prerequisites automatically. Documentation is in the wiki of
https://github.com/modilabs/formhub/wiki/_pages .  (Formhub is a django
system used to receive generic survey data taken using android devices
offline.)




On Wed, Sep 25, 2013 at 12:49 PM, Bill Freeman  wrote:

> I guess that it's what you're used to.  I'm perfectly happy with emacs
> (less so with vi or vim, but still happy enough).  I'm happy with emac's
> python mode, css mode, etc.  There's even supposed to be help for Django
> templates now.  I'm using the Espresso add-on for JavaScript.  It's not
> everything that the IDEs offer, but I don't have to keep re-learning how to
> do things.  vim has some pretty good syntax support too.  I certainly
> wouldn't pay for something.  And having installed eclipse, it makes emacs
> look light weight.
>
> Indeed, I, too, tend to develop and test on my laptop, when I'm happy,
> check in my chaanges (mercurial), push to the linode, ssh in, update to
> head, and touch the wsgi script file (IIRC).  In a pinch I can directly
> edit on the linode, using vim through ssh, or emacs tramp mode over ssh,
> or, if you want to install your favorite X based editor on the linode,
> through a ssh -Y tunnel.
>
> Bill, the curmudgeon
>
>
> On Wed, Sep 25, 2013 at 2:06 PM, Jorge Arevalo 
> wrote:
>
>> Fine. I don't think my boss is going to pay for PyCharm license, so I'll
>> probably go for Eclipse now (I don't really like it too much, but if works,
>> it's ok for me)
>>
>> About virtualenv, is there any method to provide something like a script
>> to create a virtualenv, install the needed software and have a working
>> environment in a few commands? Something like "vagrantfile for virtualenv"
>> http://docs.vagrantup.com/v2/vagrantfile/index.html
>>
>> Again, many thanks for your useful insights
>>
>>
>> On Tuesday, September 17, 2013 4:29:14 PM UTC+2, Vernon D. Cole wrote:
>>>
>>> Answering the other half of your question:  The choice of IDE is not
>>> nearly as important as its ease of integration with your dvcs.  If you are
>>> already familiar with a good one, don't change.
>>>
>>> On my present project, my boss and I are both using PyCharm, and my
>>> other co-worker is using Eclipse, since he is more comfortable (and
>>> therefore, more productive) with it. Both IDE's have good integration with
>>> git (my least favourite dvcs, but the boss's choice) and our sharing is
>>> done using a group private repository on github.  This is on Ubuntu Linux,
>>> it all works well.   In the evening hours, I use PyCharm on Windows 7 to
>>> contribute to an open source project hosted on bitbucket using mercurial.
>>> Both projects end up being tested on the same Linode.
>>>
>>> Yes, use virtualenv.  I also made the mistake of thinking of it as a
>>> virtual computer.  It is not.  It is only a method of separating Python
>>> library directories so that you can experiment with different
>>> configurations easily.  It does not slow anything down, and actually makes
>>> installation of packages easier.  Use virtualenvwrapper to make switching
>>> environments easy.  PyCharm also supports virtual environments as well as
>>> django projects. It is commercial, and suffers from a few Java
>>> idiosyncrasies, but the boss paid for the license ;-) so I don't mind.
>>>
>>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> 

Re: Recommended dev environment for a Django project deployed to Linode

2013-09-25 Thread Bill Freeman
I guess that it's what you're used to.  I'm perfectly happy with emacs
(less so with vi or vim, but still happy enough).  I'm happy with emac's
python mode, css mode, etc.  There's even supposed to be help for Django
templates now.  I'm using the Espresso add-on for JavaScript.  It's not
everything that the IDEs offer, but I don't have to keep re-learning how to
do things.  vim has some pretty good syntax support too.  I certainly
wouldn't pay for something.  And having installed eclipse, it makes emacs
look light weight.

Indeed, I, too, tend to develop and test on my laptop, when I'm happy,
check in my chaanges (mercurial), push to the linode, ssh in, update to
head, and touch the wsgi script file (IIRC).  In a pinch I can directly
edit on the linode, using vim through ssh, or emacs tramp mode over ssh,
or, if you want to install your favorite X based editor on the linode,
through a ssh -Y tunnel.

Bill, the curmudgeon


On Wed, Sep 25, 2013 at 2:06 PM, Jorge Arevalo wrote:

> Fine. I don't think my boss is going to pay for PyCharm license, so I'll
> probably go for Eclipse now (I don't really like it too much, but if works,
> it's ok for me)
>
> About virtualenv, is there any method to provide something like a script
> to create a virtualenv, install the needed software and have a working
> environment in a few commands? Something like "vagrantfile for virtualenv"
> http://docs.vagrantup.com/v2/vagrantfile/index.html
>
> Again, many thanks for your useful insights
>
>
> On Tuesday, September 17, 2013 4:29:14 PM UTC+2, Vernon D. Cole wrote:
>>
>> Answering the other half of your question:  The choice of IDE is not
>> nearly as important as its ease of integration with your dvcs.  If you are
>> already familiar with a good one, don't change.
>>
>> On my present project, my boss and I are both using PyCharm, and my other
>> co-worker is using Eclipse, since he is more comfortable (and therefore,
>> more productive) with it. Both IDE's have good integration with git (my
>> least favourite dvcs, but the boss's choice) and our sharing is done using
>> a group private repository on github.  This is on Ubuntu Linux, it all
>> works well.   In the evening hours, I use PyCharm on Windows 7 to
>> contribute to an open source project hosted on bitbucket using mercurial.
>> Both projects end up being tested on the same Linode.
>>
>> Yes, use virtualenv.  I also made the mistake of thinking of it as a
>> virtual computer.  It is not.  It is only a method of separating Python
>> library directories so that you can experiment with different
>> configurations easily.  It does not slow anything down, and actually makes
>> installation of packages easier.  Use virtualenvwrapper to make switching
>> environments easy.  PyCharm also supports virtual environments as well as
>> django projects. It is commercial, and suffers from a few Java
>> idiosyncrasies, but the boss paid for the license ;-) so I don't mind.
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Not able to create an simple application using DB (syncdb error)

2013-09-25 Thread Bill Freeman
And where is your settings.py file?  If it is in the same directory as
manage.py, and it is a reasonably current Django (1.4, 1.5), then it's in
the wrong place.  It belongs in a sub-directory named 'blog1', along with
your urls.py, wsgi.py and an empty __init__.py .



On Wed, Sep 25, 2013 at 1:40 PM, s. gulab  wrote:

> When i give " ./manage.py syncdb " i am getting following error.
>
> " *Traceback (most recent call last):*
> *  File "manage.py", line 10, in *
> *execute_from_command_line(sys.argv)*
> *  File
> "c:\Python27\lib\site-packages\django\core\management\__init__.py", line*
> *453, in execute_from_command_line*
> *utility.execute()*
> *  File
> "c:\Python27\lib\site-packages\django\core\management\__init__.py", line*
> *392, in execute*
> *self.fetch_command(subcommand).run_from_argv(self.argv)*
> *  File
> "c:\Python27\lib\site-packages\django\core\management\__init__.py", line*
> *263, in fetch_command*
> *app_name = get_commands()[subcommand]*
> *  File
> "c:\Python27\lib\site-packages\django\core\management\__init__.py", line*
> *109, in get_commands*
> *apps = settings.INSTALLED_APPS*
> *  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 53,
> in __ge*
> *tattr__*
> *self._setup(name)*
> *  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 48,
> in _set*
> *up*
> *self._wrapped = Settings(settings_module)*
> *  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line
> 134, in __i*
> *nit__*
> *raise ImportError("Could not import settings '%s' (Is it on
> sys.path?): %s"*
> *% (self.SETTINGS_MODULE, e))*
> *ImportError: Could not import settings 'blog1.settings' (Is it on
> sys.path?): No*
> * module named blog1.settings* "
>
> manage.py:
> 
> #!/usr/bin/env python
> import os
> import sys
>
> if __name__ == "__main__":
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blog1.settings")
>
> from django.core.management import execute_from_command_line
>
> execute_from_command_line(sys.argv)
>
> settings.py:
> 
>
> # Django settings for blog1 project.
>
> import os
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
> # ('Your Name', 'your_em...@example.com'),
> )
>
> MANAGERS = ADMINS
>
> *DATABASES = {*
> *'default': {*
> *'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add
> 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.*
> *'NAME': 'blog1',  # Or path to database file
> if using sqlite3.*
> *# The following settings are not used with sqlite3:*
> *'USER': 'blog',*
> *'PASSWORD': 'blog',*
> *'HOST': '',  # Empty for localhost through
> domain sockets or '127.0.0.1' for localhost through TCP.*
> *'PORT': '',  # Set to empty string for
> default.*
> *}*
> *}*
>
> # Hosts/domain names that are valid for this site; required if DEBUG is
> False
> # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
> ALLOWED_HOSTS = []
>
> # Local time zone for this installation. Choices can be found here:
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> # although not all choices may be available on all operating systems.
> # In a Windows environment this must be set to your system time zone.
> *TIME_ZONE = 'India/Tamilnadu'*
>
> # Language code for this installation. All choices can be found here:
> # http://www.i18nguy.com/unicode/language-identifiers.html
> LANGUAGE_CODE = 'en-us'
>
> SITE_ID = 1
>
> # If you set this to False, Django will make some optimizations so as not
> # to load the internationalization machinery.
> USE_I18N = True
>
> # If you set this to False, Django will not format dates, numbers and
> # calendars according to the current locale.
> USE_L10N = True
>
> # If you set this to False, Django will not use timezone-aware datetimes.
> USE_TZ = True
>
> # Absolute filesystem path to the directory that will hold user-uploaded
> files.
> # Example: "/var/www/example.com/media/"
> MEDIA_ROOT = ''
>
> # URL that handles the media served from MEDIA_ROOT. Make sure to use a
> # trailing slash.
> # Examples: "http://example.com/media/;, "http://media.example.com/;
> MEDIA_URL = ''
>
> # Absolute path to the directory static files should be collected to.
> # Don't put anything in this directory yourself; store your static files
> # in apps' "static/" subdirectories and in STATICFILES_DIRS.
> # Example: "/var/www/example.com/static/"
> STATIC_ROOT = ''
>
> # URL prefix for static files.
> # Example: "http://example.com/static/;, "http://static.example.com/;
> STATIC_URL = '/static/'
>
> # Additional locations of static files
> STATICFILES_DIRS = (
> # Put strings here, like "/home/html/static" or "C:/www/django/static".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> )
>
> # List of finder classes that know how to find 

Re: Not able to create an simple application using DB (syncdb error)

2013-09-25 Thread Roopa singh
Can you please check this thread
http://stackoverflow.com/questions/12987648/importerror-could-not-import-settings
.


On Wed, Sep 25, 2013 at 11:10 PM, s. gulab  wrote:

> When i give " ./manage.py syncdb " i am getting following error.
>
> " *Traceback (most recent call last):*
> *  File "manage.py", line 10, in *
> *execute_from_command_line(sys.argv)*
> *  File
> "c:\Python27\lib\site-packages\django\core\management\__init__.py", line*
> *453, in execute_from_command_line*
> *utility.execute()*
> *  File
> "c:\Python27\lib\site-packages\django\core\management\__init__.py", line*
> *392, in execute*
> *self.fetch_command(subcommand).run_from_argv(self.argv)*
> *  File
> "c:\Python27\lib\site-packages\django\core\management\__init__.py", line*
> *263, in fetch_command*
> *app_name = get_commands()[subcommand]*
> *  File
> "c:\Python27\lib\site-packages\django\core\management\__init__.py", line*
> *109, in get_commands*
> *apps = settings.INSTALLED_APPS*
> *  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 53,
> in __ge*
> *tattr__*
> *self._setup(name)*
> *  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 48,
> in _set*
> *up*
> *self._wrapped = Settings(settings_module)*
> *  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line
> 134, in __i*
> *nit__*
> *raise ImportError("Could not import settings '%s' (Is it on
> sys.path?): %s"*
> *% (self.SETTINGS_MODULE, e))*
> *ImportError: Could not import settings 'blog1.settings' (Is it on
> sys.path?): No*
> * module named blog1.settings* "
>
> manage.py:
> 
> #!/usr/bin/env python
> import os
> import sys
>
> if __name__ == "__main__":
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blog1.settings")
>
> from django.core.management import execute_from_command_line
>
> execute_from_command_line(sys.argv)
>
> settings.py:
> 
>
> # Django settings for blog1 project.
>
> import os
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
> # ('Your Name', 'your_em...@example.com'),
> )
>
> MANAGERS = ADMINS
>
> *DATABASES = {*
> *'default': {*
> *'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add
> 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.*
> *'NAME': 'blog1',  # Or path to database file
> if using sqlite3.*
> *# The following settings are not used with sqlite3:*
> *'USER': 'blog',*
> *'PASSWORD': 'blog',*
> *'HOST': '',  # Empty for localhost through
> domain sockets or '127.0.0.1' for localhost through TCP.*
> *'PORT': '',  # Set to empty string for
> default.*
> *}*
> *}*
>
> # Hosts/domain names that are valid for this site; required if DEBUG is
> False
> # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
> ALLOWED_HOSTS = []
>
> # Local time zone for this installation. Choices can be found here:
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> # although not all choices may be available on all operating systems.
> # In a Windows environment this must be set to your system time zone.
> *TIME_ZONE = 'India/Tamilnadu'*
>
> # Language code for this installation. All choices can be found here:
> # http://www.i18nguy.com/unicode/language-identifiers.html
> LANGUAGE_CODE = 'en-us'
>
> SITE_ID = 1
>
> # If you set this to False, Django will make some optimizations so as not
> # to load the internationalization machinery.
> USE_I18N = True
>
> # If you set this to False, Django will not format dates, numbers and
> # calendars according to the current locale.
> USE_L10N = True
>
> # If you set this to False, Django will not use timezone-aware datetimes.
> USE_TZ = True
>
> # Absolute filesystem path to the directory that will hold user-uploaded
> files.
> # Example: "/var/www/example.com/media/"
> MEDIA_ROOT = ''
>
> # URL that handles the media served from MEDIA_ROOT. Make sure to use a
> # trailing slash.
> # Examples: "http://example.com/media/;, "http://media.example.com/;
> MEDIA_URL = ''
>
> # Absolute path to the directory static files should be collected to.
> # Don't put anything in this directory yourself; store your static files
> # in apps' "static/" subdirectories and in STATICFILES_DIRS.
> # Example: "/var/www/example.com/static/"
> STATIC_ROOT = ''
>
> # URL prefix for static files.
> # Example: "http://example.com/static/;, "http://static.example.com/;
> STATIC_URL = '/static/'
>
> # Additional locations of static files
> STATICFILES_DIRS = (
> # Put strings here, like "/home/html/static" or "C:/www/django/static".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> )
>
> # List of finder classes that know how to find static files in
> # various locations.
> STATICFILES_FINDERS = (
> 'django.contrib.staticfiles.finders.FileSystemFinder',
> 

IntegrityError with proxy model but not with parent?

2013-09-25 Thread Derek
I am working with a proxy model that does not seem to work with the
'unique_together' of the model being proxied.

What I have is:

class Parent(Model):
id = AutoField(primary_key=True)
name = CharField()
stuff = CharField()

class Meta:
ordering = ['name']
unique_together = (('name', 'stuff'),)

class Myproxy(Parent):

class Meta:
proxy = True

def __init__(self, *args, **kwargs):
super(Myproxy, self).__init__(*args, **kwargs)
self.stuff = "test"

If I use the Parent model and try to enter, 'myname' and 'test' as the
name/stuff entries twice, I get the usual warning on the second attempt;
the admin telling me that this model entry already exists.

However, if I try the same thing on the Myproxy model (which has a form
without the stuff field; as its meant to be a preset value), I get an:

IntegrityError at /admin/../add/
(1062, "Duplicate entry 'myname-test' for key 'name'")

The stack trace is as follows:

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
in get_response
  115. response = callback(request, *callback_args,
**callback_kwargs)
File
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in
wrapper
  372. return self.admin_site.admin_view(view)(*args,
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
_wrapped_view
  91. response = view_func(request, *args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py"
in _wrapped_view_func
  89. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py"
in inner
  202. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
_wrapper
  25. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
_wrapped_view
  91. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in
bound_func
  21. return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in
inner
  223. return func(*args, **kwargs)
File
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in
add_view
  1007. self.save_model(request, new_object, form, False)
File
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in
save_model
  740. obj.save()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in
save
  546.force_update=force_update,
update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in
save_base
  591.update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in
save_base
  650. result = manager._insert([self], fields=fields,
return_id=update_pk, using=using, raw=raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py"
in _insert
  215. return insert_query(self.model, objs, fields, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in
insert_query
  1675. return query.get_compiler(using=using).execute_sql(return_id)
File
"/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py"
in execute_sql
  937. cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in
execute
  41. return self.cursor.execute(sql, params)
File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py"
in execute
  122. six.reraise(utils.IntegrityError,
utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py"
in execute
  120. return self.cursor.execute(query, args)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py" in execute
  174. self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py" in
defaulterrorhandler
  36. raise errorclass, errorvalue


(FTR, I have also tried overriding the model save(), but again get an
IntegrityError, instead of Django performing the expected check).

I am obviously missing some key piece of code, but cannot see what it is.

Thanks
Derek

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more 

Re: Recommended dev environment for a Django project deployed to Linode

2013-09-25 Thread Jorge Arevalo
Fine. I don't think my boss is going to pay for PyCharm license, so I'll 
probably go for Eclipse now (I don't really like it too much, but if works, 
it's ok for me)

About virtualenv, is there any method to provide something like a script to 
create a virtualenv, install the needed software and have a working 
environment in a few commands? Something like "vagrantfile for 
virtualenv" http://docs.vagrantup.com/v2/vagrantfile/index.html

Again, many thanks for your useful insights

On Tuesday, September 17, 2013 4:29:14 PM UTC+2, Vernon D. Cole wrote:
>
> Answering the other half of your question:  The choice of IDE is not 
> nearly as important as its ease of integration with your dvcs.  If you are 
> already familiar with a good one, don't change.
>
> On my present project, my boss and I are both using PyCharm, and my other 
> co-worker is using Eclipse, since he is more comfortable (and therefore, 
> more productive) with it. Both IDE's have good integration with git (my 
> least favourite dvcs, but the boss's choice) and our sharing is done using 
> a group private repository on github.  This is on Ubuntu Linux, it all 
> works well.   In the evening hours, I use PyCharm on Windows 7 to 
> contribute to an open source project hosted on bitbucket using mercurial. 
> Both projects end up being tested on the same Linode.
>
> Yes, use virtualenv.  I also made the mistake of thinking of it as a 
> virtual computer.  It is not.  It is only a method of separating Python 
> library directories so that you can experiment with different 
> configurations easily.  It does not slow anything down, and actually makes 
> installation of packages easier.  Use virtualenvwrapper to make switching 
> environments easy.  PyCharm also supports virtual environments as well as 
> django projects. It is commercial, and suffers from a few Java 
> idiosyncrasies, but the boss paid for the license ;-) so I don't mind.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-09-25 Thread Jorge Arevalo
Hello,

First of all, many thanks for your response. Sorry for the delay answering 
this. I was in a business trip. 

So, you basically have 2 environments: your own machine, and the Linode 
box. You make the development and testing in your machine, and Linode is 
for production purposes. And you connect both environments via dvcs 
push/pull. Right?

I like it because it's simple and doesn't seem to be specially prone to 
errors. I'd just like to add a third scenario here, to end up with:

- Development environment: my own machine (Mac OS X) with all the software 
stack installed.
- Testing environment: my new addition. I would like to put this 
environment outside of my machine
- Production environment: the Linode box.

I can do the communication via push/pull, if there's no other way to 
"deploy" software to production with Python/Django (it's simple, I like 
it). And maybe I can have 2 urls (testing and production) in the Linode 
box. Testing just accessible to developers and testers, and production open 
to normal users. Does it make sense?

Thanks again

On Tuesday, September 17, 2013 3:50:55 PM UTC+2, Vernon D. Cole wrote:
>
>
> I installed a client for my favourite distributed version control system 
> on my Linode instance.  I have a private repository on a public IP.  
> (github, bitbucket, or launchpad will work, depending on your dvcs of 
> choice -- I have used all three, and other times I have used a private dvcs 
> host, including my Linode server itself.) I "cloned" a "checkout" of my 
> django system to the Linode. When I am happy from testing a new version of 
> my application:  I push it to the repository,  log in to my Linode using 
> ssh, and do a pull.  Easy and error free.  (My django environment is almost 
> exactly like yours with PostGIS, etc.)
> --
>
> On Monday, September 16, 2013 6:33:49 PM UTC+1, Jorge Arevalo wrote:
>>
>> Hello,
>>
>> I'm going to start a project based on (Geo)Django + PostgreSQL/PostGIS + 
>> OpenLayers/LeafLet + Bootstrap/Foundation. The project will be deployed to 
>> a Linode box. That box will be created with something like this: 
>> https://manager.linode.com/linodes/deploy/linode393074?StackScriptID=6482
>>
>> My work box is a MacBook with Mac OS X 10.6.8. There will be 2 people 
>> working on the web app (me and another guy). I have almost total freedom to 
>> choose, so I want to choose wisely. The whole point is that these 
>> constraints should be satisfied:
>>
>> - I need a reliable way to upload the application to the test/production 
>> environments. At least the production environment will be a Linode box. I 
>> just don't want to upload files via FTP, or manually copy them with rsync, 
>> or any other practice easily subject to errors. How do the professional 
>> django developers set up their environment in order to deploy the app?
>>
>> - I'm not sure about which IDE/editor choose. I don't want to start an 
>> editor war, and I've used several options in the past. My main interest is: 
>> I want to focus on develop. If Eclipse/Aptana/Eric/PyCharm/any IDE can be 
>> easily "linked" to my environment, that's my choice. For example, if I can 
>> deploy my app to test/production environment with a couple of clicks or 
>> commands, thanks to a plugin or script, that's great. Like deploying to 
>> Heroku or EC2, but with Linode. Is there any IDE specially friendly with 
>> this kind of development environment?
>>
>> - The other(s) developer(s) must be up ASAP. They can't spend 
>> half a day installing and configuring stuff to start being productive. I 
>> guess a VirtualBox machine + Vagrant would be a good choice here. But, 
>> would it make more difficult the deployment cycle? And using a virtual 
>> machine to just open the IDE and develop sounds like a resource waste to 
>> me. Is there any other solution?
>>
>> I think I should use, at least, VirtualEnv, VirtualEnvWrapper and PIP, 
>> like I've read in these useful links
>>
>>
>> http://www.slideshare.net/ryan_blunden/virtualenv-and-pip-isolated-python-environments
>> http://www.slideshare.net/ajdiaz/isolated-development-in-python
>>
>> But I'd like to know the opinion of Djanjo experts / hard "pythonistas". 
>> Any suggestion is strongly appreciated.
>>
>> Many thanks in advance, and best regards
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-25 Thread Simon Charette
I assumed the OP wanted to get *all* instances of Item even if they don't 
have any liked status equals to 'L'.

The query you provided will filter out instances of Item with 
`itemlikestatus__count < 1` instead of returning an annotated value of 0.

Le mercredi 25 septembre 2013 04:41:37 UTC-4, Daniel Roseman a écrit :
>
> On Tuesday, 24 September 2013 21:58:44 UTC+1, Simon Charette wrote:
>
>> Unfortunately the Django ORM's doesn't support conditionnal 
>> aggregates
>> .
>>
>  
> This is true, but completely irrelevant to the OP's question, which 
> doesn't require them. The documentation gives an example which AFAICT is 
> exactly what the OP wants, at 
> https://docs.djangoproject.com/en/1.5/topics/db/aggregation/#order-of-annotate-and-filter-clauses.
>  
> Translating it into the relevant models:
>
> items_by_popularity = 
> Item.objects.all().filter(itemlikestatus__liked_status='L').annotate(Count('itemlikestatus')).order_by('-itemlikestatus__count')[:number_requested]
>
> --
> DR.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Not able to create an simple application using DB (syncdb error)

2013-09-25 Thread s. gulab
When i give " ./manage.py syncdb " i am getting following error.

" *Traceback (most recent call last):*
*  File "manage.py", line 10, in *
*execute_from_command_line(sys.argv)*
*  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", 
line*
*453, in execute_from_command_line*
*utility.execute()*
*  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", 
line*
*392, in execute*
*self.fetch_command(subcommand).run_from_argv(self.argv)*
*  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", 
line*
*263, in fetch_command*
*app_name = get_commands()[subcommand]*
*  File "c:\Python27\lib\site-packages\django\core\management\__init__.py", 
line*
*109, in get_commands*
*apps = settings.INSTALLED_APPS*
*  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 53, 
in __ge*
*tattr__*
*self._setup(name)*
*  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 48, 
in _set*
*up*
*self._wrapped = Settings(settings_module)*
*  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 134, 
in __i*
*nit__*
*raise ImportError("Could not import settings '%s' (Is it on 
sys.path?): %s"*
*% (self.SETTINGS_MODULE, e))*
*ImportError: Could not import settings 'blog1.settings' (Is it on 
sys.path?): No*
* module named blog1.settings* "

manage.py:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blog1.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

settings.py:


# Django settings for blog1 project.

import os

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@example.com'),
)

MANAGERS = ADMINS

*DATABASES = {*
*'default': {*
*'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 
'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.*
*'NAME': 'blog1',  # Or path to database file 
if using sqlite3.*
*# The following settings are not used with sqlite3:*
*'USER': 'blog',*
*'PASSWORD': 'blog',*
*'HOST': '',  # Empty for localhost through 
domain sockets or '127.0.0.1' for localhost through TCP.*
*'PORT': '',  # Set to empty string for default.
*
*}*
*}*

# Hosts/domain names that are valid for this site; required if DEBUG is 
False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
*TIME_ZONE = 'India/Tamilnadu'*

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded 
files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/;, "http://media.example.com/;
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://example.com/static/;, "http://static.example.com/;
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'hr4fn+qh)3w)p-1g4(i-_12#mv_ncqa+*=-iz$5dl*w!@#+(h6'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 

Re: Restrict access to user-uploaded files to authorized users

2013-09-25 Thread Mattias Linnap
> Are there any obvious solutions that I have over looked?  Or am I stuck
having to use django to serve the files?

Depending on the security that you aim to achieve, one option would be to
add a custom file storage implementation that overrides
https://github.com/django/django/blob/master/django/core/files/storage.py#L63to
give all uploads randomly generated filenames - and therefore
unguessable URLs. In addition, Apache can be configured to redirect any
accesses to non-existing files in the media directory to a login page.

Only the original uploading user would know the URL, and be able to access
the file. However, this approach would still allow the user to share a
direct link to the file to other people.

Mattias



On Tue, Sep 24, 2013 at 9:53 PM, J Y  wrote:

> I am buliding a tool that needs to have the ability to allow user to
> upload a file, and the file should only be accessible by the user who
> uploaded it.  It seems that the MEDIA_ROOT directory must be placed in the
> public www directory for front end web servers Apache to serve the file,
> which currently does not restrict access to any of the uploaded files.
>  What I am looking for is a way that I can lock it down so that if they try
> to access the file directly, I would bring up a login screen and they must
> authenticate before I give them access to it.
>
> I did some searching around, and found various solutions to the problem,
> but none of them sounds like it would work for me.  My requirements are:
>
> 1. My front-end web server must be Apache
> 2. Apache setup and config cannot be changed to accommodate my site alone
> (unless it's a config I can easily override in .htaccess)
> 3. Users should not have to log in twice (If they authenticated against
> django already, no reason to ask them to login to Apache again)
> 3. Use django to serve the files as a last resort
>
> Here are some of the solutions I found:
>
> 1. Update nginx/apache config to hook into django's user's database.  This
> looks like it would ask the user to login again via Apache's login
> mechanism, plus it doesn't look like it would work with alternative
> authentication backend (I am using django-auth-ldap)
> 2. Use django-sendfile, not possible because it requires installing
> plugins to Apache
> 3. Serve files through django.  Not recommended by django, so I am loath
> to try it
> 4. Override the MEDIA_ROOT behavior in urls.py and implement my own file
> serving behavior.  This sounds not all that far off from #3.
>
> Are there any obvious solutions that I have over looked?  Or am I stuck
> having to use django to serve the files?
>
> Thanks for any advice,
>
> Jack
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


"original" not set in admin template django/contrib/admin/templates/admin/submit_line.html after upgrade

2013-09-25 Thread Gloria W
Hi all,

I recently upgraded a site from 1.4 to 1.5.4, and it seems like in the 
submit_line template, "original" is not set. 
This line fails for that reason:

{% if show_delete_link %}{% trans "Delete" %}{% endif %}

The template chain at this point is so nested that it's hard to figure out 
where "original" originated. Does anyone know what is going on here?

Thank you,
Gloria

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Server-side validation for complex ajax forms

2013-09-25 Thread Mattias Linnap
Hi all,

I have been asked to build a single-page, ajax based data entry interface
for a moderately complex set of models. There are 5 models, linked into a
tree structure by foreign keys. The number of children for each model is
variable, so there could be up to 4 levels of nested formsets.

I can get a nice nested JSON representation of the data into Javascript on
the page using Django Rest Framework, and I'm sure I could hack together an
interface to modify that data structure in the browser with jQuery. I could
also use the Rest Framework to receive a POST with the new data structure,
and convert it to a series of plain Python dictionaries and lists.

However, I haven't yet discovered a great way to map it to updates,
insertions and deletions of existing model instances, validate it for
consistency, and return any errors for display at the right input fields in
the user interface.

I have seen https://code.google.com/p/django-ajax-forms/ for adding
client-side validation to forms - but it appears abandoned, and any data
should still be re-validated on the server side. Some of the validation
(unique constraints) can only be done on the server.

Do you have any suggestions, or links to useful libraries, tutorials and
blog posts about how to best approach this?

Thanks,

Mattias

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Restrict access to user-uploaded files to authorized users

2013-09-25 Thread Michael Fladischer
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2013-09-24 22:53, J Y wrote:
> Are there any obvious solutions that I have over looked?  Or am I
> stuck having to use django to serve the files?

If you have deployed through mod_wsgi:

Just serve the files through Apache but restrict access by having
Apache query the Django user database:

https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/apache-auth/

This will allow you to use HTTP basic auth when a user wants to access
a file in a protected location.

Although it will not limit the user's access to only the files he/she
uploaded, meaning that any authenticated user can access ALL protected
files.

HTH,
- -- 
Michael Fladischer
Fladi.at
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.21 (GNU/Linux)

iQIcBAEBAgAGBQJSQo0JAAoJEGlMre9Rx7W2s7AQAJ/T70od7W/8PzmImAJzS1G5
yH2flMjwnPf7GVhlhElot1QxMuHp99O+29/+sEEgMxhsAh6tBr770U+JfNic5/YL
xhKwYS82GhzoPhgr2p9O3Zmm3pDzmCB7w+Y1omjPH2JhWWARdja/4mZmM/nU53Wq
HhYcre+po4TyjY86/6y4/c6RQm3QUea7Jo5O6DDcd8byCAmD8U7Tt0ObypVHaUE+
EZc14Gh95ZWSsfmXKeK3xJ7LKvrasOpKhqy9a0HRoHExpoqw9BYIgGwtqhn3Alx8
MI4DoNwpQWm3PCtgRq3hqfsRDnOvisUJmdKtNDUSE8H23T5DohVXVHeUzpnkp+zq
JgdqxEUYGCHe6al2sonI/cfeKlzDtjNm0qTJGsuABHwg0snj/lp63LHJpL+yEsTa
EAdSdQHPV1BX1nXZeRzsKffIQ6r84HcWGtUn7l/VCzCyZA+QHDMsNR/dL8oAH3Oe
q80qIRM3IopuP/4px00Qa5owcOQaus8MZUxXZ3IvxQcycxec4TmMAp/f6KIisT3c
3MOLgx5K6NOt1FuzQtoAAOgyJKz28YTjIInZ2yq13CypYqp1U6LdCoqGNf5C/58z
tzR8/yExI1Cc/1hMS1wFvE5apUPkTB/PglYWaNXLdnuWtZ44kXgsMR84ivYSRSmI
W5kZHsT1jXKR+Tbg2ySH
=tuRc
-END PGP SIGNATURE-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


wrong data on save

2013-09-25 Thread elia chiesa
Hi all,

I have this change list in admin. On this list I can edit two fields inline.

Problem is, on save, in overridden method "save_model(self, request, obj, 
form, change)", when I check for data integrity, sometimes values of these 
two fields from post, form and model differ.
When it happens, many saved rows show this behavior. 
Without this integrity control, django would have save wrong data in db.

Thanks for your time and sorry for my bad english.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


View videos

2013-09-25 Thread Hélio Miranda
Good.
I have a problem that does not really know how to solve.
It is this: I have my server-client application. On the server I'm using 
django with tastypie. My problem is this, I'm uploading videos (where I am 
entering these videos in GridFS, file system mongodb), now I wonder how do 
I show the videos to the customer?

Sending the videos to the customer and deal there? Show the videos on the 
server and on the client meth in this iframe?
What would be the best solution?
Someone could help me?

thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Template Syntax Error

2013-09-25 Thread SHANTANU SRIVASTAVA
Thanks ! The urls.py can be viewed here : http://dpaste.com/hold/1394929/

On Tuesday, September 24, 2013 1:10:57 AM UTC+5:30, Alagappan Ramu wrote:
>
> Looks like the is an issue in Django being able to resolve URLs in your 
> application. Can you paste your urls.py for more info. 
>
>
> Regards,
> Alagappan R
>
> Twitter: @_alagappan 
>
> Thanks & Regards,
> Alagappan Ramu
> +1 (716) 598 2730
>
> Graduate Student in Computer Science
> University at Buffalo, The State University of New 
> York.
>
>
>
> On Mon, Sep 23, 2013 at 7:12 AM, SHANTANU SRIVASTAVA <
> shan...@rediffmail.com > wrote:
>
>>  
>> Hi People ! Just started development with Django and am stuck with this 
>> error. When I run my admin panel from the server (default server of django) 
>> the browser shows this error "TemplateSyntaxError
>> " - Caught RuntimeError while rendering: maximum recursion depth exceeded 
>> while calling a Python object. Help me in resolving this ! Any help 
>> appreciated .
>>
>> I am developing on a 64bit x86 machine. OS-Windows - 7. 
>>
>> The tracebacks and detailed report is here : 
>> http://dpaste.com/1392716/plain/
>>
>> It is also attached as an attachment with this mail.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Aggregation and count - only counting certain related models? (i.e. adding a filter on the count)

2013-09-25 Thread Daniel Roseman
On Tuesday, 24 September 2013 21:58:44 UTC+1, Simon Charette wrote:

> Unfortunately the Django ORM's doesn't support conditionnal 
> aggregates
> .
>
 
This is true, but completely irrelevant to the OP's question, which doesn't 
require them. The documentation gives an example which AFAICT is exactly 
what the OP wants, 
at 
https://docs.djangoproject.com/en/1.5/topics/db/aggregation/#order-of-annotate-and-filter-clauses.
 
Translating it into the relevant models:

items_by_popularity = 
Item.objects.all().filter(itemlikestatus__liked_status='L').annotate(Count('itemlikestatus')).order_by('-itemlikestatus__count')[:number_requested]

--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.