Looking for a session cart

2013-01-21 Thread frocco
Hello,

I am learning django and want to port an app over from PHP.
In PHP, I use a session cart to store items purchased.
Is there anything for django?

-- 
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/-/fe0jYDw20nMJ.
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: ignore field during form validation

2013-01-21 Thread Sarfraz ahmad
Hello everyone,

 i m facing a problem while validating django form. 
i have 5 form fields in a form and in the view i want to validate only 
three form fields which i need to update .. tell me a solution if 
anyone have any

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



want to update only a few fields of a form

2013-01-21 Thread Sarfraz ahmad
i want to update only a few fields of a form bt not with the cleaned method

i need to validate them in a view... please tell me a solution
thenk you all

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



Database Transaction

2013-01-21 Thread Sandeep kaur
Hello Django users,
I have created a django application whose database is totally
different(different foreign keys, fields, tables etc.) from that of
old application. But now when I have created the application I require
the data from old application too. How can I do the data transaction
among the two applications?
Your help will be appreciated.
Thank you.

-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

-- 
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: want to update only a few fields of a form

2013-01-21 Thread Babatunde Akinyanmi
Hi, this is well documented in the online documentation
https://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs
https://docs.djangoproject.com/en/dev/ref/forms/validation/

If you define the fields you want to with required=False, you shouldn't
have issues

Sent from my Windows Phone
--
From: Sarfraz ahmad
Sent: 1/21/2013 1:59 PM
To: django-users@googlegroups.com
Subject: want to update only a few fields of a form

i want to update only a few fields of a form bt not with the cleaned method

i need to validate them in a view... please tell me a solution
thenk you all

-- 
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/-/epxfcWcGCqUJ.
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: Looking for a session cart

2013-01-21 Thread Stefano Probst
Did you mean something like 
"sessions"(
example
)?

Am Montag, 21. Januar 2013 13:50:13 UTC+1 schrieb frocco:
>
> Hello,
>
> I am learning django and want to port an app over from PHP.
> In PHP, I use a session cart to store items purchased.
> Is there anything for django?
>

-- 
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/-/qo2PBDvtxAsJ.
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: Looking for a session cart

2013-01-21 Thread Stefano Probst
There is also a finished Shop  application 
if you want looking how other solve this Problem.

-- 
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/-/gelYsDFV3qAJ.
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: Looking for a session cart

2013-01-21 Thread frocco
I found django-cart, but it seems to write to the database.
I want to keep items in session until they checkout.

Thanks for the link to Shop, I will take a look at that also.

On Monday, January 21, 2013 8:54:00 AM UTC-5, Stefano Probst wrote:
>
> Did you mean something like 
> "sessions"(
> example
> )?
>
> Am Montag, 21. Januar 2013 13:50:13 UTC+1 schrieb frocco:
>>
>> Hello,
>>
>> I am learning django and want to port an app over from PHP.
>> In PHP, I use a session cart to store items purchased.
>> Is there anything for django?
>>
>

-- 
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/-/L5wk5NhVqlUJ.
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: ignore field during form validation

2013-01-21 Thread Jonathan D. Baker
Hi Sarfraz,

If your form class inherits from ModelForm, you can use a subset of
fields within your form per the following documentation:
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form

If you're not inheriting from ModelForm, then it's a matter of
configuring your model and form fields to allow null/blank. In this
case, seeing your code would help provide more direction.

Hope this helps,
Jonathan

On 01/21/2013 04:34 AM, Sarfraz ahmad wrote:
> Hello everyone,
>
>  i m facing a problem while validating django
> form. i have 5 form fields in a form and in the view i want to
> validate only three form fields which i need to update .. tell
> me a solution if anyone have any
> -- 
> 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/-/oZfMAZ8FWt4J.
> 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.


-- 
Software Developer
https://github.com/jondbaker
GPG: 1F6F3FFD

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



Cascading deletes in Admin: ForeignKey with on_delete=models.DO_NOTHING from an unmanaged table fails when the table does not exist

2013-01-21 Thread Dorenthas
I ran into an issue today with the Django Admin and I was wondering if this 
was "by design" (in which case I'd like to understand what the rationale 
is) or if it was an actual bug that deserves a ticket.

Here's sample code to illustrate the problem.

# models.py

class MasterModel(models.Model):
name = models.CharField(max_length=50)

def __unicode__(self):
return u'%s (Master)' % self.name


class ExternalModel(models.Model):
master = models.ForeignKey(MasterModel, on_delete=models.DO_NOTHING)

class Meta:
managed = False


# admin.py

from django.contrib import admin
import models
admin.site.register(models.MasterModel)
admin.site.register(models.ExternalModel)

When I try to delete a MasterModel object in the Admin, I get the following 
exception & traceback:

Environment:

