Re: Django help required with non foreign key relations

2012-04-23 Thread akaariai
On Apr 23, 8:15 am, Aditya Sriram M  wrote:
> Ohh this looks little promising..
>
> However,
>
>    1. I need a few cols of table1 and few from table 2 to be displayed. How
>    can we achieve that at the .filter() level? and
>    2. At the view level like using the list_display () for displaying them
>    in the Admin interface

If you want to get results just define the ForeignKey (or OneToOneKey)
in your Customer or User model. After this .select_related
and .prefetch_related should solve the problems you are currently
facing.

If you can't define that ForeignKey for one reason or another you need
a lot more knowledge of how Django works. All the things you need to
do are too numerous to handle in a django-users post. It is possible
there will be some problems which are very hard to solve along this
path.

In short, I recommend to just define the relation between the models.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread akaariai
On Monday, April 23, 2012 1:56:19 AM UTC+3, Russell Keith-Magee wrote:
>
> It's also probable that it's something that is new to 1.4 (or, at least, 
> that it manifests in slightly different ways in 1.4). One of the features 
> added in 1.4 is bulk insertion of data. This means that you can use a 
> single SQL statement to insert all your m2m relation; however, the downside 
> is that on SQLite, there is a limit of 500 insertions that can be done at 
> any one time (2 values per insertion).
>
> This is logged as ticket #17788. There have been some discussions about a 
> fix for this problem that will break the bulk insertion into batches. I 
> suspect that when this problem is fixed, your problem will go away.
>
There are at least three different instances of the 1000 variables problem. 
One is the bulk_create() which is likely to get fixed. Then there is 
delete(). This might get fixed. The last one is 
qs.filter(id__in=large_list) which will not get fixed.

The reason for fixing bulk_create() is that it is somewhat easy to do so. 
Just split the batch of objects into smaller batches and iterate. delete() 
isn't as easy, but the same split + iterate approach could work. If it gets 
too complicated then it will not be fixed, if it is easy then it might get 
fixed. The last one, qs.filter(id__in=large_list) is pretty much impossible 
to fix. The reason is you can't split that query into multiple parts. Or 
not for any non-trivial query anyways. For example ORDER BY is enough to 
break any attempt to split the query into parts.

While Django's ORM should hide limitations in the underlying database it 
can't do it perfectly. My viewpoint is that Django should hide limitations 
if it is easy to do so. It is all about cost-benefit ratio.

For your particular problem you have at least these choices:
  1. Use different database. I guess you have a reason to use SQLite so 
this might not be an option.
  2. Compile SQLite yourself with a higher parameter limit. If you need to 
deploy your software on multiple machines this might be hard to do.
  3. Work around the issues in your code. Maybe a ModelMultipleChoiceField 
subclass which does the .clean() in a safe way would work. Or better yet do 
as Russell said: try to remove the need to have 1000 options in one field 
altogether.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/QtYFVgICbC8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Logging in by Email isn't responding

2012-04-23 Thread Mai
here i guess i wrote Every thing to be able to log in by mail but it's
not working is there something missing please? and
AUTHENTICATION_BACKENDS = (
'mayapp.backends.EmailAuthBackend',
'django.contrib.auth.backends.ModelBackend'
)


backends.py


from django.conf import settings
from django.contrib.auth.backends import ModelBackend
from django.core.validators import email_re
from django.contrib.auth.models import User, check_password

# Overwrite the default backend to check for e-mail address
class EmailAuthBackend(object):
"""
Email Authentication Backend

Allows a user to sign in using an email/password pair rather than
a username/password pair.
"""

def authenticate(self, username=None, password=None):
""" Authenticate a user based on email address as the user
name. """
try:
user = User.objects.get(email=username)
if user.check_password(password):
return user
except User.DoesNotExist:
return None

def get_user(self, user_id):
""" Get a User object from the user_id. """
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None


views.py



def login_user(request):
state = "Please log in below..."
username = password = ''
if request.POST:
if 'login' in request.POST:
username = request.POST.get('username')
password = request.POST.get('password')

user = authenticate(username=username, 
password=password)
if user is not None:
if user.is_active:
login(request, user)
state = "You're successfully logged in!"

return 
render_to_response('master.html',RequestContext(request))
else:
state = "Your account is not active, 
please contact the site
admin."
else:
state = "Your username and/or password were 
incorrect."
elif 'signup' in request.POST:
form= SignUpForm()
context = {'form':form}
return
render_to_response('Sign_up_Employer.html',context,context_instance=RequestContext(request))



return render_to_response('login.html',{'state':state, 'username':
username},RequestContext(request))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Cross domain cookie to extract csrf token

2012-04-23 Thread Luther Goh Lu Feng
I have managed to resolve the issue. This only works on phonegap,
chrome 20 but not on desktop safari 5.1.5.

General strategy:
- Make an ajax OPTIONS call to http://foo
- Generate the csrf token and return it in the success callback
- Extract the csrf token
- In the success callback do the ajax post, and set the request header
with the csrf token using xhr.setRequestHeader("X-CSRFToken", token)
- In the middleware you will need to enable CORS and accept the
csrftoken headder

Desktop safari seemed to fail as it was unable to return the cookie in
the ajax post call

This is in django 1.4 and with the view decorators:

@ensure_csrf_cookie
@require_http_methods(["OPTIONS", "POST"])

On Apr 22, 2:57 am, Luther Goh Lu Feng  wrote:
> I am running a website on local host (my mac, ip 127.0.0.1) and my
> django dev server on a VM (some other ip eg. 192.168.56.1).
>
> I load up the local host website, which 'emulates' the mobile app that
> I will build using phonegap. I am issuing ajax requests from the
> website to the django application residing in the VM.
>
> The views that the requests are routed to are not csrf exempt. As
> such, I issue a get request on the local website to try and obtain the
> csrf token:
>
> $.get('http://127.0.0.1:8000/login')
>
> In the response headers, the following is returned:
> Set-Cookie:csrftoken=82c34b2495ad0c7f8a5fed67ca9a21bd; expires=Sat, 20-
> Apr-2013 05:20:20 GMT; Max-Age=31449600; Path=/
>
> However, this is unfortunately not found in document.cookie.
>
> I would like to ask for advice on how I can get around this problems.
>
> Thanks in advance,
>
> Luther

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



restarting a django development server

2012-04-23 Thread dummyman dummyman
how to restart a django development server programmatically in python ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread Javier Guerra Giraldez
On Mon, Apr 23, 2012 at 3:58 AM, akaariai  wrote:
> The last one, qs.filter(id__in=large_list) is pretty much impossible to fix.

what's wrong with:

qs.filter((Q(id__in=large_list[:n])|Q(id__in=large_list[n:])))  ?

>   1. Use different database. I guess you have a reason to use SQLite so this
> might not be an option.

Oracle has a 1000-element limit for the IN ()  clause.  Of course,
it does work with (IN(<1sthalf>) or IN(<2ndhalf>))

-- 
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread akaariai
On Apr 23, 1:43 pm, Javier Guerra Giraldez  wrote:
> On Mon, Apr 23, 2012 at 3:58 AM, akaariai  wrote:
> > The last one, qs.filter(id__in=large_list) is pretty much impossible to fix.
>
> what's wrong with:
>
> qs.filter((Q(id__in=large_list[:n])|Q(id__in=large_list[n:])))  ?
>
> >   1. Use different database. I guess you have a reason to use SQLite so this
> > might not be an option.
>
> Oracle has a 1000-element limit for the IN ()  clause.  Of course,
> it does work with (IN(<1sthalf>) or IN(<2ndhalf>))

SQLite has the limit for the whole query, Oracle for just one IN
clause. For Oracle we already do that split. For SQLite we would need
to split the _whole query_ into two parts (that is, run
two .exectutes()) and then "join" the parts in Python. The joining in
Python is the hard part.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Loading static files from a dev environment

2012-04-23 Thread gnesher
I'm having an odd problem with my test Django environment.

It seems that static filles I've collected from different apps using
the collectstatic command works fine, while other static files I
placed in myself result in 404 error. This can happen from the same
directory (where a png that was collected will load, but a png i just
drop in will fail).

all files have the same permissions, and I can't figure out why this
would happen. I'm currently able to solve this by serving the files
through ngnix - but I really shouldn't need to do that.

Any ideas why this might be happening ?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django static files STATIC_ROOT vs STATICFILES_FINDERS

2012-04-23 Thread gnesher
Hi,

I'm not sure if this is a bug or am I missing something but I've
created a very simple test environment and placed a single png file
within my static folder.

The file is being served fine when I set :
STATIC_ROOT = ''
STATICFILES_DIRS = (
'/Users/guynesher/Work/play/quicktest/testproj/static/',
)

however I'm geting a 404 error when I set it like this :
STATIC_ROOT = '/Users/guynesher/Work/play/quicktest/testproj/static/'
STATICFILES_DIRS = (
)

Based on the STATICFILES_DIRS comment (Additional locations of static
files) I expected I will only need to use it if I have multiple static
files directory which doesn't seem to be the case.

What am I missing here?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django static files STATIC_ROOT vs STATICFILES_FINDERS

2012-04-23 Thread Philip Mountifield

There is a slight difference:

 * STATIC_ROOT is where you would like the files to be collected to
   when you run "manage.py collectstatic" and should be empty to begin
   with.
 * STATICFILES_DIRS is where the actual files are located and they will
   be automagically servered under the development server.
 * You can also create a folder called "static" in any app and put
   files in there.

Regards
Phil


On 23/04/2012 12:32, gnesher wrote:

Hi,

I'm not sure if this is a bug or am I missing something but I've
created a very simple test environment and placed a single png file
within my static folder.

The file is being served fine when I set :
STATIC_ROOT = ''
STATICFILES_DIRS = (
 '/Users/guynesher/Work/play/quicktest/testproj/static/',
)

however I'm geting a 404 error when I set it like this :
STATIC_ROOT = '/Users/guynesher/Work/play/quicktest/testproj/static/'
STATICFILES_DIRS = (
)

Based on the STATICFILES_DIRS comment (Additional locations of static
files) I expected I will only need to use it if I have multiple static
files directory which doesn't seem to be the case.

What am I missing here?




--

Philip Mountifield
Formac Electronics Ltd
tel  +44 (0) 1225 837333
fax  +44 (0) 1225 430995

pmountifi...@formac.net
www.formac.net
www.telgas.net

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: keep models simple ? where to put the business logic ?

2012-04-23 Thread bruno desthuilliers
On Apr 22, 7:51 pm, Michael Palumbo 
wrote:
> Hi,
>
> I know this has already been discussed several times, I found several posts
> about it through Google but I'm still interested in getting your opinion on
> an example.
>
> I'm wondering that because my models file is getting big. That makes me
> confused so I'm wondering if I'm doing the right thing from a design point
> of view.
> I have the feeling that my models should remain simple. What do you think ?

https://www.google.com/search?q=anemic+domain+model

> For example, let's say I want to create a model named Feed. (simplified
> version)
> class Feed(models.Model):
>     name = models.CharField(max_length=255, unique=True)
>     url = models.URLField(unique=True)
>     etag = models.CharField(max_length=255, null=True, blank=True)
>
> I want to be able to extract a feed (that is to say to download it and
> store it(as a file but I also keep a track in the DB through a File
> model)). Would you create:
> - an extract method in the model

That's probably what I would do.

>
> - a view:

Nope. The view should just deal with user interactions (in this case,
allow a user to launch the extraction).

FWIW, a part of the Django code I see suffer from this problem (anemic
domain, and anemic forms to), and it's a major PITA when you want to
extend such a code, because you have business logic and user
interaction logic deeply mixed in the views for no good reason.


> - a "util" function to whom I pass the Feed object.
> f = Feed.objects.get(pk=1)
> utils.extract_feed(f)

How is this better than having the very same function being a method
of the model ?

Models - like any other module - should indeed be "as simple as
possible", _but not simpler_. If you concern is about your models.py
file size, it might be time to refactor it into a package.

Now if there are parts of your methods that are low-level enough and
don't really need to know about your models, yeps, they may belong to
some "model-agnostic" utility module. Refactoring methods this way can
help keeping the method code hi-level and readable.

My 2 cents

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: request.is_ajax() not working

2012-04-23 Thread psychok7
yes i did that now, and still doesnt work.. it still returns false and 
doesnt print the line after request.is_ajax()

