Upgrade to 1.5 issues

2013-03-08 Thread jayhalleaux
So I have two questions:

1.  Changing LOGIN_REDIRECT to a named url.

Example:

settings.py:
LOGIN_REDIRECT = ??   // what do i set it to,  'tracklist:profile' gives me 
an unsafe redirect error

urls.py: // which one?  your root urls.py or your application urls.py
from django.conf.urls import include, patterns, url

urlpatterns = patterns('tracklist.views',
url(r'^accounts/profile/$', 'profile', name='profile'),
)

etc...


2.  Accessing user profile data from a session.

Example:

models.py

from django.contrib.auth.models import User

class UserProfile(models.Model):

user = models.ForeignKey(User, unique=True)
timestamp = models.DateTimeField(auto_now_add=True)


So in the above example if I get the User object from a session how do I 
get the session data.
Per the documentation it looks like it should be:

user = request.user

timestamp = user.userprofile.timestamp


I get that user does not have userprofile attribute.

Hopefully someone can help...


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




Re: p.choice_set.all() error

2013-03-08 Thread Hugo Guzman
Thanks for the feedback. It's much appreciated.

On Thursday, March 7, 2013 10:39:42 PM UTC-5, Hugo Guzman wrote:
>
> Hey there. I'm working through Part I of the "Writing your first Django 
> app" tutorial and everything was going smoothly until I tried executing the 
> following command:
>
> >>> p.choice_set.all()
>
> When I try running it I get the proceeding errors (below). I've attached 
> my models.py file for context. Any help or guidance would be much 
> appreciated.
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
> line 72, in __repr__
> data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
> line 87, in __len__
> self._result_cache.extend(self._iter)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
> line 291, in iterator
> for row in compiler.results_iter():
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
>  
> line 763, in results_iter
> for rows in self.execute_sql(MULTI):
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
>  
> line 818, in execute_sql
> cursor.execute(sql, params)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/util.py", 
> line 40, in execute
> return self.cursor.execute(sql, params)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>  
> line 114, in execute
> return self.cursor.execute(query, args)
>   File "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/cursors.py", 
> line 201, in execute
> self.errorhandler(self, exc, value)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/connections.py", 
> line 36, in defaulterrorhandler
> raise errorclass, errorvalue
> DatabaseError: (1054, "Unknown column 'polls_choice.choice_text' in 'field 
> list'")
>
>
>

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




Re: TestCase - send POST with m2m data?

2013-03-08 Thread Russell Keith-Magee
On Fri, Mar 8, 2013 at 7:52 PM, galgal  wrote:

> As in the topic - how can I prepare POST data dictionary in TestCase to
> send it via POST?
> I can see how it works in real admin POST in Chrome:
>
> --WebKitFormBoundaryEXChB8PRJPhaP3OQ
> Content-Disposition: form-data; name="visibly_usergroup" 1
> --WebKitFormBoundaryEXChB8PRJPhaP3OQ
> Content-Disposition: form-data; name="visibly_usergroup" 2
> --WebKitFormBoundaryEXChB8PRJPhaP3OQ
> Content-Disposition: form-data; name="visibly_usergroup" 5
>
> How to simulate that?
>

Hi,

You don't need to concern yourself about the POST data encoding -- you just
pass in a list of values instead of a single value to the data argument in
the test client.

self.client.post('/your/url/here'/, data={'visibly_usergroup':
['1','2','5']}

This is all covered in the docs; specifically on the section on POST
operation of the test client:

https://docs.djangoproject.com/en/1.5/topics/testing/overview/#django.test.client.Client.post

Yours,
Russ Magee %-)

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




Re: I screwed up my django site using touch

2013-03-08 Thread frocco
Thanks Sam

On Friday, March 8, 2013 2:13:36 PM UTC-5, Sam Solomon wrote:
>
> Here is something that may help:
>
> import importlib
>
> from django.conf import settings
>
> for app in settings.INSTALLED_APPS:
> views_name = "%s.views" % app
> try:
> importlib.import_module(views_name)
> except ImportError:
> pass
> except:
> print "Could not import %s" % views_name
> raise
>
> (This is assuming all views are named views.py and in the root of your 
> "installed apps")
>
> I just ran this from django shell but you could also make it a management 
> command.
>
> On Thursday, March 7, 2013 7:45:19 AM UTC-8, ke1g wrote:
>>
>> And a last stop gap, assuming the server is *nix, the find command will 
>> find all files
>> with changes newer than a given time (though the syntax can be squirrelly.
>>
>> On Thu, Mar 7, 2013 at 10:42 AM, Shawn Milochik wrote:
>>
>>> On Thu, Mar 7, 2013 at 10:38 AM, frocco  wrote:
>>> > Thanks you, I think I will only use Pycharm now to help prevent this 
>>> issue
>>> > again.
>>> > I hope future versions will offer better trace.
>>>
>>>
>>> Even better, use version control, such as git. Then your editor will
>>> be irrelevant and it will be trivial to find and revert any changes.
>>>
>>> --
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>

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




Re: Django Form Designer

2013-03-08 Thread Jason Arnst-Goodrich
I never knew this existed. I do hope someone continues development...

On Thursday, March 7, 2013 8:39:56 AM UTC-8, Daniele Procida wrote:
>
> I like and use Django Form Designer, <
> https://github.com/philomat/django-form-designer>, but it hasn't been 
> updated for a while and needs some work. 
>
> For example, it needs better docs and tests, while there are a number of 
> outstanding pull requests. 
>
> I'm hoping to hear back from Samuel Luescher, the author, about his plans 
> for it (if any). 
>
> In the meantime, is anyone else maintaining and updating a fork that I 
> should contribute to? There's <
> https://github.com/Raumkraut/django-form-designer> for example. 
>
> Daniele 
>
>

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




Re: cannot find unique constraint on easy_thumbnails_thumbnails while running jenkins

2013-03-08 Thread Jaimin Patel
Also while running I get this out put -

$ python manage.py jenkins
Creating test database for alias 'default'...
Got an error creating the test database: (1007, "Can't create database 
'test_abc'; database exists")
Destroying old test database 'default'...
Could not remove foreign key contraint: Cannot find a FOREIGN KEY 
constraint on table easy_thumbnails_source, column storage_new_id
Could not remove foreign key contraint: Cannot find a FOREIGN KEY 
constraint on table easy_thumbnails_thumbnail, column storage_new_id
EE..E.....EE.EE.EEE...EE...EEE..EE..E...EE..E.EEE..EE.F.

and it keeps going..

what does it mean? Is this got stuck somewhere?

On Friday, March 8, 2013 1:28:19 PM UTC-5, Jaimin Patel wrote:
>
>
> I am running into below error while running jenkins for my django project -
>
> File 
> "/Library/Python/2.7/site-packages/easy_thumbnails/migrations/0015_auto__del_unique_thumbnail_name_storage_hash__add_unique_thumbnail_sou.py",
>  
> line 12, in forwards
> db.delete_unique('easy_thumbnails_thumbnail', ['name', 'storage_hash'])
>   File "/Library/Python/2.7/site-packages/south/db/generic.py", line 479, 
> in delete_unique
> raise ValueError("Cannot find a UNIQUE constraint on table %s, columns 
> %r" % (table_name, columns))
> ValueError: Cannot find a UNIQUE constraint on table 
> easy_thumbnails_thumbnail, columns ['name', 'storage_hash']
>
> you can find the details error message -
>
> https://github.com/SmileyChris/easy-thumbnails/issues/208
>
> Any idea what might be wrong?
>
> Thanks.
>

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




Re: urls.py not loading changes

2013-03-08 Thread Bill Freeman
Well, nginx is a proxy to the fastCGI application.  So you can't access it
from the usual URL when
nginx is stopped, but that doesn't mean that the process to which you
proxy, which is running
Django, has stopped.

On Fri, Mar 8, 2013 at 3:11 PM, Asier Hernández Juanes <
asiertxo...@gmail.com> wrote:

> Maybe fastCGI but when I stop the nginx server with /etc/init.d/nginx stop
> the application is not loading.
>
> I have seen some fastCGI configuration inside nginx server but I don't
> know how to restart fastCGI process or Django process itself.
>
> How can I do that?
>
> El viernes, 8 de marzo de 2013 20:04:34 UTC+1, Javier Guerra escribió:
>>
>> On Sun, Mar 3, 2013 at 8:16 AM, Asier Hernández Juanes
>>  wrote:
>> > i have a remote Linux server with a Django application running in a
>> nginx
>> > server
>>
>> Django application's don't run in the nginx server.  There must be
>> some other process running your app.  Either uWSGI, gunicorn, FastCGI,
>> etc.
>>
>>
>> On Fri, Mar 8, 2013 at 12:14 PM, Asier Hernández Juanes
>>  wrote:
>> > I have removed the .py and the .pyc files, restart the nginx server and
>> the
>> > application is still working.
>>
>> you have to restart the Django process to make it reload the new code.
>>
>>
>> --
>> Javier
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Urls on the fly

2013-03-08 Thread Bill Freeman
That is weird.  I don't know why 2 shouldn't satisfy a need for 2.

As far as a work around goes, one doesn't need to use url() to make a url
pattern.
Just a tuple with those two members will do it.  I think of url() as a way
to
specify a pattern name without specifying the extra dict.

Unless things have changed.

But I think that your call to patterns() is wrong.  The patterns are
additional
arguments, not a list of patterns, at least as normally used.  So:

urlpatterns = patterns("", *url_list)

On Fri, Mar 8, 2013 at 2:03 PM, Serge G. Spaolonzi wrote:

> I am looking the way to create urls on the fly.
> This is a simplified version of the code I am using:
>
> def get_urls():
> url_list = []
> for code in external_code_list:
> url_list.append(
> url(r'^%s/$' % code,
> view
> )
> )
> urlpatterns = patterns('', url_list)
> return urlpatterns
>
>
> urlpatterns = get_urls()
>
> It throws "url() takes at least 2 arguments (2 given)"
>
> Any idea?
>
> Thanks
>
> --
> Serge G. Spaolonzi
> Cobalys Systems
> http://www.cobalys.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: urls.py not loading changes

2013-03-08 Thread Asier Hernández Juanes
Maybe fastCGI but when I stop the nginx server with /etc/init.d/nginx stop 
the application is not loading.

I have seen some fastCGI configuration inside nginx server but I don't know 
how to restart fastCGI process or Django process itself.

How can I do that?

El viernes, 8 de marzo de 2013 20:04:34 UTC+1, Javier Guerra escribió:
>
> On Sun, Mar 3, 2013 at 8:16 AM, Asier Hernández Juanes 
>  wrote: 
> > i have a remote Linux server with a Django application running in a 
> nginx 
> > server 
>
> Django application's don't run in the nginx server.  There must be 
> some other process running your app.  Either uWSGI, gunicorn, FastCGI, 
> etc. 
>
>
> On Fri, Mar 8, 2013 at 12:14 PM, Asier Hernández Juanes 
>  wrote: 
> > I have removed the .py and the .pyc files, restart the nginx server and 
> the 
> > application is still working. 
>
> you have to restart the Django process to make it reload the new code. 
>
>
> -- 
> Javier 
>

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




Re: How can my JQuery Sliderbar pass a value to the Veiw and cause the View to execute?

2013-03-08 Thread Shawn Milochik
You'll need to attach something to the "change" event of your slider
to execute a JavaScript function.

The function would contain something like this:

//  $.ajax({

//  url: your_url,
//  cache: 'false',
//  success: function (resp){ do_something(resp); },
//  type: "POST",
//  data: your_data_here

//  })

Then your "success" function would contain (or call) the JavaScript to
make whatever changes in the DOM you want to make.

This is a minimal example. Once you have something working, you'll
probably want to implement a way to prevent your function from firing
too many times as someone is playing with the UI.

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




Re: I screwed up my django site using touch

2013-03-08 Thread Sam Solomon
Here is something that may help:

import importlib

from django.conf import settings

for app in settings.INSTALLED_APPS:
views_name = "%s.views" % app
try:
importlib.import_module(views_name)
except ImportError:
pass
except:
print "Could not import %s" % views_name
raise

(This is assuming all views are named views.py and in the root of your 
"installed apps")

I just ran this from django shell but you could also make it a management 
command.

On Thursday, March 7, 2013 7:45:19 AM UTC-8, ke1g wrote:
>
> And a last stop gap, assuming the server is *nix, the find command will 
> find all files
> with changes newer than a given time (though the syntax can be squirrelly.
>
> On Thu, Mar 7, 2013 at 10:42 AM, Shawn Milochik 
>  > wrote:
>
>> On Thu, Mar 7, 2013 at 10:38 AM, frocco  
>> wrote:
>> > Thanks you, I think I will only use Pycharm now to help prevent this 
>> issue
>> > again.
>> > I hope future versions will offer better trace.
>>
>>
>> Even better, use version control, such as git. Then your editor will
>> be irrelevant and it will be trivial to find and revert any changes.
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>

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




Re: urls.py not loading changes

2013-03-08 Thread Javier Guerra Giraldez
On Sun, Mar 3, 2013 at 8:16 AM, Asier Hernández Juanes
 wrote:
> i have a remote Linux server with a Django application running in a nginx
> server

Django application's don't run in the nginx server.  There must be
some other process running your app.  Either uWSGI, gunicorn, FastCGI,
etc.


On Fri, Mar 8, 2013 at 12:14 PM, Asier Hernández Juanes
 wrote:
> I have removed the .py and the .pyc files, restart the nginx server and the
> application is still working.

you have to restart the Django process to make it reload the new code.


--
Javier

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




Urls on the fly

2013-03-08 Thread Serge G. Spaolonzi
I am looking the way to create urls on the fly.
This is a simplified version of the code I am using:

def get_urls():
url_list = []
for code in external_code_list:
url_list.append(
url(r'^%s/$' % code,
view
)
)
urlpatterns = patterns('', url_list)
return urlpatterns


urlpatterns = get_urls()

It throws "url() takes at least 2 arguments (2 given)"

Any idea?

Thanks

-- 
Serge G. Spaolonzi
Cobalys Systems
http://www.cobalys.com

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




Re: How can my JQuery Sliderbar pass a value to the Veiw and cause the View to execute?

2013-03-08 Thread 7equivalents
Ok, thanks Shawn, still having a bit of  a snag. I have read the JQuery doc 
on $.ajax, but still don't have a complete grasp... So here is my next 
question,

I added this to my sliderbar script:

var args = { type:"POST", url:"/slider/" }
$.ajax(args);

Would those two lines of code cause my slider_page View to execute 
(assuming of coarse the url is correct)?

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




cannot find unique constraint on easy_thumbnails_thumbnails while running jenkins

2013-03-08 Thread Jaimin Patel

I am running into below error while running jenkins for my django project -

File 
"/Library/Python/2.7/site-packages/easy_thumbnails/migrations/0015_auto__del_unique_thumbnail_name_storage_hash__add_unique_thumbnail_sou.py",
 
line 12, in forwards
db.delete_unique('easy_thumbnails_thumbnail', ['name', 'storage_hash'])
  File "/Library/Python/2.7/site-packages/south/db/generic.py", line 479, 
in delete_unique
raise ValueError("Cannot find a UNIQUE constraint on table %s, columns 
%r" % (table_name, columns))
ValueError: Cannot find a UNIQUE constraint on table 
easy_thumbnails_thumbnail, columns ['name', 'storage_hash']

you can find the details error message -

https://github.com/SmileyChris/easy-thumbnails/issues/208

Any idea what might be wrong?

Thanks.

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




Re: how to automatically create userprofile when user is created from admin

2013-03-08 Thread Shawn Milochik
Yes. Use a post-save signal.

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




how to automatically create userprofile when user is created from admin

2013-03-08 Thread frocco
Hello,

right now, if I create a user in admin, I have to also create their 
userprofile that I have defined in settings.

Is there a way to automate this?

Thanks


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




Re: urls.py not loading changes

2013-03-08 Thread Asier Hernández Juanes
I have removed the .py and the .pyc files, restart the nginx server and the 
application is still working.

I think the alication is being cached or I have the application duplicated 
but I am not able to find the solution.

Some ideas?

Thanks!

El lunes, 4 de marzo de 2013 19:30:32 UTC+1, ke1g escribió:
>
> Yes.  So it is best to select transfer mechanisms that set the modified 
> time of the .py file to the target machine's current time at the moment 
> that the newly written copy is closed, rather than caring about the 
> modified time on the source machine.
>
> Most mechanisms do this by default (cp, mercurial checkout/update, tar).  
> You usually have to go out of your way to get the modified (and created and 
> accessed time) reflected from the source to the target.  If doing that, 
> don't.  If your mechanism preserves modified time by default (maybe rsync?) 
> see if you can't surpress it.  Or "touch" the file after transfer.
>
> On Mon, Mar 4, 2013 at 11:03 AM, Venkatraman S  > wrote:
>
>> Well, it so happens that when you ftp the file from your local box to a 
>> remote machine the timezones are mostly different. For eg. i am in India 
>> and we are 'ahead' of the US, so when i push my code to a server in US 
>> timezone, i see this problem most often.
>>
>>
>> On Mon, Mar 4, 2013 at 8:26 PM, Bill Freeman > > wrote:
>>
>>> This should not be a .pyc problem, since upon startup python compares 
>>> the modified time of the .pyc to that of the .py, if available.
>>>
>>> python will use the .pyc if it can't see the .py .  I don't know what it 
>>> will do if the .py is there, but it doesn't have permission to read it 
>>> (possible permissions issue).
>>>
>>> The other way this could be a .pyc problem is if the .py file was 
>>> updated in such a way that the modified time is left older than that of the 
>>> .pyc (differences in time setting on the two machines, some funky transfer 
>>> mechanism that sets the target modified time to match that of the source, 
>>> where the .pyc is newer, or the machine time was messed up the first time 
>>> the app was started, yielding a .pyc modified time far in the future).
>>>
>>> When I've had troubles like this it has more often been that I've had 
>>> two copies of the site on the deployment box, and I've been fixing the 
>>> wrong one.
>>>
>>> Bill
>>>
>>> On Mon, Mar 4, 2013 at 9:03 AM, frocco >> >wrote:
>>>
 That's good to know.


 On Monday, March 4, 2013 8:12:15 AM UTC-5, Venkatraman.S. wrote:

> Always prefer to delete the .pyc fie for issues such as these wherein 
> changes are not reflected despite server restart.
>
> On Sun, Mar 3, 2013 at 9:59 PM, Serge G. Spaolonzi 
> wrote:
>
>> Maybe the server is loading an old .pyc file. try to delete the 
>> urls.pyc file and restart the server. 
>>  
>>
>> On Sun, Mar 3, 2013 at 11:16 AM, Asier Hernández Juanes <
>> asier...@gmail.com> wrote:
>>
>>> Hi everyone,
>>>
>>> i have a remote Linux server with a Django application running in a 
>>> nginx server but when I make a change in urls.py like adding a new 
>>> urlpattern the server is not applying the changes. I have restarted 
>>> nginx 
>>> server but the new url is not loading.
>>>
>>> Does anyone know what may be the problem?
>>>
>>> Thanks a lot! 
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, 
>>> send an email to django-users...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at http://groups.google.com/**
>>> group/django-users?hl=en
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>  
>>>  
>>>
>>
>>
>>
>> -- 
>> Serge G. Spaolonzi
>> Cobalys Systems
>> http://www.cobalys.com
>>  
>> -- 
>> You received this message because you are subscribed to the Google 
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to django-users...@**googlegroups.com.
>> To post to this group, send email to django...@googlegroups.com.
>>
>> Visit this group at http://groups.google.com/**
>> group/django-users?hl=en
>> .
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out
>> .
>>  
>>  
>>
>
>  -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" 

Re: Question modelformset_factory with initial values

2013-03-08 Thread carlos
Thanks Tom you were right but I had several mistakes and resolved to

thank you very much :)

Cheers


On Fri, Mar 8, 2013 at 8:56 AM, Tom Evans  wrote:

> On Fri, Mar 8, 2013 at 4:42 AM, carlos  wrote:
> >
> > Hi
> > is posible fill forms with initial values for example
> >
> > -- models.py -
> > class Model1(models.Model):
> > field1 = models.CharField()
> > field2 =models.CharField()
> >
> > CHOICE_ONE = (
> >   (1,'one'),
> >   (2, 'two'),
> >   (3, 'three'),
> >   (4, 'four')
> > )
> > class Model2(models.Model):
> >  field_fk = fk(Model1)
> >  field2 = models.IntegerField(choices=CHOICE_ONE)
> >  field3 = IntegerField()
> >  field4 = IntegerField()
> >
> > - forms.py ---
> >
> > class Model2Form(forms.ModelForm):
> >
> > class Meta:
> > model = Model2
> > exclude = ('field_fk',)
> >
> > -- views.py --
> >
> > def name_views(request):
> > initial_one = [{'field2':'one'},
> > {'field2':'two'},
> > {'field2':'three '},
> > {'field2':' four'},
> >]
> > form1FormSet = modelformset_factory(Model2, formModel2Form=,extra=4)
> > if request.method == "POST":
> > form1 = Model2Form(request.POST)
> > if form1.is_valid():
> > form1.save()
> >else:
> > form1 = form1FormSet(initial=initial_one)
> >
> > return render_to_response('template_form1.html',{'form1':form1},
> >   context_instance=RequestContext(request))
> >
> > -- template_form1.html 
> >
> >{% csrf_token %}
> >   {{form1.management_form}}
> >
> >   {%for fila in form1.forms%}
> >{{ fila }}
> >   {%endfor%}
> >
> > but this no working the output is
> >
> >
> > but i need to appear so
> >
> >
> >
> > the words in red are the options
> >
> > which is the right way to do better and if possible do that
> >
> > additionally I read this but it's not like my model
> >
> https://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-initial-data-with-a-formset
> >
> > Cheers
>
> Your initial values possibly don't appear because they are not valid
> choices for that field - you've given it the text value of the choice,
> it is expecting the data value, eg 1, not 'One'.
>
> Additionally, your formset handling appears to be incorrect. Before
> submission, you create an instance of your formset, yet after
> submission you create an instance of your model form to try and save
> it.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: How do i set div dynamically in template?

2013-03-08 Thread frocco
Thank you, I found it.

On Friday, March 8, 2013 9:51:00 AM UTC-5, Laurent Meunier wrote:
>
> On 08/03/2013 15:34, frocco wrote: 
> > Hello 
> > 
> > I need to have a div set the on the first pass and then changed on the 
> > second pass 
> > 
> > for row in data 
> > first row 
> > 
> > 
> > 
> > second row 
> > endfor 
> > 
> > in PHP I could just assign a variable to the div and change it. 
> > How would I do this in django? 
> > 
>
> Hi, 
>
> In your {% for %} loop, you can access a special variable named forloop, 
> and you can do something like this: 
>
> {% for row in data %} 
>{% if forloop.first %} 
>  // do something 
>{% endif %} 
>... 
> {% endfor %} 
>
>
> The complet list of available variables are in the doc: 
> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#for 
>
> -- 
> Laurent Meunier  
>

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




Re: How do i set div dynamically in template?

2013-03-08 Thread Laurent Meunier

On 08/03/2013 15:34, frocco wrote:

Hello

I need to have a div set the on the first pass and then changed on the
second pass

for row in data
first row

   

second row
endfor

in PHP I could just assign a variable to the div and change it.
How would I do this in django?



Hi,

In your {% for %} loop, you can access a special variable named forloop, 
and you can do something like this:


{% for row in data %}
  {% if forloop.first %}
// do something
  {% endif %}
  ...
{% endfor %}


The complet list of available variables are in the doc:
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#for

--
Laurent Meunier 

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




Re: How do i set div dynamically in template?

2013-03-08 Thread frocco
Thanks Tom

On Friday, March 8, 2013 9:45:34 AM UTC-5, Tom Evans wrote:
>
> On Fri, Mar 8, 2013 at 2:34 PM, frocco  
> wrote: 
> > Hello 
> > 
> > I need to have a div set the on the first pass and then changed on the 
> > second pass 
> > 
> > for row in data 
> >first row 
> > 
> >
> > 
> >second row 
> > endfor 
> > 
> > in PHP I could just assign a variable to the div and change it. 
> > How would I do this in django? 
> > 
> > Thanks 
>
> Presumably, in a template? 
>
> https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#for 
>
> Cheers 
>
> Tom 
>

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




Re: Question modelformset_factory with initial values

2013-03-08 Thread Tom Evans
On Fri, Mar 8, 2013 at 4:42 AM, carlos  wrote:
>
> Hi
> is posible fill forms with initial values for example
>
> -- models.py -
> class Model1(models.Model):
> field1 = models.CharField()
> field2 =models.CharField()
>
> CHOICE_ONE = (
>   (1,'one'),
>   (2, 'two'),
>   (3, 'three'),
>   (4, 'four')
> )
> class Model2(models.Model):
>  field_fk = fk(Model1)
>  field2 = models.IntegerField(choices=CHOICE_ONE)
>  field3 = IntegerField()
>  field4 = IntegerField()
>
> - forms.py ---
>
> class Model2Form(forms.ModelForm):
>
> class Meta:
> model = Model2
> exclude = ('field_fk',)
>
> -- views.py --
>
> def name_views(request):
> initial_one = [{'field2':'one'},
> {'field2':'two'},
> {'field2':'three '},
> {'field2':' four'},
>]
> form1FormSet = modelformset_factory(Model2, formModel2Form=,extra=4)
> if request.method == "POST":
> form1 = Model2Form(request.POST)
> if form1.is_valid():
> form1.save()
>else:
> form1 = form1FormSet(initial=initial_one)
>
> return render_to_response('template_form1.html',{'form1':form1},
>   context_instance=RequestContext(request))
>
> -- template_form1.html 
>
>{% csrf_token %}
>   {{form1.management_form}}
>
>   {%for fila in form1.forms%}
>{{ fila }}
>   {%endfor%}
>
> but this no working the output is
>
>
> but i need to appear so
>
>
>
> the words in red are the options
>
> which is the right way to do better and if possible do that
>
> additionally I read this but it's not like my model
> https://docs.djangoproject.com/en/dev/topics/forms/formsets/#using-initial-data-with-a-formset
>
> Cheers

Your initial values possibly don't appear because they are not valid
choices for that field - you've given it the text value of the choice,
it is expecting the data value, eg 1, not 'One'.

Additionally, your formset handling appears to be incorrect. Before
submission, you create an instance of your formset, yet after
submission you create an instance of your model form to try and save
it.

Cheers

Tom

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




Re: django templates - iterate over several lists

2013-03-08 Thread Roberto López López

Thank you very much!


On 03/08/2013 03:12 PM, Javier Guerra Giraldez wrote:
> On Fri, Mar 8, 2013 at 5:07 AM, Roberto López López
>  wrote:
>> I'd like to avoid having to concatenate them in the view and pass that
>> as another parameter.
> 
> 
> two ideas come to mind:
> 
> - itertools.chain() on the view.  it's equivalent to concatenating,
> but done lazily, so there's _very_ little overhead.
> 
> - add them in the template.  the 'add' filter is supposed to work with
> lists too.
> 
> needless to say, i'd far prefer the first option.  view functions are
> supposed to gather and organize all the info and templates should have
> as little behaviour as possible.
> 
> 

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




Re: How do i set div dynamically in template?

2013-03-08 Thread Tom Evans
On Fri, Mar 8, 2013 at 2:34 PM, frocco  wrote:
> Hello
>
> I need to have a div set the on the first pass and then changed on the
> second pass
>
> for row in data
>first row
>
>   
>
>second row
> endfor
>
> in PHP I could just assign a variable to the div and change it.
> How would I do this in django?
>
> Thanks

Presumably, in a template?

https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#for

Cheers

Tom

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




How do i set div dynamically in template?

2013-03-08 Thread frocco
Hello

I need to have a div set the on the first pass and then changed on the 
second pass

for row in data
   first row

  

   second row 
endfor

in PHP I could just assign a variable to the div and change it.
How would I do this in django?

Thanks

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




Re: p.choice_set.all() error

2013-03-08 Thread Tom Evans
On Fri, Mar 8, 2013 at 3:39 AM, Hugo Guzman  wrote:
> Hey there. I'm working through Part I of the "Writing your first Django app"
> tutorial and everything was going smoothly until I tried executing the
> following command:
>
 p.choice_set.all()
>
> When I try running it I get the proceeding errors (below). I've attached my
> models.py file for context. Any help or guidance would be much appreciated.
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py",
> line 72, in __repr__
> data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py",
> line 87, in __len__
> self._result_cache.extend(self._iter)
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py",
> line 291, in iterator
> for row in compiler.results_iter():
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
> line 763, in results_iter
> for rows in self.execute_sql(MULTI):
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
> line 818, in execute_sql
> cursor.execute(sql, params)
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/util.py",
> line 40, in execute
> return self.cursor.execute(sql, params)
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
> line 114, in execute
> return self.cursor.execute(query, args)
>   File "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/cursors.py",
> line 201, in execute
> self.errorhandler(self, exc, value)
>   File
> "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/connections.py", line
> 36, in defaulterrorhandler
> raise errorclass, errorvalue
> DatabaseError: (1054, "Unknown column 'polls_choice.choice_text' in 'field
> list'")

This means that the database table exists, but it is missing a field
that is in your models.py.

This normally means you have changed your model after you created the table.

Django cannot automatically modify your DB tables when you change your
models.py (although there are packages like django-south that help you
manage making the changes), so you need to either manually modify the
table, or remove the table and re-run 'python manage.py syncdb', which
will re-create it (without any data).

Cheers

Tom

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




Re: p.choice_set.all() error

2013-03-08 Thread Victor Rocha
The only thing I can think of it is that your database is not up-to-date 
with your models. You could drop the database and do a syncdb, otherwise 
using south to migrate your database schema could be an option.

Good luck,
Victor Rocha
RochApps 

On Thursday, March 7, 2013 10:39:42 PM UTC-5, Hugo Guzman wrote:
>
> Hey there. I'm working through Part I of the "Writing your first Django 
> app" tutorial and everything was going smoothly until I tried executing the 
> following command:
>
> >>> p.choice_set.all()
>
> When I try running it I get the proceeding errors (below). I've attached 
> my models.py file for context. Any help or guidance would be much 
> appreciated.
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
> line 72, in __repr__
> data = list(self[:REPR_OUTPUT_SIZE + 1])
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
> line 87, in __len__
> self._result_cache.extend(self._iter)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
> line 291, in iterator
> for row in compiler.results_iter():
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
>  
> line 763, in results_iter
> for rows in self.execute_sql(MULTI):
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
>  
> line 818, in execute_sql
> cursor.execute(sql, params)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/util.py", 
> line 40, in execute
> return self.cursor.execute(sql, params)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>  
> line 114, in execute
> return self.cursor.execute(query, args)
>   File "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/cursors.py", 
> line 201, in execute
> self.errorhandler(self, exc, value)
>   File 
> "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/connections.py", 
> line 36, in defaulterrorhandler
> raise errorclass, errorvalue
> DatabaseError: (1054, "Unknown column 'polls_choice.choice_text' in 'field 
> list'")
>
>
>

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




Re: django templates - iterate over several lists

2013-03-08 Thread Javier Guerra Giraldez
On Fri, Mar 8, 2013 at 5:07 AM, Roberto López López
 wrote:
> I'd like to avoid having to concatenate them in the view and pass that
> as another parameter.


two ideas come to mind:

- itertools.chain() on the view.  it's equivalent to concatenating,
but done lazily, so there's _very_ little overhead.

- add them in the template.  the 'add' filter is supposed to work with
lists too.

needless to say, i'd far prefer the first option.  view functions are
supposed to gather and organize all the info and templates should have
as little behaviour as possible.


-- 
Javier

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




no way to delete auth_messages

2013-03-08 Thread Yanhong Wu
Hi,

I created an database router to try using multiple databases. I copied the
example router in  this page:
https://docs.djangoproject.com/en/1.3/topics/db/multi-db/ .

Almost everything is ok, however, it seems that I cannot delete an
auth_message. The log said:

DELETE command denied to user 'user_readonly'@'192.168.1.1' for table
'auth_message'

it seemed the delete command had gone to slave database, why delete not
using db_for_write, which is default the master db.

If anyone have met such a problem? I googled a lot, but found nothing.



-- 
*samuel*

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




Re: Get all objects that don't belong to M2M

2013-03-08 Thread galgal
I think that did the trick:

*Product.objects.filter(subproducts__isnull=True)*

On Friday, March 8, 2013 1:50:47 PM UTC+1, Martin J. Laubach wrote:
>
> Something like this (totally untested though)
>
> Product.objects.exclude(pk__in=Product.subproducts.through.values_list(
> 'product_id', flat=True))
>
> perhaps?
>
>   Cheers,
>
> mjl
>
>
>
>
>
>
>

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




Re: How can my JQuery Sliderbar pass a value to the Veiw and cause the View to execute?

2013-03-08 Thread Shawn Milochik
I think we've come all the way around to where my response is now
appropriate. :o)

https://groups.google.com/d/msg/django-users/kB27nmftPng/btPKtxvoumYJ

Shawn

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




Re: Get all objects that don't belong to M2M

2013-03-08 Thread Martin J. Laubach
Something like this (totally untested though)

Product.objects.exclude(pk__in=Product.subproducts.through.values_list(
'product_id', flat=True))

perhaps?

  Cheers,

mjl






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




Get all objects that don't belong to M2M

2013-03-08 Thread galgal


I have a model with field:

class Product(models.Model):
subproducts = models.ManyToManyField("self", blank=True)

I need to overwrite admin's field queryset, to display only that objects 
that don't belong to any m2m relation. I have no idea how to get them.

So if I have: product1, product2, product3, product4.

product1 contains in subproducts: product2

I need a query that will get, in that situation, product3 and product4

Any idea how to get that?

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




Django + WSGI + CsrfViewMiddleware = ?

2013-03-08 Thread Konstantin

I am running Django 1.3  with Apache and mod_wsgi. I followed these
instructions, https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
to display a simple page, which contains a form, and which sends the
data back via POST.

Everything is fine with GET requests. However, when I do POST, I get
an error: Forbidden (403), "CSRF token missing or incorrect".

The django.middleware.csrf.CsrfViewMiddleware component is added to
the MIDDLEWARE_CLASSES list. The html form contains the {% csrf_token
%} tag. I can verify that in the form sent on GET, this tag is
replaced with the hidden input field:



I also use RequestContext in the django views code.

When the form is POSTed back, the CsrfViewMiddleware expects to find a
cookie with a specific name, and if found, it sets the csrf_token
variable:

  csrf_token =
_sanitize_token( request.COOKIES[settings.CSRF_COOKIE_NAME])

Then, for the POST request, it expects to find a specific data inside
request.POST:

  if request.method == "POST":
request_csrf_token =
request.POST.get('csrfmiddlewaretoken', '')

The error I am seeing happens when these two values are not equal.
Indeed, in my case, the csrf_token is set to the value above, and the
request_csrf_token is empty. Moreover, request.POST comes completely
empty when it reaches the CsrfViewMiddleware filter. It is known that
mod_wsgi sends POST data in request.META['wsgi.input'], which somehow
needs to be parsed.

Django documentation advises against accessing POST data in the
middleware (something breaks down the road), with CsrfViewMiddleware
being an exception. But even if I stick another custom component just
before CsrfViewMiddleware in the MIDDLEWARE_CLASSES list, which would
read and parse the request.META['wsgi.input'] data, I will not be able
to pass the value to CsrfViewMiddleware via POST because it is read
only.

So, my question is, how this is supposed to work? What am I missing?

Thanks.
Konstantin.


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




p.choice_set.all() error

2013-03-08 Thread Hugo Guzman
Hey there. I'm working through Part I of the "Writing your first Django 
app" tutorial and everything was going smoothly until I tried executing the 
following command:

>>> p.choice_set.all()

When I try running it I get the proceeding errors (below). I've attached my 
models.py file for context. Any help or guidance would be much appreciated.

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
line 72, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
  File 
"/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
line 87, in __len__
self._result_cache.extend(self._iter)
  File 
"/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/query.py", 
line 291, in iterator
for row in compiler.results_iter():
  File 
"/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
 
line 763, in results_iter
for rows in self.execute_sql(MULTI):
  File 
"/home/hugodev/dev/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
 
line 818, in execute_sql
cursor.execute(sql, params)
  File 
"/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/util.py", 
line 40, in execute
return self.cursor.execute(sql, params)
  File 
"/home/hugodev/dev/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
 
line 114, in execute
return self.cursor.execute(query, args)
  File "/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/cursors.py", 
line 201, in execute
self.errorhandler(self, exc, value)
  File 
"/home/hugodev/dev/lib/python2.7/site-packages/MySQLdb/connections.py", 
line 36, in defaulterrorhandler
raise errorclass, errorvalue
DatabaseError: (1054, "Unknown column 'polls_choice.choice_text' in 'field 
list'")


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


from django.db import models

import datetime
from django.utils import timezone

# Create your models here.
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.question
def was_published_recently(self):
return self.pub_date >= timezone.now() - datetime.timedelta(days=1)


class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __unicode__(self):
return self.choice_text








TestCase - send POST with m2m data?

2013-03-08 Thread galgal
As in the topic - how can I prepare POST data dictionary in TestCase to 
send it via POST?
I can see how it works in real admin POST in Chrome:

--WebKitFormBoundaryEXChB8PRJPhaP3OQ
Content-Disposition: form-data; name="visibly_usergroup" 1
--WebKitFormBoundaryEXChB8PRJPhaP3OQ
Content-Disposition: form-data; name="visibly_usergroup" 2
--WebKitFormBoundaryEXChB8PRJPhaP3OQ
Content-Disposition: form-data; name="visibly_usergroup" 5

How to simulate that? 

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




django recaptcha

2013-03-08 Thread Xavier Pegenaute

Dear,

I am using your django-recaptcha application but I am havig a problem. 
Seems the validation step is not done properly ONLY if I use the 
javascript code.


I've edited the django/forms/widgets.py file and added print data at 
line 209 (I am using django 1.5), once I am filling the form and click 
on submit, the console output is this one:


u'csrfmiddlewaretoken': [u'oblablaq'], u'email': [u'x...@xx.xx'], 
u'password2': [u'1']}>


And here is missing the 'recaptcha_response_field' key. Therefore, it is 
not possible to validate with the google servers.


The javascript generated inside django is this one:
-
 name='csrfmiddlewaretoken' value='oblablaq' />
Recaptcha:class="errorlist">This field is required.type="text/javascript">
var DjangoRecaptchaOptions = {
  "lang": "en"
};
if (typeof RecaptchaOptions !== 'object') {
RecaptchaOptions = DjangoRecaptchaOptions;
} else {
for (key in DjangoRecaptchaOptions) {
RecaptchaOptions[key] = DjangoRecaptchaOptions[key];
}
}

src="http://www.google.com/recaptcha/api/challenge?k=6blablaEhC&hl=en";>


  src="http://www.google.com/recaptcha/api/noscript?k=6blablahC=en; 
height="300" width="500" frameborder="0">

  
  value='manual_challenge' />






-

Shouldn't exist a input tag with a name attribute with the name 
'recaptcha_response_field' and the response of the google key?


Thanks a lot,
Xavi

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




Re: how to get value of anchor tag which is taken from database using python.

ya i got it 
I used   {{ c.stream }}

and in url -
  url(r'^(?P[^/]+)/$','stream',name="stream"),

  so here detail will store that value...

and in views-
def stream(request,detail):
courses = Course.objects.filter(stream = detail )
ctx = {'courses':courses}
return render_to_response('homepage/index.html', ctx)

thanks
regards,
avnesh shakya

On Fri, Mar 8, 2013 at 3:40 PM, Avnesh Shakya  wrote:

> Actually, i have lot of different-2 stream, now i want to make it as link,
> so that i can click on particular stream and it should filter data
> according to that stream({{c.stream}}) on same page.
>
> thanks
>
>
> On Fri, Mar 8, 2013 at 3:08 PM, Daniel Roseman wrote:
>
>> On Friday, 8 March 2013 09:07:12 UTC, Avnesh Shakya wrote:
>>
>>> I am using an anchor tag and have to access its content in python. I
>>> have to access the 'text' from this.
>>>
>>> in html page--
>>>
>>> {% for c in courses%}
>>> 
>>> {{c.title}}**>> href="cd.html">{{c.stream}}
>>>
>>> i want to get {{c.stream}} value so that i can use it in views.py i want
>>> to filter the content acoording to it, and want to display after shorting
>>> acc. it.
>>>
>>> plz help me...
>>>
>>> thanks
>>>
>>
>> It's very unclear what you want to do. But I suspect you should be trying
>> to use that parameter as part of your URL:
>>
>> {{ c.stream }}
>>
>> Or even better, use the {% url %} tag to calculate the correct URL.
>> --
>> DR.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

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




Re: how to get value of anchor tag which is taken from database using python.

Actually, i have lot of different-2 stream, now i want to make it as link,
so that i can click on particular stream and it should filter data
according to that stream({{c.stream}}) on same page.

thanks

On Fri, Mar 8, 2013 at 3:08 PM, Daniel Roseman wrote:

> On Friday, 8 March 2013 09:07:12 UTC, Avnesh Shakya wrote:
>
>> I am using an anchor tag and have to access its content in python. I have
>> to access the 'text' from this.
>>
>> in html page--
>>
>> {% for c in courses%}
>> 
>> {{c.title}}**> href="cd.html">{{c.stream}}
>>
>> i want to get {{c.stream}} value so that i can use it in views.py i want
>> to filter the content acoording to it, and want to display after shorting
>> acc. it.
>>
>> plz help me...
>>
>> thanks
>>
>
> It's very unclear what you want to do. But I suspect you should be trying
> to use that parameter as part of your URL:
>
> {{ c.stream }}
>
> Or even better, use the {% url %} tag to calculate the correct URL.
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




django templates - iterate over several lists


Hi,

How can I iterate over several list objects available in my template?
I'd like to avoid having to concatenate them in the view and pass that
as another parameter.

I mean something like this:

{% for x in list1, list2, list3... listN %}
{% if not forloop.first %}, {% endif %}write some stuff
{% endfor %}

Thanks for your input!

Roberto


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




Re: how to get value of anchor tag which is taken from database using python.

On Friday, 8 March 2013 09:07:12 UTC, Avnesh Shakya wrote:

> I am using an anchor tag and have to access its content in python. I have 
> to access the 'text' from this.
>
> in html page--
>
> {% for c in courses%}
> 
> {{c.title}} href="cd.html">{{c.stream}}
>
> i want to get {{c.stream}} value so that i can use it in views.py i want 
> to filter the content acoording to it, and want to display after shorting 
> acc. it.
>
> plz help me...
>
> thanks 
>

It's very unclear what you want to do. But I suspect you should be trying 
to use that parameter as part of your URL:

{{ c.stream }}

Or even better, use the {% url %} tag to calculate the correct URL.
--
DR. 

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




how to get value of anchor tag which is taken from database using python.

I am using an anchor tag and have to access its content in python. I have
to access the 'text' from this.

in html page--

{% for c in courses%}

{{c.title}}{{c.stream}}

i want to get {{c.stream}} value so that i can use it in views.py i want to
filter the content acoording to it, and want to display after shorting acc.
it.

plz help me...

thanks

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