Request Method: POST
Request URL: http://localhost:8000/admin/sample_app/mastermodel/

Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django_on_delete_do_nothing_bug.sample_app')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "D:\Python27\lib\site-packages\django\core\handlers\base.py" in 
get_response
  111. response = callback(request, *callback_args, 
**callback_kwargs)
File "D:\Python27\lib\site-packages\django\contrib\admin\options.py" in 
wrapper
  366. return self.admin_site.admin_view(view)(*args, 
**kwargs)
File "D:\Python27\lib\site-packages\django\utils\decorators.py" in 
_wrapped_view
  91. response = view_func(request, *args, **kwargs)
File "D:\Python27\lib\site-packages\django\views\decorators\cache.py" in 
_wrapped_view_func
  89. response = view_func(request, *args, **kwargs)
File "D:\Python27\lib\site-packages\django\contrib\admin\sites.py" in inner
  196. return view(request, *args, **kwargs)
File "D:\Python27\lib\site-packages\django\utils\decorators.py" in _wrapper
  25. return bound_func(*args, **kwargs)
File "D:\Python27\lib\site-packages\django\utils\decorators.py" in 
_wrapped_view
  91. response = view_func(request, *args, **kwargs)
File "D:\Python27\lib\site-packages\django\utils\decorators.py" in 
bound_func
  21. return func(self, *args2, **kwargs2)
File "D:\Python27\lib\site-packages\django\contrib\admin\options.py" in 
changelist_view
  1153. response = self.response_action(request, 
queryset=cl.get_query_set(request))
File "D:\Python27\lib\site-packages\django\contrib\admin\options.py" in 
response_action
  908. response = func(self, request, queryset)
File "D:\Python27\lib\site-packages\django\contrib\admin\actions.py" in 
delete_selected
  35. queryset, opts, request.user, modeladmin.admin_site, using)
File "D:\Python27\lib\site-packages\django\contrib\admin\util.py" in 
get_deleted_objects
  104. collector.collect(objs)
File "D:\Python27\lib\site-packages\django\contrib\admin\util.py" in collect
  155. return super(NestedObjects, self).collect(objs, 
source_attr=source_attr, **kwargs)
File "D:\Python27\lib\site-packages\django\db\models\deletion.py" in collect
  175. if not sub_objs:
File "D:\Python27\lib\site-packages\django\db\models\query.py" in 
__nonzero__
  130. iter(self).next()
File "D:\Python27\lib\site-packages\django\db\models\query.py" in 
_result_iter
  118. self._fill_cache()
File "D:\Python27\lib\site-packages\django\db\models\query.py" in 
_fill_cache
  892. self._result_cache.append(self._iter.next())
File "D:\Python27\lib\site-packages\django\db\models\query.py" in iterator
  291. for row in compiler.results_iter():
File "D:\Python27\lib\site-packages\django\db\models\sql\compiler.py" in 
results_iter
  763. for rows in self.execute_sql(MULTI):
File "D:\Python27\lib\site-packages\django\db\models\sql\compiler.py" in 
execute_sql
  818. cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\util.py" in execute
  40. return self.cursor.execute(sql, params)
File "D:\Python27\lib\site-packages\django\db\backends\mysql\base.py" in 
execute
  114. return self.cursor.execute(query, args)
File "D:\Python27\lib\site-packages\MySQLdb\cursors.py" in execute
  174. self.errorhandler(self, exc, value)
File "D:\Python27\lib\site-packages\MySQLdb\connections.py" in 
defaulterrorhandler
  36. raise errorclass, errorvalue

Exception Type: DatabaseError at /a

Re: Looking for a session cart

2013-01-21 Thread Stefano Probst

But this is what 
"sessions"does. By 
default a session is saved in the database but you can move it 
also in a cache 
(https://docs.djangoproject.com/en/1.4/topics/http/sessions/#using-cached-sessions
 
). Memcached is realy performant.
You can write by write "request.session['fav_color'] = green" and read by 
write "request.session['fav_color']" or "fav_color = 
request.session.get('fav_color', 'red')" then "red" is the default value if 
"fav_color" is'nt set.
Am Montag, 21. Januar 2013 15:44:47 UTC+1 schrieb frocco:
>
> I found django-cart, but it seems to write to the database.
> I want to keep items in session until they checkout.
>
> Thanks for the link to Shop, I will take a look at that also.
>
> On Monday, January 21, 2013 8:54:00 AM UTC-5, Stefano Probst wrote:
>>
>> Did you mean something like 
>> "sessions"(
>> example
>> )?
>>
>> Am Montag, 21. Januar 2013 13:50:13 UTC+1 schrieb frocco:
>>>
>>> Hello,
>>>
>>> I am learning django and want to port an app over from PHP.
>>> In PHP, I use a session cart to store items purchased.
>>> Is there anything for django?
>>>
>>

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



Calculate availability based on Events

2013-01-21 Thread Tijmen
Hi,

