Re: new field in models

2013-07-23 Thread Serdar Dalgic
On Mon, Jul 22, 2013 at 10:53 AM, Harjot Mann  wrote:
> In django when we add a new field in existing class, we need to drop
> the table and then run the syncdb again. Is there any alternative for
> it so that we can add the field without dropping the table??
>

You can also run sqldiff django command if you have django_extensions
installed in your django app.

See http://pythonhosted.org/django-extensions/sqldiff.html for
details. It gives you the difference between your model and the
database structure. Then, you can apply this difference to your db.


-- 
- Serdar Dalgıç 
FLOSS Developer, Life & Nature Hacker
twitter:
https://twitter.com/serdaroncode
https://twitter.com/serdarintowild

-- 
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: Search from database

2013-07-23 Thread Kamal Kaur
On Wed, Jul 24, 2013 at 5:15 AM, Amirouche Boubekki
 wrote:
> Apache solr or ElasticSearch: yes
> Haystack: maybe
> Regex: no


Thanks.
Studying ElasticSearch currently.


-- 
Kamaljeet Kaur

kamalkaur188.wordpress.com
facebook.com/kaur.188

-- 
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: Search from database

2013-07-23 Thread Amirouche Boubekki
Apache solr or ElasticSearch: yes
Haystack: maybe
Regex: no


2013/7/21 Kamal Kaur 

> We can search from database using phonetic codes or queries. I want an
> advanced search module in my project. That can suggest similar
> spellings from database, if user enters something wrong, like if
> something is misspelled, it must tell that you might have entered
> something wrong, similar results are shown. And more options for user
> to search accordingly. Can something be done using regex? or I need to
> go for Haystack/Apache solr?
>
>
> --
> Kamaljeet Kaur
>
> Blog:http://kamalkaur188.wordpress.com/
>
> --
> 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.




Problem with chaining filters

2013-07-23 Thread Pepsodent Cola
*1.*
I wrote this to make python shell only list Words that have no translation.

>>> Word.objects.filter(translation='')
[, , ]



*2.*
How can I use the above filter result and chain it,
so that I can make a new list that displays the field *"articulate"*,
from the other table "Pronunciation"?


01 class Word(models.Model):
02word = models.CharField(max_length=200)
03translation = models.CharField(max_length=120, blank=True, null=True)
04def __unicode__(self):
05return self.word
06  
07 class Pronunciation(models.Model):
08word = models.ForeignKey(Word)
09articulate = models.CharField(max_length=200)
10def __unicode__(self):
11return self.articulate


 

-- 
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: python manage.py runserver error

2013-07-23 Thread Jay Lozier
virtualenv works, this for the link.