On Monday, April 23, 2012 4:36:06 AM UTC+1, Amao wrote:
>
> dear psychok7:
> You have no data from your ajax post, you should post some data with 
> your ajax post, like this 
> $.post("api/newdoc/", {'user':'your username'}, function(data) {
> alert(data);
> });
> }
>
> 在 2012年4月23日星期一,psychok7 写道:
>
>> hi there i am trying a simple example using AJAX, DJANGO, JQUERY, JSON 
>> and my if request.is_ajax() is not working for some reason.. here is my 
>> code:
>>
>> URLS: (r'api/newdoc/$', 'rose_miracle.views.newdoc'),
>>
>> VIEW:
>> def newdoc(request):
>> # only process POST request
>> print "entrei"
>> if request.is_ajax():
>> print "entrei2" _#this is not working
>> data= dict(request.POST)
>> print data
>> # save data to db
>>
>> return HttpResponse(simplejson.dumps([True]))
>> 
>> return HttpResponse(simplejson.dumps([False]))
>>
>> js:
>> $(document).ready(function(){
>> 
>>
>> alert("ya");
>> $.post("api/newdoc/", function(data) {
>> alert(data);
>> });
>> }
>>
>>
>> i added this in a file as well, dont know how it works though 
>> https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax
>>
>> the print in my request.is_ajax()  is now working, what im i doing wrong??
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/J9sGcOB5wBwJ.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/VLZFfoW8PtAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django static files STATIC_ROOT vs STATICFILES_FINDERS

2012-04-23 Thread gnesher
But then shouldn't I expect the files to be served from the
STATIC_ROOT as well ?


On Apr 23, 12:38 pm, Philip Mountifield 
wrote:
> There is a slight difference:
>
>   * STATIC_ROOT is where you would like the files to be collected to
>     when you run "manage.py collectstatic" and should be empty to begin
>     with.
>   * STATICFILES_DIRS is where the actual files are located and they will
>     be automagically servered under the development server.
>   * You can also create a folder called "static" in any app and put
>     files in there.
>
> Regards
> Phil
>
> On 23/04/2012 12:32, gnesher wrote:
>
>
>
>
>
>
>
>
>
> > Hi,
>
> > I'm not sure if this is a bug or am I missing something but I've
> > created a very simple test environment and placed a single png file
> > within my static folder.
>
> > The file is being served fine when I set :
> > STATIC_ROOT = ''
> > STATICFILES_DIRS = (
> >      '/Users/guynesher/Work/play/quicktest/testproj/static/',
> > )
>
> > however I'm geting a 404 error when I set it like this :
> > STATIC_ROOT = '/Users/guynesher/Work/play/quicktest/testproj/static/'
> > STATICFILES_DIRS = (
> > )
>
> > Based on the STATICFILES_DIRS comment (Additional locations of static
> > files) I expected I will only need to use it if I have multiple static
> > files directory which doesn't seem to be the case.
>
> > What am I missing here?
>
> --
>
> Philip Mountifield
> Formac Electronics Ltd
> tel  +44 (0) 1225 837333
> fax  +44 (0) 1225 430995
>
> pmountifi...@formac.netwww.formac.netwww.telgas.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to syncdb programatically (django standalone script) ?

2012-04-23 Thread Fábio Santos
There's a problem in your INSTALLED_APPS setting. You have to use:

('polls',)

Notice the trailing comma. When writing tuples with one item, you must have 
a traling comma. It indicates that you are writing a tuple, and not simply 
an expression enclosed in parenthesis. A workaround is to use a list 
instead, thus ['polls'].

Django will try to iterate INSTALLED_APPS and import all the modules there, 
in order to do its magic. If you iterate ('polls') you get every character 
in the string.


Segunda-feira, 15 de Setembro de 2008 22:51:59 UTC+1, Mathieu Leplatre 
escreveu:
>
> Hi all, 
>
> I found many post about specific errors regarding django as a 
> standalone tool. 
>
> With a little bit of researching, I ended up with this script below. 
> Unfortunately, it fails on database initialization. 
>
> ... 
> ... 
>  File "/home/mathieu/Code/uhm/svn/uhm/django/db/backends/sqlite3/ 
> base.py", line 167, in execute 
>return Database.Cursor.execute(self, query, params) 
>sqlite3.OperationalError: no such table: polls_poll 
>
> The sqlite file is empty (0 byte). How can I syncdb programatically 
> (and only once) ? 
>
> Thanks ! 
>
>
> import datetime 
> from django.conf import settings 
> settings.configure( DATABASE_ENGINE = "sqlite3", 
> DATABASE_NAME   = "./polls.db", 
> INSTALLED_APPS = ('polls')) 
> from django.db import models 
>
> class Poll(models.Model): 
> question = models.CharField(max_length=200) 
> pub_date = models.DateTimeField('date published') 
> class Meta: 
> app_label = "polls" 
>
> p = Poll(question="What's up?", pub_date=datetime.datetime.now()) 
> p.save()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/pTDF6QVEdJAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread Lukas Zilka
Hey Russ,

thanks for your reply. I looked at the bulk insertion problem, and
that made me think that probably using the variables themselves is the
problem. It does not really make sense to me why anybody bothers to
use variables in a long SQL query for the IN clause, let alone a bulk
insertion? Does that benefit anything?

Anyway, I conducted an experiment and tried a simple SQL query with
lots of items in the IN clause to prove that its the variables
themselves, not the limitation of IN clause in SQLite, is whats
causing the problem. I have been successfully able to execute a query
as "SELECT * FROM projects WHERE id IN (...)" where on the place of
`...` there were 15,000 numbers. So SQLite has no problem with lot of
stuff as an argument of the IN operator. Now, the only limitation is
the length of the SQL query itself. According to the SQLite
documentation it is 1megabyte, and that suffices for 100k+ elements.
With that big query, you are right, it would be very impractical and
slow for the end users to interact with the application (sending 1M of
data to the webserver will probably be very unresponsive), so I think
this is a fair limitation that should never be exceeded for this use.

In Django code it seems that it would suffice to make a change in the
file 'db/models/sql/where.py'. Particularly, condition on the number
of elements of IN, and, if it is over let's say 100 of them, put them
into the SQL query directly as a string (e.g. '1,2,3') - not as
variables('?, ?, ?').

Though, for the future, I still believe there should be a better
solution than to rely on not reaching this limit. I would propose that
a temporary table should be created, filled up with the right
arguments of IN operator, and the query rewritten as a JOIN on the
original left argument of IN (or for simplicity, and perhaps worse
performance, a nested query) and this temporary table. That of course
only if the number of elements on the right side of IN is more than
some number. But this is for another discussion.

My question is therefore: Will the change in Django code that I
propose have any bad consequences or do you think it might actually
work satisfactorily?

Thanks.

Best,
Lukas

On Apr 23, 12:56 am, Russell Keith-Magee 
wrote:
> Hi Lukas,
>
> I haven't looked into the problem in detail, but it doesn't surprise me that 
> it exists.
>
> It's also probable that it's something that is new to 1.4 (or, at least, that 
> it manifests in slightly different ways in 1.4). One of the features added in 
> 1.4 is bulk insertion of data. This means that you can use a single SQL 
> statement to insert all your m2m relation; however, the downside is that on 
> SQLite, there is a limit of 500 insertions that can be done at any one time 
> (2 values per insertion).
>
> This is logged as ticket #17788. There have been some discussions about a fix 
> for this problem that will break the bulk insertion into batches. I suspect 
> that when this problem is fixed, your problem will go away.
>
> That said, I would also suggest you have a think about how you represent this 
> widget in your UI. The approach you're describing is going to be very slow 
> for the end user -- every time they load the page, they're going to have to 
> download the HTML for a widget 1000 choices; when they send their selections, 
> they're going to have to POST up to 1000 choices back to the server. This all 
> takes time, and won't result in a particularly responsive web page.
>
> If you've got a situation where there are 1000 options, but usually only a 
> small number -- say, O(10) -- are selected, then perhaps an AJAX autocomplete 
> widget of some kind would be a better approach. If the user is going to 
> select a lot more options, then you might need to use a more exotic widget 
> that avoids the need to transfer full lists back and forth.
>
> Yours,
> Russ Magee %-)
>
>
>
>
>
>
>
> On Monday, 23 April 2012 at 5:38 AM, Lukas Zilka wrote:
> > Hello,
>
> > I have a form with ModelMultipleChoiceField on it, and I am getting
> > 'DatabaseError: too many SQL variables' (using SQLite) when the user
> > picks more than 1000 entries in the selection widget and posts the
> > form.
>
> > The problem seems to be the method clean of ModelMultipleChoiceField,
> > which tries to select objects from the database simply by the IN SQL
> > clause (e.g. SELECT * FROM projects WHERE id IN (1,2,3)). When the
> > number of numbers in the IN argument rises over 1000 the too many SQL
> > variables happens.
>
> > I am using the most recent version of Django (1.5.dev17922), though I
> > think it is irrelevant because similar issues happened even with older
> > versions.
>
> > I have always worked around this problem by custom temporary models
> > that I used for joins of more complex queries. But more and more it
> > seems to me that, either there already is a systematic solution to
> > this problem that I am missing (which I hope somebody could point out
> > to me), or there at least nee

Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread Lukas Zilka
Thanks for your reply Anssi.

My previous post probably got lost somewhere (or maybe just awaiting 
moderation?), so I am going to repeat the relevant part. It is related with 
your point on qs.filter(id__in=large_list), so I will try to say it again.

Why do you use SQL variables when you construct query for the IN operator? 
It does not make sense to me for both -- bulk inserts (which you are 
currently solving), as well as the IN operator -- or at least not for 
integer arguments. I think there is no limit on the IN clause argument size 
in SQLite and for databases where there is, it could be solved by breaking 
it into OR clauses, as is already done). A simple solution for the IN 
operator problems would be to change the Django code in 
db/models/sql/where.py in a way that it puts the parameters into the SQL 
query straight away instead of as parameters, e.g.:
201:return ('%s IN (%s)' % (field_sql,
202:', '.join(repeat('%s', 
len(params))) % tuple(params)) , ())

This worked for my particular case. The only limitation that can be reached 
is a 1MB size limit on query in SQLite. Is this going to break anything?

Best, 
Lukas


On Monday, April 23, 2012 10:58:19 AM UTC+2, akaariai wrote:
>
> On Monday, April 23, 2012 1:56:19 AM UTC+3, Russell Keith-Magee wrote:
>>
>> It's also probable that it's something that is new to 1.4 (or, at least, 
>> that it manifests in slightly different ways in 1.4). One of the features 
>> added in 1.4 is bulk insertion of data. This means that you can use a 
>> single SQL statement to insert all your m2m relation; however, the downside 
>> is that on SQLite, there is a limit of 500 insertions that can be done at 
>> any one time (2 values per insertion).
>>
>> This is logged as ticket #17788. There have been some discussions about a 
>> fix for this problem that will break the bulk insertion into batches. I 
>> suspect that when this problem is fixed, your problem will go away.
>>
> There are at least three different instances of the 1000 variables 
> problem. One is the bulk_create() which is likely to get fixed. Then there 
> is delete(). This might get fixed. The last one is 
> qs.filter(id__in=large_list) which will not get fixed.
>
> The reason for fixing bulk_create() is that it is somewhat easy to do so. 
> Just split the batch of objects into smaller batches and iterate. delete() 
> isn't as easy, but the same split + iterate approach could work. If it gets 
> too complicated then it will not be fixed, if it is easy then it might get 
> fixed. The last one, qs.filter(id__in=large_list) is pretty much impossible 
> to fix. The reason is you can't split that query into multiple parts. Or 
> not for any non-trivial query anyways. For example ORDER BY is enough to 
> break any attempt to split the query into parts.
>
> While Django's ORM should hide limitations in the underlying database it 
> can't do it perfectly. My viewpoint is that Django should hide limitations 
> if it is easy to do so. It is all about cost-benefit ratio.
>
> For your particular problem you have at least these choices:
>   1. Use different database. I guess you have a reason to use SQLite so 
> this might not be an option.
>   2. Compile SQLite yourself with a higher parameter limit. If you need to 
> deploy your software on multiple machines this might be hard to do.
>   3. Work around the issues in your code. Maybe a ModelMultipleChoiceField 
> subclass which does the .clean() in a safe way would work. Or better yet do 
> as Russell said: try to remove the need to have 1000 options in one field 
> altogether.
>
>  - Anssi
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/95QFVjj5QosJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Jdango - What IDE to use?

2012-04-23 Thread Joel Goldstick
On Sun, Apr 22, 2012 at 12:59 PM, Aaron C. de Bruyn  wrote:
> This has been asked eleventy bajillion times, but I don't see a wiki
> page on it?  :)
>
> I'd be happy to dig through the archives and compile a list if there's
> no objection.
>
> Would there be a problem including for-pay IDEs?  (For example I use
> PyCharm from time to time)
>
> Any wiki managers or people with the commit bit object to me adding an
> 'IDE' section here?
> https://code.djangoproject.com/wiki/DjangoResources
>
> -A
>
> On Sat, Apr 21, 2012 at 11:47, yati sagade  wrote:
>> You counted it wrong. Add one more zero ;-)
>>
>>
>> On Sat, Apr 21, 2012 at 11:48 PM, Shawn Milochik  wrote:
>>>
>>> There are eleventy bajillion discussions on this already.
>>>
>>> Please search the group history on Google Groups.
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>>
>> --
>> Yati Sagade
>>
>> Twitter: @yati_itay
>>
>> Organizing member of TEDx EasternMetropolitanBypass
>> http://www.ted.com/tedx/events/4933
>> https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
There is always gedit or vim with a couple of browser tabs open to the
djangobook and djangoproject


-- 
Joel Goldstick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Ways to handle long-running server-side processing in Django