I would like to calculate the availability of a service which holds zero or 
more events. The model looks like this:

class Service(models.Model):
name = models.CharField(max_length=75)

class Event(models.Model):
event_class = models.CharField(max_length=75)
service = models.ForeignKey(Service)
start = models.DateTimeField()
end = models.DateTimeField()

What approach would you take to be able to supply a certain timeframe (e.g. 
start = 01-01-2013 00:00, end = 02-01-2013 00:00) and the availability gets 
calculated over that exact timeframe. I identified two problems here:

1. When you get the events that match a certain timeframe (with the range 
filter) events are excluded matching the following criteria: 
 - start before the timeframe but end within the timeframe -  
 or 
 - start within the timeframe but end after the timeframe -
 
2. If we were able to get these events we don't want to take into account 
the time that is not within the timeframe as it would mess up our 
calculation. So we need to reset the start and or endtime.

Any ideas on how to accomplish 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/-/YA2pMVCiBWUJ.
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.



looking for an app to view various github repositories within a django powered site

2013-01-21 Thread garagefan
I'm looking to build a website to collaborate on some open source projects. 
I'd like to set up discussions based on git repositories, and maybe even 
allow folks to contribute/fork/submit issues, etc.

I could handle this on my own, but its more of a side fun project for 
myself and I'd rather see if there is something already completed, or 
mostly completed.

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/-/oXLGdJjhi8EJ.
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: Newbie question: session-length data storage best practices?

2013-01-21 Thread testbackupacct
Nik,

My concerns are about security. I have some sensitive data associated with 
each user's session, and I'd like to make sure it is deleted when the user 
logs out or their session times out or closes their browser window. There's 
also some other clean up actions I'd like to do under the same 
circumstances.

I took a look at the session caching documents (thanks for the pointer), 
and I think I would have to go for the cached_db option; if I just used the 
plain vanilla cache option and the data got expired out of the cache, it 
would create a terrible user experience. But I would to understand the 
mechanism by which session data gets purged from the database backend. Can 
I rely on it getting purged with each log out/session time out/browser 
window closure? 

Again, thanks for the good feedback.

Spork

-- 
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/-/SOs0zvR48PMJ.
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: looking for an app to view various github repositories within a django powered site

2013-01-21 Thread Pankaj Singh
Hi,

I could not any recent work similar to what you have described.

Charles Leifer tried to do some django+github[1] integration and his
work is available on github[2].

There are good implementations of Github Oauth as you can see it in
django-social-auth[3] and django-allauth[4].

There are many python libraries, e.g. github3.py[5],for Github
Developer API[6]. You can use any of these inside your django app.

You might be interested in django-git[7] as well. It's a gitweb
replacement written in Django.

Links
1. http://charlesleifer.com/blog/simple-integration-github-django-github/
2. https://github.com/frozenskys/django-github
3. https://github.com/omab/django-social-auth
4. https://github.com/pennersr/django-allauth
5. https://github.com/sigmavirus24/github3.py
6. http://developer.github.com/v3/libraries/#python
7. https://github.com/sethtrain/django-git

Pankaj Singh
http://about.me/psjinx


On Mon, Jan 21, 2013 at 10:29 PM, garagefan  wrote:
> I'm looking to build a website to collaborate on some open source projects.
> I'd like to set up discussions based on git repositories, and maybe even
> allow folks to contribute/fork/submit issues, etc.
>
> I could handle this on my own, but its more of a side fun project for myself
> and I'd rather see if there is something already completed, or mostly
> completed.
>
> 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/-/oXLGdJjhi8EJ.
> 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: Looking for a session cart

2013-01-21 Thread frocco
Thanks, I need to look at this, not sure how django-cart knows what records 
are for each user logged in.