On Sunday, July 21, 2013 10:09:59 PM UTC-4, Jay Lozier wrote:
>
> I get the following error when run python manage.py runserver:
>
> OS openSUSE 12.3
> django 1.7
>
>
> boopers@linux-nss6:~/myfirstsite> python manage.py runserver
> Traceback (most recent call last):
> File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
> File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
> 397, in execute_from_command_line
> utility.execute()
> File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
> 390, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
> 261, in fetch_command
> app_name = get_commands()[subcommand]
> File "/home/boopers/django-trunk/django/core/management/__init__.py", line 
> 107, in get_commands
> apps = settings.INSTALLED_APPS
> File "/home/boopers/django-trunk/django/conf/__init__.py", line 54, in 
> __getattr__
> self._setup(name)
> File "/home/boopers/django-trunk/django/conf/__init__.py", line 50, in 
> _setup
> self._configure_logging()
> File "/home/boopers/django-trunk/django/conf/__init__.py", line 68, in 
> _configure_logging
> from django.utils.log import DEFAULT_LOGGING
> File "/home/boopers/django-trunk/django/utils/log.py", line 7, in 
> from django.views.debug import ExceptionReporter, 
> get_exception_reporter_filter
> File "/home/boopers/django-trunk/django/views/debug.py", line 10, in 
> 
> from django.http import (HttpResponse, HttpResponseServerError,
> File "/home/boopers/django-trunk/django/http/__init__.py", line 4, in 
> 
> from django.http.response import (HttpResponse, StreamingHttpResponse,
> File "/home/boopers/django-trunk/django/http/response.py", line 16, in 
> 
> from django.utils import six, timezone
> File "/home/boopers/django-trunk/django/utils/timezone.py", line 11, in 
> 
> import pytz
> File "/usr/lib/python2.7/site-packages/pytz/__init__.py", line 35, in 
> 
> from pkg_resources import resource_stream
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 3027, in 
> add_activation_listener(lambda dist: dist.activate())
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 741, in subscribe
> callback(dist)
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 3027, in 
> add_activation_listener(lambda dist: dist.activate())
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 2514, in activate
> list(map(declare_namespace, self._get_metadata('namespace_packages.txt')))
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 2094, in declare_namespace
> _handle_ns(packageName, path_item)
> File 
> "/usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg/pkg_resources.py",
>  
> line 2059, in _handle_ns
> raise TypeError("Not a package:", packageName)
> TypeError: ('Not a package:', 'cgi')
>
>
> The sys paths are
>
> /usr/lib/python2.7/site-packages/pymongo-2.5.1-py2.7-linux-x86_64.egg
> /usr/lib/python2.7/site-packages/bottle-0.11.6-py2.7.egg
> /usr/lib/python2.7/site-packages/translationstring-1.1-py2.7.egg
> /usr/lib/python2.7/site-packages/venusian-1.0a8-py2.7.egg
> /usr/lib/python2.7/site-packages/zope.deprecation-4.0.2-py2.7.egg
> /usr/lib/python2.7/site-packages/setuptools-0.9.6-py2.7.egg
> /home/boopers/django-trunk
> /usr/lib/python27.zip
> /usr/lib64/python2.7
> /usr/lib64/python2.7/plat-linux2
> /usr/lib64/python2.7/lib-tk
> /usr/lib64/python2.7/lib-old
> /usr/lib64/python2.7/lib-dynload
> /usr/lib64/python2.7/site-packages
> /usr/lib64/python2.7/site-packages/FontTools
> /usr/lib64/python2.7/site-packages/PIL
> /usr/local/lib64/python2.7/site-packages
> /usr/local/lib/python2.7/site-packages
> /usr/lib64/python2.7/site-packages/gst-0.10
> /usr/lib64/python2.7/site-packages/gtk-2.0
> /usr/lib64/python2.7/site-packages/input-pad-1.0
> /usr/lib/python2.7/site-packages
> /usr/lib64/python2.7/site-packages/wx-2.9.4-gtk2
>

-- 
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: django-admin.py startproject mysite error

2013-07-23 Thread Jay Lozier
virtualenv seems to work well and I can get django tamed.

On Saturday, July 20, 2013 5:55:21 PM UTC-4, Jay Lozier wrote:
>
> Using openSUSE 12.3
> python 2.7.3
> django 1.5.1 installed manually and verified
>
> When I enter "django-admin.py startproject mysite" at the command prompt I 
> get the following traceback:
>
> Traceback (most recent call last):
> File "/usr/bin/django-admin.py", line 5, in 
> management.execute_from_command_line()
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 453, in execute_from_command_line
> utility.execute()
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 272, in fetch_command
> klass = load_command_class(app_name, subcommand)
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 
> 77, in load_command_class
> module = import_module('%s.management.commands.%s' % (app_name, name))
> File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 
> 35, in import_module
> __import__(name)
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/commands/startproject.py",
>  
> line 2, in 
> from django.core.management.templates import TemplateCommand
> File 
> "/usr/lib/python2.7/site-packages/django/core/management/templates.py", 
> line 20, in 
> from django.template import Template, Context
> File "/usr/lib/python2.7/site-packages/django/template/__init__.py", line 
> 53, in 
> from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
> File "/usr/lib/python2.7/site-packages/django/template/base.py", line 18, 
> in 
> from django.utils.formats import localize
> File "/usr/lib/python2.7/site-packages/django/utils/formats.py", line 5, 
> in 
> from django.utils import dateformat, numberformat, datetime_safe
> File "/usr/lib/python2.7/site-packages/django/utils/dateformat.py", line 
> 25, in 
> from django.utils.timezone import is_aware, is_naive
> File "/usr/lib/python2.7/site-packages/django/utils/timezone.py", line 11, 
> in 
> import pytz
> File "/usr/lib/python2.7/site-packages/pytz/__init__.py", line 35, in 
> 
> from pkg_resources import resource_stream
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 
> 
> add_activation_listener(lambda dist: dist.activate())
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 709, in 
> subscribe
> callback(dist)
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2978, in 
> 
> add_activation_listener(lambda dist: dist.activate())
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2465, in 
> activate
> map(declare_namespace, self._get_metadata('namespace_packages.txt'))
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2045, in 
> declare_namespace
> _handle_ns(packageName, path_item)
> File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2010, in 
> _handle_ns
> raise TypeError("Not a package:", packageName)
> TypeError: ('Not a package:', 'cgi')
>
> How do I fix this?
>

-- 
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: How to force modelForm.is_valid() to use a specific database?

2013-07-23 Thread Fred Stluka

Fellipe,

See:
https://docs.djangoproject.com/en/dev/topics/db/multi-db/

There are a number of ways for force use of a specific database.
You can force it per query, per table, or by any other criteria you
like.  You may need to set up a simple "database router".

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 7/23/13 2:52 PM, Fellipe Henrique wrote:
The problem is: when usng modelForm, it try to validate the unique key 
in the database, and this validation use a default database.. if I 
remove primary_key=True in my model, work fine, but I need to set the 
pk in my model, because when I try to get using: obj.get(xx)  show me 
error...



I try every think.. and I start to think is not possible multi-db in 
"runtime" in django.. :(


T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

/Blog: http://fhbash.wordpress.com//
/GitHub: https://github.com/fellipeh/
/Twitter: @fh_bash/


2013/7/23 Brian Millham >

I've done that with this code:

if form.is_valid():
  f = form.save(commit = False)
  f.save(using='yourdatabase')


Works fine for me.


On Tuesday, July 23, 2013 1:21:29 PM UTC-4, Fellipe Henrique wrote:

I have many database setted in my setting.py   in my
formModel, when I try to validate the form, show me error:


http://stackoverflow.com/questions/17797419/modelforms-and-multiple-datasbase-error-in-form-is-valid

The problem is.. is_valid is going to "default" database...
how can I force to got to another database?

Thanks.

-- 
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: Aggregating annotations

2013-07-23 Thread Debanshu Kundu
This bug has been solved here: https://code.djangoproject.com/ticket/20782

On Friday, July 19, 2013 11:49:52 AM UTC+5:30, Debanshu Kundu wrote:
>
> If I have a model *Book* defined as:
>
> class Book(models.Model):
>name = models.CharField(max_length=300)
>pages = models.IntegerField()
>price = models.DecimalField(max_digits=10, decimal_places=2)
>rating = models.FloatField()
>pubdate = models.DateField()
>
> and I run the query:
>
> Book.objects.values('rating').annotate(books_per_rating=Count('id')).aggregate(Max(books_per_rating))
>
> I get a *DatabaseError*.
>
> According to this 
> https://docs.djangoproject.com/en/1.5/topics/db/aggregation/#aggregating-annotations,
>  
> Django supports aggregating annotations. But in the example given in the 
> link itself, they annotate over a *QuerySet* which in turn returns a *
> QuerySet* (and not *ValuesQuerySet*), so aggregate method runs 
> successfully. But in my example aggregating a *ValuesQuerySet* raises a *
> DatabaseError*.
>
> Is it a bug in Django? Because if Django does not support aggregation over 
> *ValuesQuerySet* then it should raise an exception at Django level (not *
> DatabaseError*).
>
>

-- 
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: Aggregating annotations

2013-07-23 Thread Debanshu Kundu
This bug has been solved here: https://code.djangoproject.com/ticket/20782

On Friday, July 19, 2013 10:05:46 PM UTC+5:30, Debanshu Kundu wrote:
>
> Also interestingly, if I do: 
>
> Book.objects.values('rating').aggregate(Max('rating'))
>
> It returns an empty dict without performing any DB query!!
>
> On Friday, July 19, 2013 11:49:52 AM UTC+5:30, Debanshu Kundu wrote:
>>
>> If I have a model *Book* defined as:
>>
>> class Book(models.Model):
>>name = models.CharField(max_length=300)
>>pages = models.IntegerField()
>>price = models.DecimalField(max_digits=10, decimal_places=2)
>>rating = models.FloatField()
>>pubdate = models.DateField()
>>
>> and I run the query:
>>
>> Book.objects.values('rating').annotate(books_per_rating=Count('id')).aggregate(Max(books_per_rating))
>>
>> I get a *DatabaseError*.
>>
>> According to this 
>> https://docs.djangoproject.com/en/1.5/topics/db/aggregation/#aggregating-annotations,
>>  
>> Django supports aggregating annotations. But in the example given in the 
>> link itself, they annotate over a *QuerySet* which in turn returns a *
>> QuerySet* (and not *ValuesQuerySet*), so aggregate method runs 
>> successfully. But in my example aggregating a *ValuesQuerySet* raises a *
>> DatabaseError*.
>>
>> Is it a bug in Django? Because if Django does not support aggregation 
>> over *ValuesQuerySet* then it should raise an exception at Django level 
>> (not *DatabaseError*).
>>
>>
>
> It returns an empty dict without performing any DB query!!
>
> On Friday, July 19, 2013 11:49:52 AM UTC+5:30, Debanshu Kundu wrote:
>>
>> If I have a model *Book* defined as:
>>
>> class Book(models.Model):
>>name = models.CharField(max_length=300)
>>pages = models.IntegerField()
>>price = models.DecimalField(max_digits=10, decimal_places=2)
>>rating = models.FloatField()
>>pubdate = models.DateField()
>>
>> and I run the query:
>>
>> Book.objects.values('rating').annotate(books_per_rating=Count('id')).aggregate(Max(books_per_rating))
>>
>> I get a *DatabaseError*.
>>
>> According to this 
>> https://docs.djangoproject.com/en/1.5/topics/db/aggregation/#aggregating-annotations,
>>  
>> Django supports aggregating annotations. But in the example given in the 
>> link itself, they annotate over a *QuerySet* which in turn returns a *
>> QuerySet* (and not *ValuesQuerySet*), so aggregate method runs 
>> successfully. But in my example aggregating a *ValuesQuerySet* raises a *
>> DatabaseError*.
>>
>> Is it a bug in Django? Because if Django does not support aggregation 
>> over *ValuesQuerySet* then it should raise an exception at Django level 
>> (not *DatabaseError*).
>>
>>

-- 
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: How to force modelForm.is_valid() to use a specific database?

2013-07-23 Thread Fellipe Henrique
The problem is: when usng modelForm, it try to validate the unique key in
the database, and this validation use a default database.. if I remove
primary_key=True in my model, work fine, but I need to set the pk in my
model, because when I try to get using: obj.get(xx)  show me error...


I try every think.. and I start to think is not possible multi-db in
"runtime" in django.. :(

T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

*Blog: http://fhbash.wordpress.com/*
*GitHub: https://github.com/fellipeh*
*Twitter: @fh_bash*


2013/7/23 Brian Millham 

> I've done that with this code:
>
> if form.is_valid():
>>   f = form.save(commit = False)
>>   f.save(using='yourdatabase')
>
>
> Works fine for me.
>
>
> On Tuesday, July 23, 2013 1:21:29 PM UTC-4, Fellipe Henrique wrote:
>>
>> I have many database setted in my setting.py   in my formModel, when I
>> try to validate the form, show me error:
>>
>> http://stackoverflow.com/**questions/17797419/modelforms-**
>> and-multiple-datasbase-error-**in-form-is-valid
>>
>> The problem is.. is_valid is going to "default" database... how can I
>> force to got to another database?
>>
>> Thanks.
>>
>  --
> 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: How to force modelForm.is_valid() to use a specific database?

2013-07-23 Thread Brian Millham
I've done that with this code:

if form.is_valid():
>   f = form.save(commit = False)
>   f.save(using='yourdatabase')


Works fine for me.


On Tuesday, July 23, 2013 1:21:29 PM UTC-4, Fellipe Henrique wrote:
>
> I have many database setted in my setting.py   in my formModel, when I try 
> to validate the form, show me error:
>
>
> http://stackoverflow.com/questions/17797419/modelforms-and-multiple-datasbase-error-in-form-is-valid
>
> The problem is.. is_valid is going to "default" database... how can I 
> force to got to another database?
>
> Thanks.
>

-- 
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.




How to force modelForm.is_valid() to use a specific database?

2013-07-23 Thread Fellipe Henrique
I have many database setted in my setting.py   in my formModel, when I try 
to validate the form, show me error:

http://stackoverflow.com/questions/17797419/modelforms-and-multiple-datasbase-error-in-form-is-valid

The problem is.. is_valid is going to "default" database... how can I force 
to got to another database?

Thanks.

-- 
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.




How can I upload async files with django-storages

2013-07-23 Thread Nicolas Bases
Hi all,

I'm doing a web site where the users can upload some images. These images
are uploaded through django-storages [0] to Amazon S3. But it's taking too
long to uploaded these files.

There is a way where I can upload these images async?

Thank you in advance!
Nicolas.

[0] http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html

-- 
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: Can I only have one "get_queryset" per Viewpage?

2013-07-23 Thread Mário Neto
Exactly @Babatundle =)


2013/7/23 Babatunde Akinyanmi 

> Override your get method but it's easier to override the get_context_data
> method like
> # From my head
> def get_context_data(**kwargs):
> context = super(IndexView, self).get_context_data(**kwargs)
> #filter1 is already present as latest_poll_list in the context
> filter2 = Word.blah()
> filter3 = Word.blah_blah()
> context.update({
> "filter2": filter2,
> "filter3": filter3
> })
> return context
>
> Sent from my Windows Phone
> --
> From: Pepsodent Cola
> Sent: 7/22/2013 9:47 PM
> To: django-users@googlegroups.com
> Subject: Re: Can I only have one "get_queryset" per Viewpage?
>
> I'm having difficulty understanding the abstract explanations in that
> documentation.
> Could you or somebody else explain this, by showing by example using my
> code examples?
>
> *views.py*
>
> class IndexView(generic.ListView):
> template_name = 'polls/index.html'
> context_object_name = *'latest_poll_list'*
>
> def get_queryset(self):
> """
> Return the last five published polls
> (not including those set to be published in the future).
> """
> return Word.objects.filter(
> pub_date__lte=timezone.now()
> ).order_by('-pub_date')[:5]
>
> *### Filter 2*
> #Word.objects.filter(translation='')
> *### Filter 3*
> #Pronunciation.objects.filter(wordfield__translation='')
>
>
>
>
> *index.html*
>
> index.html
>
> {% if latest_poll_list %}
> 
> {% for word in *latest_poll_list* %}
> {{ word.wordfield
> }}
> {% endfor %}
> 
> {% else %}
> No polls are available.
> {% endif %}
>
>
>
> How should I write my IndexView class so that Filter 1, 2 and 3 list
> results are then sent to my index.html template file?
>
>
>
>
> On Monday, July 22, 2013 2:03:59 PM UTC+2, macndesign wrote:
>>
>> Hi, you can separate your querysets in get_context_data method.
>> See:
>> https://docs.djangoproject.com/en/dev/ref/class-based-views/mixins-simple/#django.views.generic.base.ContextMixin.get_context_data
>>
>>
>> 2013/7/22 Pepsodent Cola 
>>
>>> Hi,
>>>
>>> Can I only have one "get_queryset" for each Viewpage?
>>> If I wanted to add another database list on the same Viewpage how would
>>> that code look like for my Django *views.py* file?
>>>
>>> Example:
>>> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#amend-views
>>>
>>> from polls.models import Choice, Poll
>>>
>>> class IndexView(generic.ListView):
>>> template_name = 'polls/index.html'
>>> *context_object_name = 'latest_poll_list'*
>>>
>>> *def get_queryset(self):*
>>> """Return the last five published polls."""
>>> return Poll.objects.order_by('-pub_date')[:5]
>>>
>>>
>>>
>>> I mean will "context_object_name" be able to separate between several
>>> "get_queryset(self)"?
>>> Because I want to have several different poll_lists on the same Viewpage.
>>>
>>> context_object_name = 'latest_poll_list'
>>>
>>>  --
>>> 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.
>>>
>>>
>>>
>>
>>
>>
>> --
>> Att. *Mário Araújo Chaves Neto*
>> *Programmer, Designer and U.I. Engineer*
>> *
>> *
>> *MBA in Design Digital* - 2008 - FIC
>> *Analysis and Systems Development* - 2011 - Estácio
>> *D**esign and Implementation of Internet Environments* - 2003 - FIC
>>
>  --
> 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.
>
>
>



-- 
Att. *Mário Araújo Chaves Neto*
*Programmer, Designer and U.I. Engineer*
*
*
*MBA in Design Digital* - 2008 - FIC
*Analysis and Systems Development* - 2011 - Estácio
*D**esign and Implementation of Internet Environments* - 2003 - FIC

-- 
You received this message because you are subscribed to 

Re: Foreign Key problems with legacy database

2013-07-23 Thread Nick Dokos
Avraham Serour  writes:

> you don't need songid = models.Integerfield()

... and the ForeignKey should not specify a db_column.

>
> On Tue, Jul 23, 2013 at 6:04 AM, Brian Millham  wrote:
>
> I have the following models:
>
> class Requestlist(models.Model):
>    id = models.IntegerField(primary_key=True)
>    songid = models.Integerfield()
>    song = ForeignKey('Song', db_column='songid')
> class Song(models.Model):
>   id = models.IntegerField(primary_key=True)
>   title = models.CharField(max_length=255L)
>
--
Nick

-- 
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: How to Create an Auto Incrementing Integer Field

2013-07-23 Thread Christian Erhardt
you are very welcome

-- 
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: Foreign Key problems with legacy database

2013-07-23 Thread Avraham Serour
you don't need songid = models.Integerfield()


On Tue, Jul 23, 2013 at 6:04 AM, Brian Millham  wrote:

> I have the following models:
>
> class Requestlist(models.Model):
>>id = models.IntegerField(primary_key=True)
>>songid = models.Integerfield()
>>song = ForeignKey('Song', db_column='songid')
>> class Song(models.Model):
>>   id = models.IntegerField(primary_key=True)
>>   title = models.CharField(max_length=255L)
>
>
> The relation should be Requestlist.songid = Song.id
>
> The above models seem to work for querying, but when I create a new
> requestlist, via a form, then I get the error that: Column songid specified
> twice.
>
> If I remove the ForeignKey, I can save the requestlist, but obviously I
> lose the relations.
>
> I've tried replacing the db_column='songid' with to_field='id' but that's
> worse. The relation then totally breaks.
>
> It's gotta be something simple that I'm overlooking
>
> Thanks!
>
> --
> 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: Can I only have one "get_queryset" per Viewpage?

2013-07-23 Thread Babatunde Akinyanmi
Override your get method but it's easier to override the get_context_data
method like
# From my head
def get_context_data(**kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
#filter1 is already present as latest_poll_list in the context
filter2 = Word.blah()
filter3 = Word.blah_blah()
context.update({
"filter2": filter2,
"filter3": filter3
})
return context

Sent from my Windows Phone
--
From: Pepsodent Cola
Sent: 7/22/2013 9:47 PM
To: django-users@googlegroups.com
Subject: Re: Can I only have one "get_queryset" per Viewpage?

I'm having difficulty understanding the abstract explanations in that
documentation.
Could you or somebody else explain this, by showing by example using my
code examples?

*views.py*

class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = *'latest_poll_list'*

def get_queryset(self):
"""
Return the last five published polls
(not including those set to be published in the future).
"""
return Word.objects.filter(
pub_date__lte=timezone.now()
).order_by('-pub_date')[:5]

*### Filter 2*
#Word.objects.filter(translation='')
*### Filter 3*
#Pronunciation.objects.filter(wordfield__translation='')




*index.html*

index.html

{% if latest_poll_list %}

{% for word in *latest_poll_list* %}
{{ word.wordfield
}}
{% endfor %}

{% else %}
No polls are available.
{% endif %}



How should I write my IndexView class so that Filter 1, 2 and 3 list
results are then sent to my index.html template file?




On Monday, July 22, 2013 2:03:59 PM UTC+2, macndesign wrote:
>
> Hi, you can separate your querysets in get_context_data method.
> See:
> https://docs.djangoproject.com/en/dev/ref/class-based-views/mixins-simple/#django.views.generic.base.ContextMixin.get_context_data
>
>
> 2013/7/22 Pepsodent Cola 
>
>> Hi,
>>
>> Can I only have one "get_queryset" for each Viewpage?
>> If I wanted to add another database list on the same Viewpage how would
>> that code look like for my Django *views.py* file?
>>
>> Example:
>> https://docs.djangoproject.com/en/1.5/intro/tutorial04/#amend-views
>>
>> from polls.models import Choice, Poll
>>
>> class IndexView(generic.ListView):
>> template_name = 'polls/index.html'
>> *context_object_name = 'latest_poll_list'*
>>
>> *def get_queryset(self):*
>> """Return the last five published polls."""
>> return Poll.objects.order_by('-pub_date')[:5]
>>
>>
>>
>> I mean will "context_object_name" be able to separate between several
>> "get_queryset(self)"?
>> Because I want to have several different poll_lists on the same Viewpage.
>>
>> context_object_name = 'latest_poll_list'
>>
>>  --
>> 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.
>>
>>
>>
>
>
>
> --
> Att. *Mário Araújo Chaves Neto*
> *Programmer, Designer and U.I. Engineer*
> *
> *
> *MBA in Design Digital* - 2008 - FIC
> *Analysis and Systems Development* - 2011 - Estácio
> *D**esign and Implementation of Internet Environments* - 2003 - FIC
>
 --
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.