2012-04-23 Thread bruno desthuilliers
On Apr 21, 11:34 pm, David Markey  wrote:
> Sounds like the API should return a UUID that can then be used to poll,
> while celery or similar does the heavy lifting in the background?

+1

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Jdango - What IDE to use?

2012-04-23 Thread Timothy Makobu
If you can spare a few bux, get PyCharm. It's the best.

On Mon, Apr 23, 2012 at 2:51 PM, Joel Goldstick wrote:

> On Sun, Apr 22, 2012 at 12:59 PM, Aaron C. de Bruyn 
> wrote:
> > This has been asked eleventy bajillion times, but I don't see a wiki
> > page on it?  :)
> >
> > I'd be happy to dig through the archives and compile a list if there's
> > no objection.
> >
> > Would there be a problem including for-pay IDEs?  (For example I use
> > PyCharm from time to time)
> >
> > Any wiki managers or people with the commit bit object to me adding an
> > 'IDE' section here?
> > https://code.djangoproject.com/wiki/DjangoResources
> >
> > -A
> >
> > On Sat, Apr 21, 2012 at 11:47, yati sagade 
> wrote:
> >> You counted it wrong. Add one more zero ;-)
> >>
> >>
> >> On Sat, Apr 21, 2012 at 11:48 PM, Shawn Milochik 
> wrote:
> >>>
> >>> There are eleventy bajillion discussions on this already.
> >>>
> >>> Please search the group history on Google Groups.
> >>>
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Django users" group.
> >>> To post to this group, send email to django-users@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> django-users+unsubscr...@googlegroups.com.
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/django-users?hl=en.
> >>>
> >>
> >>
> >>
> >> --
> >> Yati Sagade
> >>
> >> Twitter: @yati_itay
> >>
> >> Organizing member of TEDx EasternMetropolitanBypass
> >> http://www.ted.com/tedx/events/4933
> >>
> https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/337763226244869
> >>
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/django-users?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
> There is always gedit or vim with a couple of browser tabs open to the
> djangobook and djangoproject
>
>
> --
> Joel Goldstick
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django static files STATIC_ROOT vs STATICFILES_FINDERS

2012-04-23 Thread Philip Mountifield
It depends how you are running. When using "manage.py runserver" it 
serves the static files for you, without even needing to collect them 
IIRC. But when deploying, you have to run "manage.py collectstatic" and 
Django collects all the files from the other locations for you and puts 
them in STATIC_ROOT, which you would configure your webserver to serve 
at STATIC_URL. The docs are pretty clear on this:


https://docs.djangoproject.com/en/1.4/howto/static-files/

Regards
Phil

On 23/04/2012 12:49, gnesher wrote:

But then shouldn't I expect the files to be served from the
STATIC_ROOT as well ?


On Apr 23, 12:38 pm, Philip Mountifield
wrote:

There is a slight difference:

   * STATIC_ROOT is where you would like the files to be collected to
 when you run "manage.py collectstatic" and should be empty to begin
 with.
   * STATICFILES_DIRS is where the actual files are located and they will
 be automagically servered under the development server.
   * You can also create a folder called "static" in any app and put
 files in there.

Regards
Phil

On 23/04/2012 12:32, gnesher wrote:










Hi,
I'm not sure if this is a bug or am I missing something but I've
created a very simple test environment and placed a single png file
within my static folder.
The file is being served fine when I set :
STATIC_ROOT = ''
STATICFILES_DIRS = (
  '/Users/guynesher/Work/play/quicktest/testproj/static/',
)
however I'm geting a 404 error when I set it like this :
STATIC_ROOT = '/Users/guynesher/Work/play/quicktest/testproj/static/'
STATICFILES_DIRS = (
)
Based on the STATICFILES_DIRS comment (Additional locations of static
files) I expected I will only need to use it if I have multiple static
files directory which doesn't seem to be the case.
What am I missing here?

--

Philip Mountifield
Formac Electronics Ltd
tel  +44 (0) 1225 837333
fax  +44 (0) 1225 430995

pmountifi...@formac.netwww.formac.netwww.telgas.net



--

Philip Mountifield
Formac Electronics Ltd
tel  +44 (0) 1225 837333
fax  +44 (0) 1225 430995

pmountifi...@formac.net
www.formac.net
www.telgas.net

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Jdango - What IDE to use?

2012-04-23 Thread kenneth gonsalves
On Mon, 2012-04-23 at 14:54 +0300, Timothy Makobu wrote:
> If you can spare a few bux, get PyCharm. It's the best.

they give open source licenses for free.
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Jdango - What IDE to use?

2012-04-23 Thread Timothy Makobu
I have one of those actually, but that's coz I have a project that's been
around a while. They actually checked out the googlecode page.

On Mon, Apr 23, 2012 at 3:00 PM, kenneth gonsalves
wrote:

> On Mon, 2012-04-23 at 14:54 +0300, Timothy Makobu wrote:
> > If you can spare a few bux, get PyCharm. It's the best.
>
> they give open source licenses for free.
> --
> regards
> Kenneth Gonsalves
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Distributing Django apps

2012-04-23 Thread Steve Kilbane
Hi all,

I'm new to Python. I'm in the process of developing an open-source
app. Is there a guide for packaging up and distributing Django apps?
Or is it just a matter of copying the relevant files?

steve

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread akaariai


On Apr 23, 10:48 am, Lukas Zilka  wrote:
> Hey Russ,
>
> thanks for your reply. I looked at the bulk insertion problem, and
> that made me think that probably using the variables themselves is the
> problem. It does not really make sense to me why anybody bothers to
> use variables in a long SQL query for the IN clause, let alone a bulk
> insertion? Does that benefit anything?
>
> Anyway, I conducted an experiment and tried a simple SQL query with
> lots of items in the IN clause to prove that its the variables
> themselves, not the limitation of IN clause in SQLite, is whats
> causing the problem. I have been successfully able to execute a query
> as "SELECT * FROM projects WHERE id IN (...)" where on the place of
> `...` there were 15,000 numbers. So SQLite has no problem with lot of
> stuff as an argument of the IN operator. Now, the only limitation is
> the length of the SQL query itself. According to the SQLite
> documentation it is 1megabyte, and that suffices for 100k+ elements.
> With that big query, you are right, it would be very impractical and
> slow for the end users to interact with the application (sending 1M of
> data to the webserver will probably be very unresponsive), so I think
> this is a fair limitation that should never be exceeded for this use.
>
> In Django code it seems that it would suffice to make a change in the
> file 'db/models/sql/where.py'. Particularly, condition on the number
> of elements of IN, and, if it is over let's say 100 of them, put them
> into the SQL query directly as a string (e.g. '1,2,3') - not as
> variables('?, ?, ?').
>
> Though, for the future, I still believe there should be a better
> solution than to rely on not reaching this limit. I would propose that
> a temporary table should be created, filled up with the right
> arguments of IN operator, and the query rewritten as a JOIN on the
> original left argument of IN (or for simplicity, and perhaps worse
> performance, a nested query) and this temporary table. That of course
> only if the number of elements on the right side of IN is more than
> some number. But this is for another discussion.
>
> My question is therefore: Will the change in Django code that I
> propose have any bad consequences or do you think it might actually
> work satisfactorily?

First the "write the query as "1, 2, 3", not as "%s, %s, %s", (1, 2,
3). The problem is SQL injection. You could do that for integer
parameters easily, but on the whole it is not a nice way.

The create temp table + join seems hard. But you could do "exists"
query instead. A query like "select * from tbl where id in (a list)"
could be rewritten to "select * from tbl where exists (select 1 from
temp_table where temp_table.id = tbl.id)". This could be handled in
sql/where.py somewhat easily.

For me this issue isn't that important. I don't use SQLite except for
testing. If somebody wants to work on this issue, I must warn that it
is possible (if not likely) that some core developer will say "too
ugly" to this solution. I might be willing to accept the solution if
it was clean enough, as this would nicely abstract away this limit of
SQLite.

So, in short: this idea is definitely worth more investigation.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Jdango - What IDE to use?

2012-04-23 Thread kenneth gonsalves
On Mon, 2012-04-23 at 15:01 +0300, Timothy Makobu wrote:
> I have one of those actually, but that's coz I have a project that's
> been
> around a while. They actually checked out the googlecode page. 

for me too
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Distributing Django apps

2012-04-23 Thread Eugenio Minardi
Hi,

You can have a look at http://pypi.python.org/pypi/django-fagungis/

-- Eugenio

On Mon, Apr 23, 2012 at 2:00 PM, Steve Kilbane
wrote:

> Hi all,
>
> I'm new to Python. I'm in the process of developing an open-source
> app. Is there a guide for packaging up and distributing Django apps?
> Or is it just a matter of copying the relevant files?
>
> steve
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django static files STATIC_ROOT vs STATICFILES_FINDERS

2012-04-23 Thread gnesher
I'm running manage.py runserver (on the dev environment) the only
reason I'm asking this is because I'm quite certain on my previous
installs (Django 1.3) it worked fine

On Apr 23, 12:54 pm, Philip Mountifield 
wrote:
> It depends how you are running. When using "manage.py runserver" it
> serves the static files for you, without even needing to collect them
> IIRC. But when deploying, you have to run "manage.py collectstatic" and
> Django collects all the files from the other locations for you and puts
> them in STATIC_ROOT, which you would configure your webserver to serve
> at STATIC_URL. The docs are pretty clear on this:
>
> https://docs.djangoproject.com/en/1.4/howto/static-files/
>
> Regards
> Phil
>
> On 23/04/2012 12:49, gnesher wrote:
>
>
>
>
>
>
>
>
>
> > But then shouldn't I expect the files to be served from the
> > STATIC_ROOT as well ?
>
> > On Apr 23, 12:38 pm, Philip Mountifield
> > wrote:
> >> There is a slight difference:
>
> >>    * STATIC_ROOT is where you would like the files to be collected to
> >>      when you run "manage.py collectstatic" and should be empty to begin
> >>      with.
> >>    * STATICFILES_DIRS is where the actual files are located and they will
> >>      be automagically servered under the development server.
> >>    * You can also create a folder called "static" in any app and put
> >>      files in there.
>
> >> Regards
> >> Phil
>
> >> On 23/04/2012 12:32, gnesher wrote:
>
> >>> Hi,
> >>> I'm not sure if this is a bug or am I missing something but I've
> >>> created a very simple test environment and placed a single png file
> >>> within my static folder.
> >>> The file is being served fine when I set :
> >>> STATIC_ROOT = ''
> >>> STATICFILES_DIRS = (
> >>>       '/Users/guynesher/Work/play/quicktest/testproj/static/',
> >>> )
> >>> however I'm geting a 404 error when I set it like this :
> >>> STATIC_ROOT = '/Users/guynesher/Work/play/quicktest/testproj/static/'
> >>> STATICFILES_DIRS = (
> >>> )
> >>> Based on the STATICFILES_DIRS comment (Additional locations of static
> >>> files) I expected I will only need to use it if I have multiple static
> >>> files directory which doesn't seem to be the case.
> >>> What am I missing here?
> >> --
>
> >> Philip Mountifield
> >> Formac Electronics Ltd
> >> tel  +44 (0) 1225 837333
> >> fax  +44 (0) 1225 430995
>
> >> pmountifi...@formac.netwww.formac.netwww.telgas.net
>
> --
>
> Philip Mountifield
> Formac Electronics Ltd
> tel  +44 (0) 1225 837333
> fax  +44 (0) 1225 430995
>
> pmountifi...@formac.netwww.formac.netwww.telgas.net

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



call_command('syncdb') in virtualenv failing: Error: No module named staticfiles

2012-04-23 Thread Stodge
I'm trying to port an existing app to Django 1.4 so I'm using virtualenv. 
./manage.py syncdb works but my old script that calls syncdb and creates 
dummy data doesn't. My code:

os.environ["DJANGO_SETTINGS_MODULE"]="settings"
call_command('syncdb', interactive=False)

is giving:

Error: No module named staticfiles

I assume it's using Django installed in /usr/lib64/python instead of the 
virtualenv? Any ideas how to fix this? Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/0vZ9QQkEq3MJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Jdango - What IDE to use?

2012-04-23 Thread Thomas Weholt
Me too. I got a open source license for PyCharm for DSE, but it
expires tomorrow and I'm not sure if I have to buy a new developer
license or not. Emailed the Pycharm-boys about this, wondering if I
could extend my open source license but haven't heard anything so far.

Anyhow, PyCharm is great and the guys behind it makes a bunch of great
products.

Thomas

On Mon, Apr 23, 2012 at 2:01 PM, Timothy Makobu
 wrote:
> I have one of those actually, but that's coz I have a project that's been
> around a while. They actually checked out the googlecode page.
>
>
> On Mon, Apr 23, 2012 at 3:00 PM, kenneth gonsalves 
> wrote:
>>
>> On Mon, 2012-04-23 at 14:54 +0300, Timothy Makobu wrote:
>> > If you can spare a few bux, get PyCharm. It's the best.
>>
>> they give open source licenses for free.
>> --
>> regards
>> Kenneth Gonsalves
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: call_command('syncdb') in virtualenv failing: Error: No module named staticfiles