On Monday, January 21, 2013 11:12:01 AM UTC-5, Stefano Probst wrote:
>
>
> But this is what 
> "sessions"does. 
> By default a session is saved in the database but you can move it 
> also in a cache (
> https://docs.djangoproject.com/en/1.4/topics/http/sessions/#using-cached-sessions).
>  Memcached is realy performant.
> You can write by write "request.session['fav_color'] = green" and read by 
> write "request.session['fav_color']" or "fav_color = 
> request.session.get('fav_color', 'red')" then "red" is the default value 
> if "fav_color" is'nt set.
> Am Montag, 21. Januar 2013 15:44:47 UTC+1 schrieb frocco:
>>
>> I found django-cart, but it seems to write to the database.
>> I want to keep items in session until they checkout.
>>
>> Thanks for the link to Shop, I will take a look at that also.
>>
>> On Monday, January 21, 2013 8:54:00 AM UTC-5, Stefano Probst wrote:
>>>
>>> Did you mean something like 
>>> "sessions"(
>>> example
>>> )?
>>>
>>> Am Montag, 21. Januar 2013 13:50:13 UTC+1 schrieb frocco:

 Hello,

 I am learning django and want to port an app over from PHP.
 In PHP, I use a session cart to store items purchased.
 Is there anything for django?

>>>

-- 
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/-/-i0YYos4f3IJ.
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: Newbie question: session-length data storage best practices?

2013-01-21 Thread Nikolas Stevenson-Molnar
Hi Spork,

See this section of the sessions docs:
https://docs.djangoproject.com/en/1.4/topics/http/sessions/#clearing-the-session-table

While it mentions file and db backends specifically, I assume the cache
backend would work similarly. I.e., you need to periodically run a
cleanup of session data. According to the docs, Django will
automatically delete session data when the user logs out, but not
otherwise (again, the server has no reliable way of knowing the user has
closed the browser window) so if you want the data gone, you have to
clean it up periodically.

Taking a step back, I don't think this is a good approach to security.
This data is still residing on your server for however short a time
period. The issue should be less one of how long the data exist there,
and more about how to keep it safe. How to do that depends somewhat on
the nature of the data (e.g., SSNs or credit card numbers should reside
only on a system not connected directly to the internet).

_Nik

On 1/21/2013 9:45 AM, testbackupa...@gmail.com wrote:
> Nik,
>
> My concerns are about security. I have some sensitive data associated
> with each user's session, and I'd like to make sure it is deleted when
> the user logs out or their session times out or closes their browser
> window. There's also some other clean up actions I'd like to do under
> the same circumstances.
>
> I took a look at the session caching documents (thanks for the
> pointer), and I think I would have to go for the cached_db option; if
> I just used the plain vanilla cache option and the data got expired
> out of the cache, it would create a terrible user experience. But I
> would to understand the mechanism by which session data gets purged
> from the database backend. Can I rely on it getting purged with each
> log out/session time out/browser window closure?
>
> Again, thanks for the good feedback.
>
> Spork
> -- 
> 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/-/SOs0zvR48PMJ.
> 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: Looking for a session cart

2013-01-21 Thread Mario Gudelj
Use django-cart. It does store the cart content in db but it stores the
session as well, so it will nicely match the user to their cart content
according to the cart id stored inside a cookie. It's a breeze to implement
with any product model. I highly recommend it.
On 22 Jan, 2013 7:43 AM, "frocco"  wrote:

> Thanks, I need to look at this, not sure how django-cart knows what
> records are for each user logged in.
>
> On Monday, January 21, 2013 11:12:01 AM UTC-5, Stefano Probst wrote:
>>
>>
>> But this is what 
>> "sessions"does. 
>> By default a session is saved in the database but you can move it
>> also in a cache (https://docs.djangoproject.**com/en/1.4/topics/http/**
>> sessions/#using-cached-**sessions).
>>  Memcached is realy performant.
>> You can write by write "request.session['fav_color'] = green" and read
>> by write "request.session['fav_color']" or "fav_color =
>> request.session.get('fav_**color', 'red')" then "red" is the default
>> value if "fav_color" is'nt set.
>> Am Montag, 21. Januar 2013 15:44:47 UTC+1 schrieb frocco:
>>>
>>> I found django-cart, but it seems to write to the database.
>>> I want to keep items in session until they checkout.
>>>
>>> Thanks for the link to Shop, I will take a look at that also.
>>>
>>> On Monday, January 21, 2013 8:54:00 AM UTC-5, Stefano Probst wrote:

 Did you mean something like 
 "sessions"(
 example
 )?

 Am Montag, 21. Januar 2013 13:50:13 UTC+1 schrieb frocco:
>
> Hello,
>
> I am learning django and want to port an app over from PHP.
> In PHP, I use a session cart to store items purchased.
> Is there anything for django?
>
  --
> 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/-/-i0YYos4f3IJ.
> 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: ignore field during form validation

2013-01-21 Thread Mario Gudelj
Add required=False to the form field and it won't be validated.
On 22 Jan, 2013 2:30 AM, "Jonathan D. Baker" 
wrote:

>  Hi Sarfraz,
>
> If your form class inherits from ModelForm, you can use a subset of fields
> within your form per the following documentation:
> https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form
>
> If you're not inheriting from ModelForm, then it's a matter of configuring
> your model and form fields to allow null/blank. In this case, seeing your
> code would help provide more direction.
>
> Hope this helps,
> Jonathan
>
> On 01/21/2013 04:34 AM, Sarfraz ahmad wrote:
>
> Hello everyone,
>
>  i m facing a problem while validating django
> form. i have 5 form fields in a form and in the view i want to
> validate only three form fields which i need to update .. tell me a
> solution if anyone have any
> --
> 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/-/oZfMAZ8FWt4J.
> 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.
>
>
>
> --
> Software Developerhttps://github.com/jondbaker
> GPG: 1F6F3FFD
>
>  --
> 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: Calculate availability based on Events

2013-01-21 Thread Mario Gudelj
I'm not sure I fully understand your requirement, but I did something
similar recently where I need to calculate the first available time slot
for a service for a given staff and create an appointment for that time
slot if the customer wants it. The staff model in this case has
the availability against it (start and end time for the working day) and
the service is a specified half hour or one hour block or whatever the
admin sets it to be. Staff also has days and hours when they're away which
people can't book in ExceptionAvailability. Appointment is what gets
created when the available slot is found.

Below is the function I used. The code may not look the best but it does
work. :) I hope you can get something out of it:



def find_slot_inside_availability(utc_start_time,
utc_availability_end_time, duration, staff):
utc_end_time = utc_start_time + datetime.timedelta(minutes=duration)

# When this function is called lets make sure there's enough time left
in the current availability (given the start_time we want)
if utc_end_time > utc_availability_end_time:
return None

# Check we aren't in the middle of a blocked out time for the staff in
question
try:
block_out_time = ExceptionAvailability.objects.get(staff = staff,
start_datetime__lt=utc_start_time, end_datetime__gt=utc_start_time)
except ExceptionAvailability.DoesNotExist:

# Check there are no blockouts starting before end of duration
possible_block_out_times =
ExceptionAvailability.objects.filter(staff=staff,
start_datetime__lt=utc_end_time,
start_datetime__gte=utc_start_time).order_by('-end_datetime')
if not possible_block_out_times:
# If we're here it means we can start checking for appointments
inside this spot
try:
overlapping_appointment =
Appointment.objects.get(staffProfile=staff, deletion_date__isnull=True,
start_time__lt=utc_start_time, end_time__gt=utc_end_time)
except Appointment.DoesNotExist:
# Check for any appointments starting within the block we
want
possible_overlapping_appointments =
Appointment.objects.filter(staffProfile=staff, deletion_date__isnull=True,
start_time__lt=utc_end_time,
start_time__gte=utc_start_time).order_by('-end_time')
if not possible_overlapping_appointments:
return utc_start_time ### HURRAH we've found an
unencumbered slot!
else:
# move to end of last overlapping appointment and run
the algo again
new_possible_start_time =
possible_overlapping_appointments[0].end_time.replace(tzinfo=pytz.UTC)
else:
# Move to end of appointment and try again
new_possible_start_time =
overlapping_appointment.end_time.replace(tzinfo=pytz.UTC)
else:
# there are blockages, move to the end of the last
possible_block_out_time and try it again (after comparing against
availability_end_time
new_possible_start_time =
possible_block_out_times[0].end_datetime.replace(tzinfo=pytz.UTC)
else:
# Move to end of block out time and check it against
availability_end_time
new_possible_start_time =
block_out_time.end_datetime.replace(tzinfo=pytz.UTC)
return find_slot_inside_availability(new_possible_start_time,
utc_availability_end_time, duration, staff)


On 22 January 2013 03:16, Tijmen  wrote:

> Hi,
>
> I would like to calculate the availability of a service which holds zero
> or more events. The model looks like this:
>
> class Service(models.Model):
> name = models.CharField(max_length=75)
>
> class Event(models.Model):
> event_class = models.CharField(max_length=75)
> service = models.ForeignKey(Service)
> start = models.DateTimeField()
> end = models.DateTimeField()
>
> What approach would you take to be able to supply a certain timeframe
> (e.g. start = 01-01-2013 00:00, end = 02-01-2013 00:00) and the
> availability gets calculated over that exact timeframe. I identified two
> problems here:
>
> 1. When you get the events that match a certain timeframe (with the range
> filter) events are excluded matching the following criteria:
>  - start before the timeframe but end within the timeframe -
>  or
>  - start within the timeframe but end after the timeframe -
>
> 2. If we were able to get these events we don't want to take into account
> the time that is not within the timeframe as it would mess up our
> calculation. So we need to reset the start and or endtime.
>
> Any ideas on how to accomplish 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/-/YA2pMVCiBWUJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsub

How can I find and clean an user's session from an user's id?

2013-01-21 Thread Serge G. Spaolonzi
I am looking the way to selective clear determinate user sessions from the
server. It has to be done from outside the user's session or request.
The complete user case is:
1) Django process receives a ping with the id of the user to clear the
session
2) Django process searchs the session for that user and cleans it.

How can I find an user's session from an user's id?
What would be the most efficient way to archive this?

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 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 can I find and clean an user's session from an user's id?

2013-01-21 Thread Nikolas Stevenson-Molnar
I took a quick peek at the sessions implementation and it doesn't look
like this is possible just using the sessions framework (since it only
stores Session -> User and not User -> Session). You could subclass one
of the existing session backends and store this information yourself
(look at django.contrib.sessions.backends). Keep in mind that sessions
are not always associated with users. You'll also need to look at the
auth module to see how it stores user id in the session, then watch for
that in your session backend's __setattr__ method.

_Nik

On 1/21/2013 2:35 PM, Serge G. Spaolonzi wrote:
> I am looking the way to selective clear determinate user sessions from
> the server. It has to be done from outside the user's session or request.
> The complete user case is:
> 1) Django process receives a ping with the id of the user to clear the
> session
> 2) Django process searchs the session for that user and cleans it. 
>
> How can I find an user's session from an user's id?
> What would be the most efficient way to archive this?
>
> 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 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: Newbie question: session-length data storage best practices?

2013-01-21 Thread Nikolas Stevenson-Molnar
Upon a second glance, it looks like the clearsession command will only
have an effect as of Django 1.5. For <=1.4 if you're using the DB
backend, you could always clear them out yourself with a query:

now = datetime.datetime.now()
Session.objects.filter(expire_date__lt=now).delete()

_Nik

On 1/21/2013 12:46 PM, Nikolas Stevenson-Molnar wrote:
> Hi Spork,
>
> See this section of the sessions docs:
> https://docs.djangoproject.com/en/1.4/topics/http/sessions/#clearing-the-session-table
>
> While it mentions file and db backends specifically, I assume the cache
> backend would work similarly. I.e., you need to periodically run a
> cleanup of session data. According to the docs, Django will
> automatically delete session data when the user logs out, but not
> otherwise (again, the server has no reliable way of knowing the user has
> closed the browser window) so if you want the data gone, you have to
> clean it up periodically.
>
> Taking a step back, I don't think this is a good approach to security.
> This data is still residing on your server for however short a time
> period. The issue should be less one of how long the data exist there,
> and more about how to keep it safe. How to do that depends somewhat on
> the nature of the data (e.g., SSNs or credit card numbers should reside
> only on a system not connected directly to the internet).
>
> _Nik
>
> On 1/21/2013 9:45 AM, testbackupa...@gmail.com wrote:
>> Nik,
>>
>> My concerns are about security. I have some sensitive data associated
>> with each user's session, and I'd like to make sure it is deleted when
>> the user logs out or their session times out or closes their browser
>> window. There's also some other clean up actions I'd like to do under
>> the same circumstances.
>>
>> I took a look at the session caching documents (thanks for the
>> pointer), and I think I would have to go for the cached_db option; if
>> I just used the plain vanilla cache option and the data got expired
>> out of the cache, it would create a terrible user experience. But I
>> would to understand the mechanism by which session data gets purged
>> from the database backend. Can I rely on it getting purged with each
>> log out/session time out/browser window closure?
>>
>> Again, thanks for the good feedback.
>>
>> Spork
>> -- 
>> 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/-/SOs0zvR48PMJ.
>> 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: How can I find and clean an user's session from an user's id?

2013-01-21 Thread Serge G. Spaolonzi
Thanks.

On Mon, Jan 21, 2013 at 10:10 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

> I took a quick peek at the sessions implementation and it doesn't look
> like this is possible just using the sessions framework (since it only
> stores Session -> User and not User -> Session). You could subclass one
> of the existing session backends and store this information yourself
> (look at django.contrib.sessions.backends). Keep in mind that sessions
> are not always associated with users. You'll also need to look at the
> auth module to see how it stores user id in the session, then watch for
> that in your session backend's __setattr__ method.
>
> _Nik
>
> On 1/21/2013 2:35 PM, Serge G. Spaolonzi wrote:
> > I am looking the way to selective clear determinate user sessions from
> > the server. It has to be done from outside the user's session or request.
> > The complete user case is:
> > 1) Django process receives a ping with the id of the user to clear the
> > session
> > 2) Django process searchs the session for that user and cleans it.
> >
> > How can I find an user's session from an user's id?
> > What would be the most efficient way to archive this?
> >
> > 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 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.
>
>


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



get_absolute_url goes to ../../../r/14/1/

2013-01-21 Thread Chad Vernon
I'm implementing the get_absolute_url method on one of my models.

@models.permalink
def get_absolute_url(self):
return ('viewProject', (), {'projectSlug' : self.slug})

My url has:

url(r'^(?P[-\w]+)/$', 'assetlibrary.views.viewProject',
name='viewProject'),


However, in the admin page for that instance, the View on Site link points
to:
../../../r/14/1/

which is not very useful.

I was following the documentation here:
https://docs.djangoproject.com/en/1.4/ref/models/instances/#get-absolute-url
and nothing more is listed than what I just did.  Am I missing another step?

Thank you,
Chad

-- 
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: Database Transaction

2013-01-21 Thread Jian Chang
you mean two different databases?
you can't do the transaction between two different databases.
Anyway you can control the transactions by yourself.
like:
commit all or rollback all if all actions are ok or not,

2013/1/21 Sandeep kaur 