2012-04-23 Thread Stodge
Bah - I completely forgot that my gen.py script had this :

#!/usr/bin/python

On Monday, 23 April 2012 07:26:55 UTC-5, Stodge wrote:
>
> I'm trying to port an existing app to Django 1.4 so I'm using virtualenv. 
> ./manage.py syncdb works but my old script that calls syncdb and creates 
> dummy data doesn't. My code:
>
> os.environ["DJANGO_SETTINGS_MODULE"]="settings"
> call_command('syncdb', interactive=False)
>
> is giving:
>
> Error: No module named staticfiles
>
> I assume it's using Django installed in /usr/lib64/python instead of the 
> virtualenv? Any ideas how to fix this? Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/FcjZ7RfYnR8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: request.is_ajax() not working

2012-04-23 Thread psychok7
i am using Chrome.

to be honest i dont really understand everything you are talking about, so 
ill just try to run your code and see if i can get results 
on the other hand if i use GET instead of POST i dont have to worry about CSRF 
right?

i am not sure you understood my question though, i am getting a 
HTTPRESPONSE, just not the one inside request.is_ajax()

i have read too much documentation on the net (old and new) so i guess 
thats why  i am confused now and just need something that works and only 
after that i will try to understand why does it work

On Monday, April 23, 2012 1:34:16 PM UTC+1, Masklinn wrote:
>
>
> On 2012-04-23, at 13:48 , psychok7 wrote:
>
> > yes i did that now, and still doesnt work.. it still returns false and 
> > doesnt print the line after request.is_ajax()
> > 
>
> I can't reproduce the issue with a trivial repro case (see attached 
> module),
> so with the little information you've provided the only thing my psychic
> debugger yield was "are you using Firefox" as it has a long-standing bug
> of not conserving headers on redirections[0][1], but that would make the 
> entire
> CSRF fail. *Unless* it redirects to a GET request, since you're not 
> checking
> whether the method is GET or POST (which you really should, incidentally)
> this would bypass the CSRF check (even though it'd lose the header), and 
> would
> lose the X-Requested-By header (set by jquery) which Django uses to know
> whether a request "is ajax" or not.
>
> So I'd recommend looking into that, and taking a long look at you 
> javascript
> console's Network tab to see what kind of calls are being sent by the 
> browser
> to django.
>
> [0] https://bugzilla.mozilla.org/show_bug.cgi?id=553888
> [1] On the other hand, it should be fixed in Firefox 7 and above, so you'd
> have to use Firefox *and* use an outdated version of it.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/816szwSVDLEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: request.is_ajax() not working

2012-04-23 Thread Masklinn
On 2012-04-23, at 14:44 , psychok7 wrote:

> i am using Chrome.
> 
> to be honest i dont really understand everything you are talking about, so 
> ill just try to run your code and see if i can get results 
> on the other hand if i use GET instead of POST i dont have to worry about 
> CSRF 
> right?

Right. You get to worry about a fundamentally broken site instead.

> i am not sure you understood my question though, i am getting a 
> HTTPRESPONSE, just not the one inside request.is_ajax()

Yes, I understand that. Which means either your CSRF works or you're in
a GET (no CSRF check), either way you're without the custom headers.

> i have read too much documentation on the net (old and new) so i guess 
> thats why  i am confused now and just need something that works and only 
> after that i will try to understand why does it work

I usually find that throwing shit at the wall until something sticks does
not yield better code or understanding than building from the basics, 
starting from small things if needs be, but that's your call.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Distributing Django apps

2012-04-23 Thread Steve Kilbane
Marvellous! I shall take a look.

Thanks.

On Apr 23, 1:19 pm, Eugenio Minardi  wrote:
> Hi,
>
> You can have a look athttp://pypi.python.org/pypi/django-fagungis/
>
> -- Eugenio
>
> On Mon, Apr 23, 2012 at 2:00 PM, Steve Kilbane
> wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I'm new to Python. I'm in the process of developing an open-source
> > app. Is there a guide for packaging up and distributing Django apps?
> > Or is it just a matter of copying the relevant files?
>
> > steve
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



[no subject]

2012-04-23 Thread Karen Tracey


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: restarting a django development server

2012-04-23 Thread Joel Goldstick
On Mon, Apr 23, 2012 at 6:10 AM, dummyman dummyman  wrote:
> how to restart a django development server programmatically in python ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

python manage.py runserver

-- 
Joel Goldstick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: restarting a django development server

2012-04-23 Thread Joel Goldstick
On Mon, Apr 23, 2012 at 9:16 AM, Joel Goldstick
 wrote:
> On Mon, Apr 23, 2012 at 6:10 AM, dummyman dummyman  wrote:
>> how to restart a django development server programmatically in python ?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
> python manage.py runserver
>
oops I spoke too soon.  Didn't see you want to do this
programatically.  But I suppose you could just invoke that line using
subprocess? http://docs.python.org/library/subprocess.html#module-subprocess
> --
> Joel Goldstick



-- 
Joel Goldstick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Problem with get_or_create

2012-04-23 Thread Murilo Vicentini
Hey guys,
I'm having a bit of a problem using the get_or_create with a 
ManyToManyField in my model.
class Run(models.Model):
distros = models.ForeignKey('Distro')
compilers = models.ManyToManyField('Compiler', blank=True, 
null=True)
adapters = models.ForeignKey('Adapter')

Task = models.IntegerField()
Path = models.CharField(max_length = 300)
Date_Time = models.DateTimeField()

class RunForm(ModelForm):
class Meta:
model = Run

What I'm trying to do is merely trying to save in the database if the entry 
does not exist already (hence why I'm trying to use get_or_create). Here is 
how I'm doing:
fields = {
 'Task': task,
 'Path': runpath,
 'Date_Time': datetime(2012, 4, 10, 10, 20, 0),
 'adapters': adapters.id,
 'distros': distros.id,
}
form = RunForm(fields)
if form.is_valid():
  runs, created = Run.objects.get_or_create(**form.cleaned_data)

In the compilers field I don't want to set any value this time. And what I 
keep getting the following error: int() argument must be a string or a 
number, not 'list'. Does anyone know why this is happening? Is it not 
possible to use the get_or_create with many to many relationship in the 
model?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/utLaEo-7EAkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: keep models simple ? where to put the business logic ?

2012-04-23 Thread Javier Guerra Giraldez
On Mon, Apr 23, 2012 at 6:47 AM, bruno desthuilliers
 wrote:
> Models - like any other module - should indeed be "as simple as
> possible", _but not simpler_. If you concern is about your models.py
> file size, it might be time to refactor it into a package.

or maybe the app has to be more focused, and split in two or more apps.


> Now if there are parts of your methods that are low-level enough and
> don't really need to know about your models, yeps, they may belong to
> some "model-agnostic" utility module.

also when the usercase concepts are not exactly the same as the
database records. then another model-like layer can be useful.

for example, lets say you're working with a genealogy application, and
you have a Person model, and several kinds of relationships between
person instances.   But let's also say that you have a 'Family'
concept that is easy to derive from the database (so it doesn't need
another model class), but you want to add some extra behaviour at the
Family level (above Person and Relationship).   then it might be
useful to add a new Family.py module that works on your models and is
managed by the views in similar ways to them.


but in the end, yes: the vast majority of business logic belongs in
models.py files, definitely not in the views.

-- 
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: YAML Fixture is not working. DeserializationError

2012-04-23 Thread James Rivett-Carnac
Your yaml doesn't seem to be correctly formated, should be:

- model: translations.Language
  pk: 1
  fields:
  code: fr
  display_name: Français
- model: translations.Language
  pk: 2
  fields:
  code: en
  display_name: English

model, pk, and fields are all on the same indentation level.  Just spent 
some time trying to debug the same problem.

rgds

james

On Tuesday, 10 April 2012 12:47:29 UTC+8, abisson wrote:
>
> Good afternoon,
>
> I am trying to do: python manage.py syncdb and I always get this error:
>
> Problem installing fixture '.../translations/fixtures/initial_data.yaml': 
> Traceback (most recent call last):
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/loaddata.py",
>  
> line 190, in handle
> for obj in objects:
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/serializers/pyyaml.py",
>  
> line 62, in Deserializer
> raise DeserializationError(e)
> DeserializationError: mapping values are not allowed here
>   in "/.../translations/fixtures/initial_data.yaml", line 2, column 7
>
> *Model:*
>
> from django.db import models
>
> class Language(models.Model):
> code = models.CharField(max_length=2)
> display_name = models.CharField(max_length=16, blank=False)
>
> def __unicode__(self):
> return self.display_name
>
>
> *Fixture:*
>
> - model: translations.Language
> pk: 1
> fields:
> code: fr
> display_name: Français
> - model: translations.Language
> pk: 2
> fields:
> code: en
> display_name: English
>
>
> I am running PyYAML 3.10! Any ideas?! :(
>
> Thanks a lot,
>
> Antoine
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/RUNoOC4Kfr8J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



cannot locate syntax error in urls.py

2012-04-23 Thread r0pewalker
Hi everybody. I recently started working on a project involving heavy
Django usage.
I basically retrieve data in xml  from a SOAP web service using suds,
parse the xml into a db and then (I should) popuate a web page.
I'm a beginner both in Python and Django, please bear with me and my
possibly ill-formed questions!
I've formed a reduced set of correct views and templates for the
purpose of testing but i cannot step through this:


Environment:

Request Method: GET
Request URL: http://www.quotidiano.net/elezioni_2012/comunali/
Django Version: 1.1.1
Python Version: 2.4.3
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'comunali',
 'client_soap']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
  82. callback, callback_args, callback_kwargs =
resolver.resolve(
File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py" in
resolve
  218. sub_match = pattern.resolve(new_path)
File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py" in
resolve
  216. for pattern in self.url_patterns:
File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py" in
_get_url_patterns
  245. patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "/usr/lib/python2.4/site-packages/django/core/urlresolvers.py" in
_get_urlconf_module
  240. self._urlconf_module =
import_module(self.urlconf_name)
File "/usr/lib/python2.4/site-packages/django/utils/importlib.py" in
import_module
  35. __import__(name)

Exception Type: SyntaxError at /comunali/
Exception Value: invalid syntax (urls.py, line 23)


which I confirmed by trying to import urls py fin the shell.
I'm quite puzzled by the fact that line 23 in my file is not a line of
code, since urls.py has only 22 lines. I looked through it in search
of tab/whitespace misuse or punctuation errors (that I often get when
first running any script I made).
Here is urls.py:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
#Example:
url('^$','comunali.views.index', name='comunali_index'),
url(r'^provincia/(?P[^/]+)/','comunali.views.provincia',
name = 'comunali_provincia'),
url(r'^comune/(?P[^/]+)/', 'comunali.views.comune', name
= 'comunali_comune'),
url(r'^ballottaggio/(?P[^/]+)/',
'comunali.views.ballottaggio', name = 'comunali_ballottaggio'),
url(r'^province/(?P[^/]
+)/','comunali.views.province', name = 'comunali_province'),
url(r'^province/$','comunali.views.province', name =
'comunali_province'),
url(r'^comuni/(?P[^/]+)/', 'comunali.views.comuni',
name = 'comunali_regioni'),
url(r'^comuni/$', 'comunali.views.comuni', name =
'comunali_regioni'),
url(r'^search/(?P[^/]+)/',
'comunali.views.search_comuni', name = 'comunali_search_comuni'),
url(r'^(?P[^/]+)/comune/(?P[^/]+)/',
'comunali.views.comune', name = 'comunali_comune'),
url(r'^incluso/', 'comunali.views.inc', name =
'comunali_incluso'),

#Uncomment the admin/doc line below and add
'django.contrib.admindocs'
#to INSTALLED_APPS to enable admin documentation:
(r'^admin/doc/', include('django.contrib.admindocs.urls')),

#Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),

any suggestions are welcome.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: cannot locate syntax error in urls.py

2012-04-23 Thread Daniel Roseman
On Monday, 23 April 2012 15:03:35 UTC+1, r0pewalker wrote:
>
> Hi everybody. I recently started working on a project involving heavy 
> Django usage. 
> I basically retrieve data in xml  from a SOAP web service using suds, 
> parse the xml into a db and then (I should) popuate a web page. 
> I'm a beginner both in Python and Django, please bear with me and my 
> possibly ill-formed questions! 
> I've formed a reduced set of correct views and templates for the 
> purpose of testing but i cannot step through this: 
>
> 
>
 

> Exception Type: SyntaxError at /comunali/ 
> Exception Value: invalid syntax (urls.py, line 23) 
>
>
> which I confirmed by trying to import urls py fin the shell. 
> I'm quite puzzled by the fact that line 23 in my file is not a line of 
> code, since urls.py has only 22 lines. I looked through it in search 
> of tab/whitespace misuse or punctuation errors (that I often get when 
> first running any script I made). 
> Here is urls.py: 
>
> from django.conf.urls.defaults import * 
>
> urlpatterns = patterns('', 
> #Example: 
> url('^$','comunali.views.index', name='comunali_index'), 
> url(r'^provincia/(?P[^/]+)/','comunali.views.provincia', 
> name = 'comunali_provincia'), 
> url(r'^comune/(?P[^/]+)/', 'comunali.views.comune', name 
> = 'comunali_comune'), 
> url(r'^ballottaggio/(?P[^/]+)/', 
> 'comunali.views.ballottaggio', name = 'comunali_ballottaggio'), 
> url(r'^province/(?P[^/] 
> +)/','comunali.views.province', name = 'comunali_province'), 
> url(r'^province/$','comunali.views.province', name = 
> 'comunali_province'), 
> url(r'^comuni/(?P[^/]+)/', 'comunali.views.comuni', 
> name = 'comunali_regioni'), 
> url(r'^comuni/$', 'comunali.views.comuni', name = 
> 'comunali_regioni'), 
> url(r'^search/(?P[^/]+)/', 
> 'comunali.views.search_comuni', name = 'comunali_search_comuni'), 
> url(r'^(?P[^/]+)/comune/(?P[^/]+)/', 
> 'comunali.views.comune', name = 'comunali_comune'), 
> url(r'^incluso/', 'comunali.views.inc', name = 
> 'comunali_incluso'), 
>
> #Uncomment the admin/doc line below and add 
> 'django.contrib.admindocs' 
> #to INSTALLED_APPS to enable admin documentation: 
> (r'^admin/doc/', include('django.contrib.admindocs.urls')), 
>
> #Uncomment the next line to enable the admin: 
> (r'^admin/', include(admin.site.urls)), 
>
> any suggestions are welcome. 
>
>
Indeed, you're missing a line 23, which would close the parentheses opened 
in the first line.
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/zfNEhB7f3lQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Ignoring empty forms in a formset

2012-04-23 Thread Martin Tiršel
Nobody knows how to ignore empty forms in a formset? I have to write some 
custom method on a form that checks all fields and returns False if any of 
the fields is filled or is there any other solution?

Martin

On Sunday, April 22, 2012 6:44:53 PM UTC+2, Martin Tiršel wrote:
>
> Hello,
>
> I have a formset and some JavaScript to add more forms into this formset. 
> In a view, I iterate through the formset saving (not a ModelForm just Form 
> with save method) each form:
>
> for form in formset:
> form.save()
>
> But I want to ignore empty forms that were added by JavasScript and not 
> removed. How can I do this?
>
> Thanks,
> Martin
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Y_DfzKjYiYwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Ignoring empty forms in a formset

2012-04-23 Thread Marcin Tustin
You will want to edit the management form values on the client side, as
described in the documentation.

On Mon, Apr 23, 2012 at 15:42, Martin Tiršel wrote:

> Nobody knows how to ignore empty forms in a formset? I have to write some
> custom method on a form that checks all fields and returns False if any of
> the fields is filled or is there any other solution?
>
> Martin
>
> On Sunday, April 22, 2012 6:44:53 PM UTC+2, Martin Tiršel wrote:
>>
>> Hello,
>>
>> I have a formset and some JavaScript to add more forms into this formset.
>> In a view, I iterate through the formset saving (not a ModelForm just Form
>> with save method) each form:
>>
>> for form in formset:
>> form.save()
>>
>> But I want to ignore empty forms that were added by JavasScript and not
>> removed. How can I do this?
>>
>> Thanks,
>> Martin
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/Y_DfzKjYiYwJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Marcin Tustin
Tel: 07773 787 105

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: restarting a django development server

2012-04-23 Thread dummyman dummyman
hi

but how do i do it when the server is running ??
i basically want to stop it and restart it in the program
is it possible ?

On Mon, Apr 23, 2012 at 6:54 PM, Joel Goldstick wrote:

> On Mon, Apr 23, 20ogr12 at 9:16 AM, Joel Goldstick
>  wrote:
> > On Mon, Apr 23, 2012 at 6:10 AM, dummyman dummyman 
> wrote:
> >> how to restart a django development server programmatically in python ?
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/django-users?hl=en.
> >
> > python manage.py runserver
> >
> oops I spoke too soon.  Didn't see you want to do this
> programatically.  But I suppose you could just invoke that line using
> subprocess?
> http://docs.python.org/library/subprocess.html#module-subprocess
> > --
> > Joel Goldstick
>
>
>
> --
> Joel Goldstick
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: keep models simple ? where to put the business logic ?

2012-04-23 Thread Daniel Sokolowski

To alleviate models.py file growing large you can split it up like so

/models/
/models/__init__.py
/models/invoices.py
/models/products.py
/models/taxes.py
...

The are two tricks to the above to make it work however; first you must 
import your files in the __init__.py and manually specify the app_label for 
all your model files:


# /models__init__.py
from .taxes import *
from .products import *
from .sandh_costs import *
from .discounts import

# /models/taxes.py
class DiscountBase(models.Model):
   ...
   ### model options - "anything that's not a field"
   class Meta:
   app_label = 'pnpstore' # must specify same app label so that in 
admin models are grouped correctly


I also split views in a similar manner.


-Original Message- 
From: Javier Guerra Giraldez

Sent: Monday, April 23, 2012 9:45 AM
To: django-users@googlegroups.com
Subject: Re: keep models simple ? where to put the business logic ?

On Mon, Apr 23, 2012 at 6:47 AM, bruno desthuilliers
 wrote:

Models - like any other module - should indeed be "as simple as
possible", _but not simpler_. If you concern is about your models.py
file size, it might be time to refactor it into a package.


or maybe the app has to be more focused, and split in two or more apps.



Now if there are parts of your methods that are low-level enough and
don't really need to know about your models, yeps, they may belong to
some "model-agnostic" utility module.


also when the usercase concepts are not exactly the same as the
database records. then another model-like layer can be useful.

for example, lets say you're working with a genealogy application, and
you have a Person model, and several kinds of relationships between
person instances.   But let's also say that you have a 'Family'
concept that is easy to derive from the database (so it doesn't need
another model class), but you want to add some extra behaviour at the
Family level (above Person and Relationship).   then it might be
useful to add a new Family.py module that works on your models and is
managed by the views in similar ways to them.


but in the end, yes: the vast majority of business logic belongs in
models.py files, definitely not in the views.

--
Javier

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Daniel Sokolowski
Web Engineer
KL Insight
http://klinsight.com/
Tel: 613-344-2116 | Fax: 613.634.7029
993 Princess Street, Suite 212
Kingston, ON K7L 1H3, Canada 


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: restarting a django development server

2012-04-23 Thread dummyman dummyman
basically i ve a form in a class CollFormAdmin where i am overriding two
fields to MultipleChoiceField where values are changed dynamically based on
a pickle file value
then in CollAdmin class


class CollAdmin(admin.ModelAdmin):

   form=CollFormAdmin

but i want to change the value of MultipleChoiceField dynamically. But it
appears like the class is loaded only once and the form is taking the
previous old value ie d first one. Thats y i asked a way to restart the
server in the code

please help me


On Mon, Apr 23, 2012 at 8:35 PM, dummyman dummyman wrote:

> hi
>
> but how do i do it when the server is running ??
> i basically want to stop it and restart it in the program
> is it possible ?
>
> On Mon, Apr 23, 2012 at 6:54 PM, Joel Goldstick 
> wrote:
>
>> On Mon, Apr 23, 20ogr12 at 9:16 AM, Joel Goldstick
>>
>>  wrote:
>> > On Mon, Apr 23, 2012 at 6:10 AM, dummyman dummyman 
>> wrote:
>> >> how to restart a django development server programmatically in python ?
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >
>> > python manage.py runserver
>> >
>> oops I spoke too soon.  Didn't see you want to do this
>> programatically.  But I suppose you could just invoke that line using
>> subprocess?
>> http://docs.python.org/library/subprocess.html#module-subprocess
>> > --
>> > Joel Goldstick
>>
>>
>>
>> --
>> Joel Goldstick
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: cannot locate syntax error in urls.py

2012-04-23 Thread r0pewalker
My bad. Thanks for the quick hint, turns out I was not looking the
right way..

On 23 Apr, 16:42, Daniel Roseman  wrote:
> On Monday, 23 April 2012 15:03:35 UTC+1, r0pewalker wrote:
>
> > Hi everybody. I recently started working on a project involving heavy
> > Django usage.
> > I basically retrieve data in xml  from a SOAP web service using suds,
> > parse the xml into a db and then (I should) popuate a web page.
> > I'm a beginner both in Python and Django, please bear with me and my
> > possibly ill-formed questions!
> > I've formed a reduced set of correct views and templates for the
> > purpose of testing but i cannot step through this:
>
> > 
>
> > Exception Type: SyntaxError at /comunali/
> > Exception Value: invalid syntax (urls.py, line 23)
>
> > which I confirmed by trying to import urls py fin the shell.
> > I'm quite puzzled by the fact that line 23 in my file is not a line of
> > code, since urls.py has only 22 lines. I looked through it in search
> > of tab/whitespace misuse or punctuation errors (that I often get when
> > first running any script I made).
> > Here is urls.py:
>
> > from django.conf.urls.defaults import *
>
> > urlpatterns = patterns('',
> >         #Example:
> >         url('^$','comunali.views.index', name='comunali_index'),
> >         url(r'^provincia/(?P[^/]+)/','comunali.views.provincia',
> > name = 'comunali_provincia'),
> >         url(r'^comune/(?P[^/]+)/', 'comunali.views.comune', name
> > = 'comunali_comune'),
> >         url(r'^ballottaggio/(?P[^/]+)/',
> > 'comunali.views.ballottaggio', name = 'comunali_ballottaggio'),
> >         url(r'^province/(?P[^/]
> > +)/','comunali.views.province', name = 'comunali_province'),
> >         url(r'^province/$','comunali.views.province', name =
> > 'comunali_province'),
> >         url(r'^comuni/(?P[^/]+)/', 'comunali.views.comuni',
> > name = 'comunali_regioni'),
> >         url(r'^comuni/$', 'comunali.views.comuni', name =
> > 'comunali_regioni'),
> >         url(r'^search/(?P[^/]+)/',
> > 'comunali.views.search_comuni', name = 'comunali_search_comuni'),
> >         url(r'^(?P[^/]+)/comune/(?P[^/]+)/',
> > 'comunali.views.comune', name = 'comunali_comune'),
> >         url(r'^incluso/', 'comunali.views.inc', name =
> > 'comunali_incluso'),
>
> >         #Uncomment the admin/doc line below and add
> > 'django.contrib.admindocs'
> >         #to INSTALLED_APPS to enable admin documentation:
> >         (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
> >         #Uncomment the next line to enable the admin:
> >         (r'^admin/', include(admin.site.urls)),
>
> > any suggestions are welcome.
>
> Indeed, you're missing a line 23, which would close the parentheses opened
> in the first line.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problem with get_or_create

2012-04-23 Thread akaariai
On Apr 23, 4:26 pm, Murilo Vicentini 
wrote:
> Hey guys,
> I'm having a bit of a problem using the get_or_create with a
> ManyToManyField in my model.
> class Run(models.Model):
>         distros = models.ForeignKey('Distro')
>         compilers = models.ManyToManyField('Compiler', blank=True,
> null=True)
>         adapters = models.ForeignKey('Adapter')
>
>         Task = models.IntegerField()
>         Path = models.CharField(max_length = 300)
>         Date_Time = models.DateTimeField()
>
> class RunForm(ModelForm):
>         class Meta:
>                 model = Run
>
> What I'm trying to do is merely trying to save in the database if the entry
> does not exist already (hence why I'm trying to use get_or_create). Here is
> how I'm doing:
> fields = {
>          'Task': task,
>          'Path': runpath,
>          'Date_Time': datetime(2012, 4, 10, 10, 20, 0),
>          'adapters': adapters.id,
>          'distros': distros.id,    }
>
> form = RunForm(fields)
> if form.is_valid():
>           runs, created = Run.objects.get_or_create(**form.cleaned_data)

Try "runs = form.save()", get_or_create doesn't seem to be the correct
method in this situation.

If you want to skip some fields you can use the form's Meta attributes
to do that.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Jdango - What IDE to use?

2012-04-23 Thread Daniel Sokolowski
Eclipse + PyDev + whatever else you want; if you need it more often then not 
there is a plugin for it. This IDE just becomes more and more powerful as 
you keep learning it through use;  note  Aptana is a rebranded Eclipse+PyDev 
however I still prefer vanilla Eclipse + plugins.


My list of plugins:

Data Tools Platform Enablement Extender SDK 
1.9.2.v201109161655-7I9O7XFE9Jfxu0wIxMQtoLz0X-dE 
org.eclipse.datatools.enablement.sdk.feature.feature.groupEclipse Data 
Tools Platform
Data Tools Platform Extender SDK 
1.9.2.v201109161655-7PA37eFEpPYv5_Ae3-6EjC5ZX4e5 
org.eclipse.datatools.sdk.feature.feature.groupEclipse Data Tools 
Platform
Eclipse EGit2.0.0.201204120545org.eclipse.egit.feature.group 
Eclipse EGit
Eclipse JGit2.0.0.201204120530org.eclipse.jgit.feature.group 
Eclipse JGit

Eclipse SDK4.2.0.I20110805-1200org.eclipse.sdk.idenull
Eclipse Web Developer Tools 
3.3.2.v20030500-7O7IFj6EMjB7yO1Xs_G1kMtQeOye6HTXFWve95_R 
org.eclipse.wst.web_ui.feature.feature.groupEclipse Web Tools Platform
Eclipse XML Editors and Tools 
3.3.2.v201112072049-7H7EFZ7DxumTmce4khcSkIiqoD8eDMKlT8Oz011P 
org.eclipse.wst.xml_ui.feature.feature.groupEclipse Web Tools Platform
EGit Mylyn2.0.0.201204120545org.eclipse.egit.mylyn.feature.group 
Eclipse EGit
JavaScript Development Tools1.3.2.v201201112313-7G78FZvFC7sRekSz-g-nAlz 
org.eclipse.wst.jsdt.feature.feature.groupEclipse Web Tools Platform
Log Viewer Feature0.9.8.8 
de.anbos.eclipse.logviewer.feature.feature.groupAndre Bossert
Marketplace Client1.1.1.I20110907-0947 
org.eclipse.epp.mpc.feature.groupEclipse Packaging Project
MercurialEclipse1.9.1.v20302231mercurialeclipse.feature.group 
MercurialEclipse project
Mylyn Context Connector: Eclipse IDE3.6.5.v20120215-0100 
org.eclipse.mylyn.ide_feature.feature.groupEclipse Mylyn
Mylyn Context Connector: Team Support3.6.5.v20120215-0100 
org.eclipse.mylyn.team_feature.feature.groupEclipse Mylyn
Mylyn Task List3.6.5.v20120215-0100 
org.eclipse.mylyn_feature.feature.groupEclipse Mylyn
Mylyn Task-Focused Interface3.6.5.v20120215-0100 
org.eclipse.mylyn.context_feature.feature.groupEclipse Mylyn
Mylyn WikiText1.5.5.v20120215-0100 
org.eclipse.mylyn.wikitext_feature.feature.groupEclipse Mylyn
PyDev for Eclipse2.5.0.2012040618 
org.python.pydev.feature.feature.groupAptana
Pydev Mylyn Integration0.3.0 
org.python.pydev.mylyn.feature.feature.groupFabio Zadrozny
Remote System Explorer End-User Runtime 
3.3.2.R33x_v201110030150-7L7CFGH8wqio8s-qYtkPgn8qWd4T 
org.eclipse.rse.feature.groupEclipse TM Project
Remote System Explorer User Actions 
1.1.300.v201103142315-31F8N8s7355353B75DD 
org.eclipse.rse.useractions.feature.groupEclipse TM Project
ReST Editor1.0.5.201110101040 
org.psem2m.eclipse.rest.editor.feature.groupisandlaTech.com
Smartsprites Eclipse Plugin0.0.9 
de.bitexpert.eclipse.smartsprites.feature.feature.groupbitExpert AG
Target Management Terminal 
3.2.1.R33x_v201106281309-7N7B1BbVJv-SaPEOkhsVVd_C3752 
org.eclipse.tm.terminal.sdk.feature.groupEclipse TM Project
Windows Binaries for Mercurial (Recommended)1.9.3.v201110131844 
com.intland.hgbinary.win32.feature.groupIntland Software
YUI Compressor Eclipse Plugin0.0.4 
de.bitexpert.eclipse.yuicompressor.feature.feature.groupbitExpert AG



-Original Message- 
From: Houmie

Sent: Saturday, April 21, 2012 2:05 PM
To: Django users
Subject: New to Jdango - What IDE to use?

Hi everyone,

I was wondering which IDE you guys are recommending to use?
Important is ease of use and productivity. Price comes third if its
not free.

I tried already Aptana 3.0, but I get a weird error message upon
creating Django projects:
http://stackoverflow.com/questions/10261037/django-on-aptana-studio-3-0

Highly appreciated,
Houman

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Daniel Sokolowski
Web Engineer
Danols Web Engineering
http://webdesign.danols.com/
Office: 613-817-6833
Fax: 613-817-4553
Toll Free: 1-855-5DANOLS
Kingston, ON K7L 1H3, Canada 


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Jdango - What IDE to use?

2012-04-23 Thread Daniel Sokolowski
To add: install the Eclipse "Marketplace Client" plugin and use that to 
locate your plugins.


-Original Message- 
From: Daniel Sokolowski

Sent: Monday, April 23, 2012 11:44 AM
To: Django users
Subject: Re: New to Jdango - What IDE to use?

Eclipse + PyDev + whatever else you want; if you need it more often then not
there is a plugin for it. This IDE just becomes more and more powerful as
you keep learning it through use;  note  Aptana is a rebranded Eclipse+PyDev
however I still prefer vanilla Eclipse + plugins.

My list of plugins:

Data Tools Platform Enablement Extender SDK
1.9.2.v201109161655-7I9O7XFE9Jfxu0wIxMQtoLz0X-dE
org.eclipse.datatools.enablement.sdk.feature.feature.groupEclipse Data
Tools Platform
Data Tools Platform Extender SDK
1.9.2.v201109161655-7PA37eFEpPYv5_Ae3-6EjC5ZX4e5
org.eclipse.datatools.sdk.feature.feature.groupEclipse Data Tools
Platform
Eclipse EGit2.0.0.201204120545org.eclipse.egit.feature.group
Eclipse EGit
Eclipse JGit2.0.0.201204120530org.eclipse.jgit.feature.group
Eclipse JGit
Eclipse SDK4.2.0.I20110805-1200org.eclipse.sdk.idenull
Eclipse Web Developer Tools
3.3.2.v20030500-7O7IFj6EMjB7yO1Xs_G1kMtQeOye6HTXFWve95_R
org.eclipse.wst.web_ui.feature.feature.groupEclipse Web Tools Platform
Eclipse XML Editors and Tools
3.3.2.v201112072049-7H7EFZ7DxumTmce4khcSkIiqoD8eDMKlT8Oz011P
org.eclipse.wst.xml_ui.feature.feature.groupEclipse Web Tools Platform
EGit Mylyn2.0.0.201204120545org.eclipse.egit.mylyn.feature.group
Eclipse EGit
JavaScript Development Tools1.3.2.v201201112313-7G78FZvFC7sRekSz-g-nAlz
org.eclipse.wst.jsdt.feature.feature.groupEclipse Web Tools Platform
Log Viewer Feature0.9.8.8
de.anbos.eclipse.logviewer.feature.feature.groupAndre Bossert
Marketplace Client1.1.1.I20110907-0947
org.eclipse.epp.mpc.feature.groupEclipse Packaging Project
MercurialEclipse1.9.1.v20302231mercurialeclipse.feature.group
MercurialEclipse project
Mylyn Context Connector: Eclipse IDE3.6.5.v20120215-0100
org.eclipse.mylyn.ide_feature.feature.groupEclipse Mylyn
Mylyn Context Connector: Team Support3.6.5.v20120215-0100
org.eclipse.mylyn.team_feature.feature.groupEclipse Mylyn
Mylyn Task List3.6.5.v20120215-0100
org.eclipse.mylyn_feature.feature.groupEclipse Mylyn
Mylyn Task-Focused Interface3.6.5.v20120215-0100
org.eclipse.mylyn.context_feature.feature.groupEclipse Mylyn
Mylyn WikiText1.5.5.v20120215-0100
org.eclipse.mylyn.wikitext_feature.feature.groupEclipse Mylyn
PyDev for Eclipse2.5.0.2012040618
org.python.pydev.feature.feature.groupAptana
Pydev Mylyn Integration0.3.0
org.python.pydev.mylyn.feature.feature.groupFabio Zadrozny
Remote System Explorer End-User Runtime
3.3.2.R33x_v201110030150-7L7CFGH8wqio8s-qYtkPgn8qWd4T
org.eclipse.rse.feature.groupEclipse TM Project
Remote System Explorer User Actions
1.1.300.v201103142315-31F8N8s7355353B75DD
org.eclipse.rse.useractions.feature.groupEclipse TM Project
ReST Editor1.0.5.201110101040
org.psem2m.eclipse.rest.editor.feature.groupisandlaTech.com
Smartsprites Eclipse Plugin0.0.9
de.bitexpert.eclipse.smartsprites.feature.feature.groupbitExpert AG
Target Management Terminal
3.2.1.R33x_v201106281309-7N7B1BbVJv-SaPEOkhsVVd_C3752
org.eclipse.tm.terminal.sdk.feature.groupEclipse TM Project
Windows Binaries for Mercurial (Recommended)1.9.3.v201110131844
com.intland.hgbinary.win32.feature.groupIntland Software
YUI Compressor Eclipse Plugin0.0.4
de.bitexpert.eclipse.yuicompressor.feature.feature.groupbitExpert AG


-Original Message- 
From: Houmie

Sent: Saturday, April 21, 2012 2:05 PM
To: Django users
Subject: New to Jdango - What IDE to use?

Hi everyone,

I was wondering which IDE you guys are recommending to use?
Important is ease of use and productivity. Price comes third if its
not free.

I tried already Aptana 3.0, but I get a weird error message upon
creating Django projects:
http://stackoverflow.com/questions/10261037/django-on-aptana-studio-3-0

Highly appreciated,
Houman

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


Daniel Sokolowski
Web Engineer
Danols Web Engineering
http://webdesign.danols.com/
Office: 613-817-6833
Fax: 613-817-4553
Toll Free: 1-855-5DANOLS
Kingston, ON K7L 1H3, Canada 


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problem with get_or_create

2012-04-23 Thread Denis Darii
Murilo, try to debug your "task" variable - must be an int.
Also next time please provide full traceback of your error.

On 23 April 2012 17:42, akaariai  wrote:

> On Apr 23, 4:26 pm, Murilo Vicentini 
> wrote:
> > Hey guys,
> > I'm having a bit of a problem using the get_or_create with a
> > ManyToManyField in my model.
> > class Run(models.Model):
> > distros = models.ForeignKey('Distro')
> > compilers = models.ManyToManyField('Compiler', blank=True,
> > null=True)
> > adapters = models.ForeignKey('Adapter')
> >
> > Task = models.IntegerField()
> > Path = models.CharField(max_length = 300)
> > Date_Time = models.DateTimeField()
> >
> > class RunForm(ModelForm):
> > class Meta:
> > model = Run
> >
> > What I'm trying to do is merely trying to save in the database if the
> entry
> > does not exist already (hence why I'm trying to use get_or_create). Here
> is
> > how I'm doing:
> > fields = {
> >  'Task': task,
> >  'Path': runpath,
> >  'Date_Time': datetime(2012, 4, 10, 10, 20, 0),
> >  'adapters': adapters.id,
> >  'distros': distros.id,}
> >
> > form = RunForm(fields)
> > if form.is_valid():
> >   runs, created = Run.objects.get_or_create(**form.cleaned_data)
>
> Try "runs = form.save()", get_or_create doesn't seem to be the correct
> method in this situation.
>
> If you want to skip some fields you can use the form's Meta attributes
> to do that.
>
>  - Anssi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
I'm using Linux because i'm freedom dependent.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread Daniel Sokolowski

+1

I use SQlite3 on lower traffic production sites due to it's ease of install 
and deployment. Even though I only once I reached this 1000 variable limit I 
would like to see some django work around.




-Original Message- 
From: akaariai

Sent: Monday, April 23, 2012 8:06 AM
To: Django users
Subject: Re: 'too many SQL variables' error with ModelMultipleChoiceField



On Apr 23, 10:48 am, Lukas Zilka  wrote:

Hey Russ,

thanks for your reply. I looked at the bulk insertion problem, and
that made me think that probably using the variables themselves is the
problem. It does not really make sense to me why anybody bothers to
use variables in a long SQL query for the IN clause, let alone a bulk
insertion? Does that benefit anything?

Anyway, I conducted an experiment and tried a simple SQL query with
lots of items in the IN clause to prove that its the variables
themselves, not the limitation of IN clause in SQLite, is whats
causing the problem. I have been successfully able to execute a query
as "SELECT * FROM projects WHERE id IN (...)" where on the place of
`...` there were 15,000 numbers. So SQLite has no problem with lot of
stuff as an argument of the IN operator. Now, the only limitation is
the length of the SQL query itself. According to the SQLite
documentation it is 1megabyte, and that suffices for 100k+ elements.
With that big query, you are right, it would be very impractical and
slow for the end users to interact with the application (sending 1M of
data to the webserver will probably be very unresponsive), so I think
this is a fair limitation that should never be exceeded for this use.

In Django code it seems that it would suffice to make a change in the
file 'db/models/sql/where.py'. Particularly, condition on the number
of elements of IN, and, if it is over let's say 100 of them, put them
into the SQL query directly as a string (e.g. '1,2,3') - not as
variables('?, ?, ?').

Though, for the future, I still believe there should be a better
solution than to rely on not reaching this limit. I would propose that
a temporary table should be created, filled up with the right
arguments of IN operator, and the query rewritten as a JOIN on the
original left argument of IN (or for simplicity, and perhaps worse
performance, a nested query) and this temporary table. That of course
only if the number of elements on the right side of IN is more than
some number. But this is for another discussion.

My question is therefore: Will the change in Django code that I
propose have any bad consequences or do you think it might actually
work satisfactorily?


First the "write the query as "1, 2, 3", not as "%s, %s, %s", (1, 2,
3). The problem is SQL injection. You could do that for integer
parameters easily, but on the whole it is not a nice way.

The create temp table + join seems hard. But you could do "exists"
query instead. A query like "select * from tbl where id in (a list)"
could be rewritten to "select * from tbl where exists (select 1 from
temp_table where temp_table.id = tbl.id)". This could be handled in
sql/where.py somewhat easily.

For me this issue isn't that important. I don't use SQLite except for
testing. If somebody wants to work on this issue, I must warn that it
is possible (if not likely) that some core developer will say "too
ugly" to this solution. I might be willing to accept the solution if
it was clean enough, as this would nicely abstract away this limit of
SQLite.

So, in short: this idea is definitely worth more investigation.

- Anssi

--
You received this message because you are subscribed to the Google Groups 
"Django users" group.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Daniel Sokolowski
Web Engineer
KL Insight
http://klinsight.com/
Tel: 613-344-2116 | Fax: 613.634.7029
993 Princess Street, Suite 212
Kingston, ON K7L 1H3, Canada 


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Form logic query

2012-04-23 Thread David
Hello

Given the following models:

CHOICES = (
(0, u'AM'),
(1, u'PM'),
)

class Person(models.Model):
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)

class PersonStuff(models.Model):
person = models.ForeignKey(Person)
stuff = model.CharField(max_length=255, choices=CHOICES)

How should I go about trying to create a form that looks like this:

PersonAstuff
PersonBstuff
PersonCstuff
PersonDstuff
PersonEstuff
PersonFstuff

This form should have one submit button and the whole form should be
processed in one go. Each instance of Person needs to be on a new row.

I've been messing about with formsets etc. and I can't achieve what I
want to. I was hoping another persons eyes may help.

Thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: restarting a django development server

2012-04-23 Thread Bill Freeman
You can "touch" one of the .py files.  That is, cause its last modified
date to become newer than that of its .pyc file by making it the current
time.

I suspect that you can do this (assuming that you don't want to run the
*nix "touch" command as a sub process, or don't have it because you
are on an OS that doesn't have it) by opening the file for writing, not
writing to it, and closing it again.  But note that I haven't tested this on
any platform, let alone yours.

The development server is actually two processes: the one you start
with manage, and the one actually running Django, which is started by
the first "driver" process.  The driver process then spends its time
watching for files to change, and when it sees one do so, it restarts
the server process.  However you can manage to implement touch on
your platform.

Note that this is specific to the development server.  But note that mod_wsgi
has a similar watch upon just the .wsgi file (which doesn't have to be
named with .wsgi, it's just the one that the WSGIScripAlias points to).

On 4/23/12, dummyman dummyman  wrote:
> basically i ve a form in a class CollFormAdmin where i am overriding two
> fields to MultipleChoiceField where values are changed dynamically based on
> a pickle file value
> then in CollAdmin class
>
>
> class CollAdmin(admin.ModelAdmin):
>
>form=CollFormAdmin
>
> but i want to change the value of MultipleChoiceField dynamically. But it
> appears like the class is loaded only once and the form is taking the
> previous old value ie d first one. Thats y i asked a way to restart the
> server in the code
>
> please help me
>
>
> On Mon, Apr 23, 2012 at 8:35 PM, dummyman dummyman
> wrote:
>
>> hi
>>
>> but how do i do it when the server is running ??
>> i basically want to stop it and restart it in the program
>> is it possible ?
>>
>> On Mon, Apr 23, 2012 at 6:54 PM, Joel Goldstick
>> wrote:
>>
>>> On Mon, Apr 23, 20ogr12 at 9:16 AM, Joel Goldstick
>>>
>>>  wrote:
>>> > On Mon, Apr 23, 2012 at 6:10 AM, dummyman dummyman 
>>> wrote:
>>> >> how to restart a django development server programmatically in python
>>> >> ?
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> Groups
>>> >> "Django users" group.
>>> >> To post to this group, send email to django-users@googlegroups.com.
>>> >> To unsubscribe from this group, send email to
>>> >> django-users+unsubscr...@googlegroups.com.
>>> >> For more options, visit this group at
>>> >> http://groups.google.com/group/django-users?hl=en.
>>> >
>>> > python manage.py runserver
>>> >
>>> oops I spoke too soon.  Didn't see you want to do this
>>> programatically.  But I suppose you could just invoke that line using
>>> subprocess?
>>> http://docs.python.org/library/subprocess.html#module-subprocess
>>> > --
>>> > Joel Goldstick
>>>
>>>
>>>
>>> --
>>> Joel Goldstick
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django deployment practices -- do people use setup.py?

2012-04-23 Thread Daniel Sokolowski
Both, system libraries and not python files --- anything outside of Python land 
that PIP can’t handle. How do you handle that if you want a self contained easy 
to deploy project?

From: Andrew Cutler 
Sent: Saturday, April 21, 2012 12:58 AM
To: django-users@googlegroups.com 
Subject: Re: Django deployment practices -- do people use setup.py?




On 18 April 2012 23:21, Daniel Sokolowski  
wrote:

  Can you clarify if you approach can handle things that are not installable 
through pip? For example I run into an issue with geodjango requirements - I 
was not able to get everything installed through PIP and had to resort to 
manually using the Debian package management.


Do you mean install requirements for system libraries, databases. That sort of 
thing? Or do you mean non python files, like scripts, documentation ? 

Cheers, Andrew


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Daniel Sokolowski
Web Engineer
Danols Web Engineering
http://webdesign.danols.com/
Office: 613-817-6833
Fax: 613-817-4553
Toll Free: 1-855-5DANOLS
Kingston, ON K7L 1H3, Canada



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: restarting a django development server

2012-04-23 Thread dummyman dummyman
awesome man :) it worked

On Mon, Apr 23, 2012 at 9:39 PM, Bill Freeman  wrote:

> You can "touch" one of the .py files.  That is, cause its last modified
> date to become newer than that of its .pyc file by making it the current
> time.
>
> I suspect that you can do this (assuming that you don't want to run the
> *nix "touch" command as a sub process, or don't have it because you
> are on an OS that doesn't have it) by opening the file for writing, not
> writing to it, and closing it again.  But note that I haven't tested this
> on
> any platform, let alone yours.
>
> The development server is actually two processes: the one you start
> with manage, and the one actually running Django, which is started by
> the first "driver" process.  The driver process then spends its time
> watching for files to change, and when it sees one do so, it restarts
> the server process.  However you can manage to implement touch on
> your platform.
>
> Note that this is specific to the development server.  But note that
> mod_wsgi
> has a similar watch upon just the .wsgi file (which doesn't have to be
> named with .wsgi, it's just the one that the WSGIScripAlias points to).
>
> On 4/23/12, dummyman dummyman  wrote:
> > basically i ve a form in a class CollFormAdmin where i am overriding two
> > fields to MultipleChoiceField where values are changed dynamically based
> on
> > a pickle file value
> > then in CollAdmin class
> >
> >
> > class CollAdmin(admin.ModelAdmin):
> >
> >form=CollFormAdmin
> >
> > but i want to change the value of MultipleChoiceField dynamically. But it
> > appears like the class is loaded only once and the form is taking the
> > previous old value ie d first one. Thats y i asked a way to restart the
> > server in the code
> >
> > please help me
> >
> >
> > On Mon, Apr 23, 2012 at 8:35 PM, dummyman dummyman
> > wrote:
> >
> >> hi
> >>
> >> but how do i do it when the server is running ??
> >> i basically want to stop it and restart it in the program
> >> is it possible ?
> >>
> >> On Mon, Apr 23, 2012 at 6:54 PM, Joel Goldstick
> >> wrote:
> >>
> >>> On Mon, Apr 23, 20ogr12 at 9:16 AM, Joel Goldstick
> >>>
> >>>  wrote:
> >>> > On Mon, Apr 23, 2012 at 6:10 AM, dummyman dummyman <
> tempo...@gmail.com>
> >>> wrote:
> >>> >> how to restart a django development server programmatically in
> python
> >>> >> ?
> >>> >>
> >>> >> --
> >>> >> You received this message because you are subscribed to the Google
> >>> Groups
> >>> >> "Django users" group.
> >>> >> To post to this group, send email to django-users@googlegroups.com.
> >>> >> To unsubscribe from this group, send email to
> >>> >> django-users+unsubscr...@googlegroups.com.
> >>> >> For more options, visit this group at
> >>> >> http://groups.google.com/group/django-users?hl=en.
> >>> >
> >>> > python manage.py runserver
> >>> >
> >>> oops I spoke too soon.  Didn't see you want to do this
> >>> programatically.  But I suppose you could just invoke that line using
> >>> subprocess?
> >>> http://docs.python.org/library/subprocess.html#module-subprocess
> >>> > --
> >>> > Joel Goldstick
> >>>
> >>>
> >>>
> >>> --
> >>> Joel Goldstick
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Django users" group.
> >>> To post to this group, send email to django-users@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> django-users+unsubscr...@googlegroups.com.
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/django-users?hl=en.
> >>>
> >>>
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Bus Error: 10 (Intro Tutorial)

2012-04-23 Thread Nikolas Stevenson-Molnar
I would try reinstalling Python and Django. This seemed to resolve the
issue of the original poster.

_Nik

On 4/21/2012 3:18 PM, James wrote:
> I just started receiving the same error "Bus error: 10". I made a
> small code change and
> it suddenly appeared. I've reverted but that doesn't seem to matter.
> Very odd behavior.
> I'll continue debugging. My settings:
>
> Python 2.7.1
> OS:X Lion 10.7.3
> Django 1.4.0
>
> James Leard
>
> On Apr 20, 7:58 am, Tom Evans  wrote:
>> On Thu, Apr 19, 2012 at 5:11 PM, Harald Sigh Andertun
>>
>>  wrote:
>>> I'm sorry. Actually that was not the solution. It works sometimes now, which
>>> it didn't before. I'll attach a screenshot.
>>> I'm on mac (OS X Lion).
>> A bus error occurs due to unaligned memory access, or access to a non
>> existent memory address. In the absence of an actual bug (which others
>> would see), this clearly indicates that one or another of the C
>> libraries used by python conflicts with it.
>>
>> This could happen if you compiled a C library to use with python, like
>> one of the many python packages that consist of a small C library
>> (mysql and postgresql DB adaptors, PIL, many others), and use it with
>> a different python than it was compiled against.
>>
>> It probably has very little to do with django - django is pure python
>> - but with one of the libraries that is used by django or your code.
>> The solution is simple; remove everything, start from scratch and
>> recompile/reinstall everything relevant.
>>
>> It is probably trickier as OS X does interesting things with python,
>> and most users end up with a system python and a user python. Making
>> sure your installed extensions are compiled and used with the right
>> python is then what is important.
>>
>> Cheers
>>
>> Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Jdango - What IDE to use?

2012-04-23 Thread Aaron C. de Bruyn
Ok--wiki page here:
https://code.djangoproject.com/wiki/DjangoResources#IntegratedDevelopmentEnvironments

Now we can stop the 'IDE' threads that come up every few weeks.  :)

It's not a complete list--I just wanted to bash something out quickly
and let others add their favorites that I missed.

-A

On Mon, Apr 23, 2012 at 08:45, Daniel Sokolowski
 wrote:
> To add: install the Eclipse "Marketplace Client" plugin and use that to
> locate your plugins.
>
> -Original Message- From: Daniel Sokolowski
> Sent: Monday, April 23, 2012 11:44 AM
> To: Django users
> Subject: Re: New to Jdango - What IDE to use?
>
>
> Eclipse + PyDev + whatever else you want; if you need it more often then not
> there is a plugin for it. This IDE just becomes more and more powerful as
> you keep learning it through use;  note  Aptana is a rebranded Eclipse+PyDev
> however I still prefer vanilla Eclipse + plugins.
>
> My list of plugins:
>
> Data Tools Platform Enablement Extender SDK
> 1.9.2.v201109161655-7I9O7XFE9Jfxu0wIxMQtoLz0X-dE
> org.eclipse.datatools.enablement.sdk.feature.feature.group    Eclipse Data
> Tools Platform
> Data Tools Platform Extender SDK
> 1.9.2.v201109161655-7PA37eFEpPYv5_Ae3-6EjC5ZX4e5
> org.eclipse.datatools.sdk.feature.feature.group    Eclipse Data Tools
> Platform
> Eclipse EGit    2.0.0.201204120545    org.eclipse.egit.feature.group
> Eclipse EGit
> Eclipse JGit    2.0.0.201204120530    org.eclipse.jgit.feature.group
> Eclipse JGit
> Eclipse SDK    4.2.0.I20110805-1200    org.eclipse.sdk.ide    null
> Eclipse Web Developer Tools
> 3.3.2.v20030500-7O7IFj6EMjB7yO1Xs_G1kMtQeOye6HTXFWve95_R
> org.eclipse.wst.web_ui.feature.feature.group    Eclipse Web Tools Platform
> Eclipse XML Editors and Tools
> 3.3.2.v201112072049-7H7EFZ7DxumTmce4khcSkIiqoD8eDMKlT8Oz011P
> org.eclipse.wst.xml_ui.feature.feature.group    Eclipse Web Tools Platform
> EGit Mylyn    2.0.0.201204120545    org.eclipse.egit.mylyn.feature.group
> Eclipse EGit
> JavaScript Development Tools    1.3.2.v201201112313-7G78FZvFC7sRekSz-g-nAlz
> org.eclipse.wst.jsdt.feature.feature.group    Eclipse Web Tools Platform
> Log Viewer Feature    0.9.8.8
> de.anbos.eclipse.logviewer.feature.feature.group    Andre Bossert
> Marketplace Client    1.1.1.I20110907-0947
> org.eclipse.epp.mpc.feature.group    Eclipse Packaging Project
> MercurialEclipse    1.9.1.v20302231    mercurialeclipse.feature.group
> MercurialEclipse project
> Mylyn Context Connector: Eclipse IDE    3.6.5.v20120215-0100
> org.eclipse.mylyn.ide_feature.feature.group    Eclipse Mylyn
> Mylyn Context Connector: Team Support    3.6.5.v20120215-0100
> org.eclipse.mylyn.team_feature.feature.group    Eclipse Mylyn
> Mylyn Task List    3.6.5.v20120215-0100
> org.eclipse.mylyn_feature.feature.group    Eclipse Mylyn
> Mylyn Task-Focused Interface    3.6.5.v20120215-0100
> org.eclipse.mylyn.context_feature.feature.group    Eclipse Mylyn
> Mylyn WikiText    1.5.5.v20120215-0100
> org.eclipse.mylyn.wikitext_feature.feature.group    Eclipse Mylyn
> PyDev for Eclipse    2.5.0.2012040618
> org.python.pydev.feature.feature.group    Aptana
> Pydev Mylyn Integration    0.3.0
> org.python.pydev.mylyn.feature.feature.group    Fabio Zadrozny
> Remote System Explorer End-User Runtime
> 3.3.2.R33x_v201110030150-7L7CFGH8wqio8s-qYtkPgn8qWd4T
> org.eclipse.rse.feature.group    Eclipse TM Project
> Remote System Explorer User Actions
> 1.1.300.v201103142315-31F8N8s7355353B75DD
> org.eclipse.rse.useractions.feature.group    Eclipse TM Project
> ReST Editor    1.0.5.201110101040
> org.psem2m.eclipse.rest.editor.feature.group    isandlaTech.com
> Smartsprites Eclipse Plugin    0.0.9
> de.bitexpert.eclipse.smartsprites.feature.feature.group    bitExpert AG
> Target Management Terminal
> 3.2.1.R33x_v201106281309-7N7B1BbVJv-SaPEOkhsVVd_C3752
> org.eclipse.tm.terminal.sdk.feature.group    Eclipse TM Project
> Windows Binaries for Mercurial (Recommended)    1.9.3.v201110131844
> com.intland.hgbinary.win32.feature.group    Intland Software
> YUI Compressor Eclipse Plugin    0.0.4
> de.bitexpert.eclipse.yuicompressor.feature.feature.group    bitExpert AG
>
>
> -Original Message- From: Houmie
> Sent: Saturday, April 21, 2012 2:05 PM
> To: Django users
> Subject: New to Jdango - What IDE to use?
>
> Hi everyone,
>
> I was wondering which IDE you guys are recommending to use?
> Important is ease of use and productivity. Price comes third if its
> not free.
>
> I tried already Aptana 3.0, but I get a weird error message upon
> creating Django projects:
> http://stackoverflow.com/questions/10261037/django-on-aptana-studio-3-0
>
> Highly appreciated,
> Houman
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl

Re: Bus Error: 10 (Intro Tutorial)

2012-04-23 Thread James
I found the problem. I had overridden __getattr__ and returned
self.value which did not yet exist on the object. This caused a
maximum recursion depth RuntimeError. I'm still not sure why this
became "Bus error: 10", however.

James Leard

On Apr 23, 1:31 pm, Nikolas Stevenson-Molnar 
wrote:
> I would try reinstalling Python and Django. This seemed to resolve the
> issue of the original poster.
>
> _Nik
>
> On 4/21/2012 3:18 PM, James wrote:
>
>
>
>
>
>
>
> > I just started receiving the same error "Bus error: 10". I made a
> > small code change and
> > it suddenly appeared. I've reverted but that doesn't seem to matter.
> > Very odd behavior.
> > I'll continue debugging. My settings:
>
> > Python 2.7.1
> > OS:X Lion 10.7.3
> > Django 1.4.0
>
> > James Leard
>
> > On Apr 20, 7:58 am, Tom Evans  wrote:
> >> On Thu, Apr 19, 2012 at 5:11 PM, Harald Sigh Andertun
>
> >>  wrote:
> >>> I'm sorry. Actually that was not the solution. It works sometimes now, 
> >>> which
> >>> it didn't before. I'll attach a screenshot.
> >>> I'm on mac (OS X Lion).
> >> A bus error occurs due to unaligned memory access, or access to a non
> >> existent memory address. In the absence of an actual bug (which others
> >> would see), this clearly indicates that one or another of the C
> >> libraries used by python conflicts with it.
>
> >> This could happen if you compiled a C library to use with python, like
> >> one of the many python packages that consist of a small C library
> >> (mysql and postgresql DB adaptors, PIL, many others), and use it with
> >> a different python than it was compiled against.
>
> >> It probably has very little to do with django - django is pure python
> >> - but with one of the libraries that is used by django or your code.
> >> The solution is simple; remove everything, start from scratch and
> >> recompile/reinstall everything relevant.
>
> >> It is probably trickier as OS X does interesting things with python,
> >> and most users end up with a system python and a user python. Making
> >> sure your installed extensions are compiled and used with the right
> >> python is then what is important.
>
> >> Cheers
>
> >> Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: restarting a django development server

2012-04-23 Thread Andy McKay
Change your code so you don't have to. Relying on a restart for that
is the wrong approach.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 'too many SQL variables' error with ModelMultipleChoiceField

2012-04-23 Thread akaariai
On Apr 23, 6:54 pm, "Daniel Sokolowski"
 wrote:
> +1
>
> I use SQlite3 on lower traffic production sites due to it's ease of install
> and deployment. Even though I only once I reached this 1000 variable limit I
> would like to see some django work around.

I thought a little more about this, and I find it unlikely that the
qs.filter() issue will ever be solved. The idea presented upthread
might work, but it will be a mess to implement. It adds some serious
complexity to the query generation: temp table creation, insertion
into the temp table, the where clause generation, and finally you need
to clean up the temp table. All this to work around a limitation in a
single database. An issue you can work around by recompiling SQLite.
Or you could just use a different database.

The implementation would need to be extremely good to have any chance
to get in. The work needed seems huge compared to what is gained.

So, as said upthread: there is only so much Django can hide about the
underlying database. The 1000 parameters limit for single query seems
to be one of those issues. If there is some easy trick Django will use
that. But the temp table workaround seems just too messy. Still, I
would be happy to be proven wrong here.

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How to create a custom widget?

2012-04-23 Thread Corbin Tarrant
I'm new to django and trying to create my first application and am having 
some difficulty. I created another post last week but haven't gotten any 
response. I did get some response in the IRC channel though and it was 
mentioned that I could use a custom widget to get the job done. I have been 
looking for a good example to help me learn more about widgets and how to 
create my own custom ones but I'm still stuck. 

I'm wondering if anyone knows of any good examples or tutorials to help me 
with this, or if someone would be so kind as to put a very basic example 
together.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/sNRMhTULRYgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to create a custom widget?

2012-04-23 Thread Corbin Tarrant
Here is my original post that describes what I'm trying to do: 
https://groups.google.com/forum/?fromgroups#!searchin/django-users/corbin/django-users/hJzxsm63WC8/AOD_NAoAhaYJ

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Y9PAcL-5lB4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



EmailMessage hangs in Windows

2012-04-23 Thread CrabbyPete
I am using
from django.core.mail   import  EmailMessage

and I have the following code
msg = EmailMessage ( subject   =  subject,
   body  =  body,
   from_email = sender,
   to  = receivers,
  bcc = bcc
)
try:
print "Mailing"
err = msg.send( fail_silently = False )
except Exception, e:
err = "Email Send Error " + str(e)
print err
else:
print "Mailed"

I am mailing a bunch of messages and every once in a while it hangs on
the send. I never know when, and it only happens with windows.

Any one else have this problem?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Updating custom permissions in a view

2012-04-23 Thread bfrederi
Does anyone know why create_permissions doesn't work (or throw any
errors) when used in a view, but works when I run the same code in the
manage.py shell?

## views.py ###
from django.db.models import get_app
from django.contrib.auth.management import create_permissions
from django.http import HttpResponseRedirect
from django.contrib.admin.views.decorators import
staff_member_required

@staff_member_required
def update_permissions_view(request):
"""Updates the permissions of the app"""
app = get_app('edit_record')
create_permissions(app, None, 2)
referrer_url = request.META.get('HTTP_REFERER', None)
return HttpResponseRedirect(referrer_url)

## models.py ###
import datetime, urllib2
from django.db import models
from django.conf import settings
from django.db.models import signals, get_app
from django.contrib.auth.models import User
from django.contrib.auth.management import create_permissions

def update_perms():
#Get Collection and Institution Permissions
coll_dict = eval(urllib2.urlopen(settings.VOCABULARIES
+'collections/py/').read())
inst_dict = eval(urllib2.urlopen(settings.VOCABULARIES
+'institutions/py/').read())
permissions = ()
for term in coll_dict['terms']:
created_perm = ('coll_'+term['name'], 'coll_'+term['name'],)
permissions += (created_perm,)
for term in inst_dict['terms']:
created_perm = ('inst_'+term['name'], 'inst_'+term['name'],)
permissions += (created_perm,)
#Add Metadata Editor and Metadata Publisher Permissions
permissions += (('metadata_editor', 'metadata_editor',),
('metadata_publisher', 'metadata_publisher',),)

return permissions

class Record(models.Model):
"""Defines the Record model """
STATUS_CHOICES = (
(0, 'Not Saved'),
(1, 'Saved'),
)

name = models.CharField(max_length=50, unique=True)
title = models.TextField()
data = models.TextField()
metadata_user = models.TextField()
metadata_save_date = models.DateTimeField(auto_now=True)
status = models.IntegerField(choices=STATUS_CHOICES)
hidden = models.BooleanField()

class Perms(models.Model):
class Meta:
permissions = update_perms()

def notify_admin(sender, instance, created, **kwargs):
'''Update permissions when a new user has been added.'''
if created:
app = get_app('edit_record')
create_permissions(app, None, 2)
signals.post_save.connect(notify_admin, sender=User)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Audio Streaming from server

2012-04-23 Thread atul khairnar
Can I stream the audio using Django without Icecast2? If yes, How?

On Apr 20, 12:12 pm, yati sagade  wrote:
> Hi,
> You need to be much more specific. If the problem is related to Django,
> someone will help you out. But if it is help with Icecast2 you're looking
> for, you should probably try their mailing lists/forums/IRC channel.
>
> Regards
>
> On Fri, Apr 20, 2012 at 12:15 PM, atul khairnar 
> wrote:
>
>
>
>
>
>
>
>
>
> > Hi,
> > I am writing an Internet Radio App. But when i start the app from the
> > localhost, it does not stream the audio. Streaming just stops. I tried to
> > use Icecast2 media streaming server, even it is not working. Or may be I am
> > not using it properly.
> > SO I wanted to ask how to stream audio from server to the client? Please
> > Help
>
> > --
> > Atul Khairnar
> > College of Engineering , Pune, India.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> Yati Sagade 
>
> Twitter: @yati_itay 
>
> Organizing member of TEDx 
> EasternMetropolitanBypasshttp://www.ted.com/tedx/events/4933https://www.facebook.com/pages/TEDx-EasternMetropolitanBypass/3377632...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: EmailMessage hangs in Windows

2012-04-23 Thread Phang Mulianto
Hi,

What s the error msg.. It should smtp error message.

Maybe your smtp mail server setting.what mta you use?

How many often you sent the email?

Maybe your smtp still busy processing other mail.
On Apr 24, 2012 7:42 AM, "CrabbyPete"  wrote:

> I am using
> from django.core.mail   import  EmailMessage
>
> and I have the following code
> msg = EmailMessage ( subject   =  subject,
>   body  =  body,
>   from_email = sender,
>   to  = receivers,
>  bcc = bcc
>)
>try:
>print "Mailing"
>err = msg.send( fail_silently = False )
>except Exception, e:
>err = "Email Send Error " + str(e)
>print err
>else:
>print "Mailed"
>
> I am mailing a bunch of messages and every once in a while it hangs on
> the send. I never know when, and it only happens with windows.
>
> Any one else have this problem?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.