> Hello Django users,
> I have created a django application whose database is totally
> different(different foreign keys, fields, tables etc.) from that of
> old application. But now when I have created the application I require
> the data from old application too. How can I do the data transaction
> among the two applications?
> Your help will be appreciated.
> Thank you.
>
> --
> Sandeep Kaur
> E-Mail: mkaurkha...@gmail.com
> Blog: sandymadaan.wordpress.com
>
> --
> 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.



Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-21 Thread Matt Andrews
Hi all,

Fairly new to Django. I ended up pulling out all of the ORM-generated 
queries and writing my own SQL directly (I got fed up trying to work out 
how to achieve the kind of things I needed without Django adding in extra 
joins or unintended WHERE clauses etc). All my app's SQL uses 
cursor.execute() and the dictfetchall() method as referenced 
here
. 

I've found that my app incurs a couple of seconds load time in production, 
with CPU time at 2532ms and overall time 4684ms (according to the debug 
toolbar). I'm seeing 8 SQL queries take 380ms, and each one seems to be 
several times slower when made by Django versus hitting the database 
through phpMyAdmin or something: eg, this query:

SELECT * FROM news 
JOIN news_categories ON news.news_category_id = news_categories.id 
LEFT JOIN writers ON news.writer_id = writers.id 
LEFT JOIN images ON news.image_id = images.id 
ORDER BY news.is_sticky DESC, news.date_posted DESC 
LIMIT 10


This takes 14.8ms when run in phpMyAdmin (against the production database) 
but Django reports it as 85.2ms. The same ratios are true for all my other 
queries.

All I can think of is the note on the dictfetchall() method in the Django 
docs which describes a "small performance hit". Is this it?!

I've profiled the app too, although I'm a bit hazy about what it all means. 
Here's a dump of the result: http://pastebin.com/raw.php?i=UHE9edVC (this 
is from running on my local server rather than production but performance 
is broadly similar).

Can anyone help me? I realise I've perhaps gone off-piste by writing raw 
SQL but I feel it was justified.

thanks,
Matt


-- 
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/-/Qiley9RqfngJ.
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 can I find and clean an user's session from an user's id?

2013-01-21 Thread Toni
Hi,
Maybe this helps you:

http://stackoverflow.com/a/4892370/938046




2013/1/21 Serge G. Spaolonzi 

> I am looking the way to selective clear determinate user sessions from the
> server. It has to be done from outside the user's session or request.
> The complete user case is:
> 1) Django process receives a ping with the id of the user to clear the
> session
> 2) Django process searchs the session for that user and cleans it.
>
> How can I find an user's session from an user's id?
> What would be the most efficient way to archive this?
>
> 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 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 attribute JSONEncoder

2013-01-21 Thread ghjim
Hello, 

I am getting an error when I access my root WSGIScriptAlias /:

AttributeError at /
module object has no attribute JSONEncoder.

I have seen similar reports on the web, some of them implying that this is 
a python bug
but I can't implement any of the fixes.

I am using Django 1.4.3 and Python2.7.3, mod_wsgi 3.4.

With my Python2.7.3 installation I have both json amd simplejson
(I can import "json as simplejson" and print a directory of attributes for 
the module simplejson.  It includes JSONEncoder.

I was hoping somebody has seen 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/-/_-xDLgBkMRYJ.
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.



download pdf in admin

2013-01-21 Thread grat
hi,

i cannot download file upladed by admin.

i have this model:
class Smlouvy(models.Model):
note= models.TextField(blank=True)
pdf= models.FileField( upload_to = 
'scany/%Y/%m/%d',blank=True,verbose_name="Pdf Filw")

in Admin i upladed file, and file is in correct directory. But cannot 
download this file. I get this error:

...
Page not found (404)Request Method:GETRequest URL:
http://127.0.0.1:8000/scany/2013/01/21/hrebci.pdf

Using the URLconf defined in maxmart.urls, Django tried these URL patterns, 
in this order:

   1. ^admin/

The current URL, scany/2013/01/21/hrebci.pdf, didn't match any of these.


Do you know, where is problem? 


Thanks Milan

-- 
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/-/pKPcvF3xW10J.
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: Struggling with slow startup / SQL in new app (using raw SQL)

2013-01-21 Thread Nikolas Stevenson-Molnar
Hi Matt,

Firstly, I encourage you to have another crack a the ORM. It can
certainly seem a bit aggravating at times if you're coming from a SQL
mindset, but really pays off down the road in terms of maintainability
and readability. Typically you should only need raw queries in Django in
cases where you have super-specialized (that uses views or non-standard
functions) queries or need some specific optimization. If there's really
no way to perform many of your "day-to-day" queries with the ORM then
that's an indication that a different database design may fit your data
model better. I understand that you may have a unique situation, but I
just wanted to throw that out there as I personally find the ORM to be a
huge time saver.

Now, with that out of the way... a couple of considerations: 1) you say
it's a slow "startup"; if you refresh the page do the queries run just
as slow the second time around? and 2) are your Django app and
phpMyAdmin running on the same machine? If not, could transit time be an
issue?

Finally, can you give an idea about the size of the tables in question?
How many rows in each?

_Nik

On 1/21/2013 3:25 PM, Matt Andrews wrote:
> Hi all,
>
> Fairly new to Django. I ended up pulling out all of the ORM-generated
> queries and writing my own SQL directly (I got fed up trying to work
> out how to achieve the kind of things I needed without Django adding
> in extra joins or unintended WHERE clauses etc). All my app's SQL uses
> cursor.execute() and the dictfetchall() method as referenced here
> .
>  
>
> I've found that my app incurs a couple of seconds load time in
> production, with CPU time at 2532ms and overall time 4684ms (according
> to the debug toolbar). I'm seeing 8 SQL queries take 380ms, and each
> one seems to be several times slower when made by Django versus
> hitting the database through phpMyAdmin or something: eg, this query:
>
> SELECT * FROM news 
> JOIN news_categories ON news.news_category_id = news_categories.id 
> LEFT JOIN writers ON news.writer_id = writers.id 
> LEFT JOIN images ON news.image_id = images.id 
> ORDER BY news.is_sticky DESC, news.date_posted DESC 
> LIMIT 10
>
>
> This takes 14.8ms when run in phpMyAdmin (against the production
> database) but Django reports it as 85.2ms. The same ratios are true
> for all my other queries.
>
> All I can think of is the note on the dictfetchall() method in the
> Django docs which describes a "small performance hit". Is this it?!
>
> I've profiled the app too, although I'm a bit hazy about what it all
> means. Here's a dump of the
> result: http://pastebin.com/raw.php?i=UHE9edVC (this is from running
> on my local server rather than production but performance is broadly
> similar).
>
> Can anyone help me? I realise I've perhaps gone off-piste by writing
> raw SQL but I feel it was justified.
>
> thanks,
> Matt
>
>
> -- 
> 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/-/Qiley9RqfngJ.
> 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: no attribute JSONEncoder

2013-01-21 Thread Nikolas Stevenson-Molnar
Does this happen only in production running via mod_wsgi, or does it
happen in local development with the Django dev server as well?

_Nik

On 1/21/2013 4:13 PM, ghjim wrote:
> Hello,
>
> I am getting an error when I access my root WSGIScriptAlias /:
>
> AttributeError at /
> module object has no attribute JSONEncoder.
>
> I have seen similar reports on the web, some of them implying that
> this is a python bug
> but I can't implement any of the fixes.
>
> I am using Django 1.4.3 and Python2.7.3, mod_wsgi 3.4.
>
> With my Python2.7.3 installation I have both json amd simplejson
> (I can import "json as simplejson" and print a directory of attributes
> for
> the module simplejson.  It includes JSONEncoder.
>
> I was hoping somebody has seen 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/-/_-xDLgBkMRYJ.
> 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: How can I find and clean an user's session from an user's id?

2013-01-21 Thread Jamie Lawrence
It is ok. Really. In llvikgiimn. In.  Go g

-j
I hurry.  
-- 
Sent from a phone, please excuse typos and terseness.

On Jan 21, 2013, at 4:10 PM, Nikolas Stevenson-Molnar  
wrote:

> I took a quick peek at the sessions implementation and it doesn't look
> like this is possible just using the sessions framework (since it only
> stores Session -> User and not User -> Session). You could subclass one
> of the existing session backends and store this information yourself
> (look at django.contrib.sessions.backends). Keep in mind that sessions
> are not always associated with users. You'll also need to look at the
> auth module to see how it stores user id in the session, then watch for
> that in your session backend's __setattr__ method.
> 
> _Nik
> 
> On 1/21/2013 2:35 PM, Serge G. Spaolonzi wrote:
>> I am looking the way to selective clear determinate user sessions from
>> the server. It has to be done from outside the user's session or request.
>> The complete user case is:
>> 1) Django process receives a ping with the id of the user to clear the
>> session
>> 2) Django process searchs the session for that user and cleans it. 
>> 
>> How can I find an user's session from an user's id?
>> What would be the most efficient way to archive this?
>> 
>> 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 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.



Global filtering of the querystes

2013-01-21 Thread Jani Tiainen

Hi,

I've several models that share same attribute and form doing ajax 
queries to/from form in a browser window.


For example owner:

class MyClass(models.Model):
title = models.TextField(max_length=100)
owner = models.TextField(max_length=100)

class MyOtherClass(models.Model):
title = models.TextField(max_length=100)
value = models.IntegerField()
owner = models.TextField(max_length=100)

And so on.

Now I would like to user have option in browser to filter any query 
based on model that has "owner" property to be filtered by owner.


What is the best way to doit?

I only could come up with threadlocals and special manager that can be 
fed with global filtering rules.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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