Re: IntegrityError when creating a brand new model instance

2013-02-08 Thread Some Developer

On 08/02/13 14:08, Andre Terra wrote:

Please post traceback, settings.py, etc.

On Fri, Feb 8, 2013 at 5:18 AM, Some Developer
> wrote:

I have a model for a Tag object with simply has two fields. A title
(which has the unique constraint) and a description. I also have a
FormView based view class which handles the creation of Tag objects.

When I try and save the object in the form_valid() method I always
get an IntegrityError stating that the title column is not unique.
This is somewhat puzzling as I have deleted the SQLite database file
and recreated it using syncdb / migrate so it is completely empty.

I'm completely baffled by this error.


I've been using Django for years and have never had this problem before. 
Hopefully someone will be able to shed some light on it as it is rather 
annoying.


The only thing I am doing now that I haven't done in the past is using 
class based views.


Settings:

The settings are just the default pretty much. The database section is 
below though.


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(DIRNAME, 'data/data.db'),
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
}
}

Traceback:

Environment:


Request Method: POST
Request URL: http://localhost:8000/blog/tag/create/

Django Version: 1.4.3
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',
 'debug_toolbar',
 'debug_toolbar_htmltidy',
 'inspector_panel',
 'debug_toolbar_user_panel',
 'compressor',
 'registration',
 'djcelery',
 'south',
 'blog',
 'controlpanel',
 'docs',
 'legal',
 'support',
 'bugs',
 'general')
Installed Middleware:
('django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.middleware.transaction.TransactionMiddleware')


Traceback:
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/core/handlers/base.py" 
in get_response
  111. response = callback(request, 
*callback_args, **callback_kwargs)
File 
"/home/somedeveloper/Documents/Development/Python/djangostormcloud/djangostormcloud/decorators/superuser.py" 
in decorator

  17. return f(request, *args, **kwargs)
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/views/generic/base.py" 
in view

  48. return self.dispatch(request, *args, **kwargs)
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/views/generic/base.py" 
in dispatch

  69. return handler(request, *args, **kwargs)
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/views/generic/edit.py" 
in post

  138. return self.form_valid(form)
File 
"/home/somedeveloper/Documents/Development/Python/djangostormcloud/blog/views.py" 
in form_valid

  134. tag.save()
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/db/models/base.py" 
in save
  463. self.save_base(using=using, force_insert=force_insert, 
force_update=force_update)
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/db/models/base.py" 
in save_base
  551. result = manager._insert([self], fields=fields, 
return_id=update_pk, using=using, raw=raw)
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/db/models/manager.py" 
in _insert

  203. return insert_query(self.model, objs, fields, **kwargs)
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/db/models/query.py" 
in insert_query

  1593. return query.get_compiler(using=using).execute_sql(return_id)
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/db/models/sql/compiler.py" 
in execute_sql

  912. cursor.execute(sql, params)
File 
"/home/somedeveloper/Documents/Development/PythonEnvironments/dsc-env/lib/python2.7/site-packages/django/db/backends/util.py" 
in execute

  40. return self.cursor.execute(sql, params)
File 

Re: django user model json

2013-02-08 Thread Anderson
Hi Jacob

thanks for the tip  but don't worry that is just a test script  there are
not real users and is running my local server that doesn't have any outside
connection.
Thanks anyway is always good to be careful.
I am using django 1.4 so you telling me that parents classes cannot be
serialized? humm any ideas how do it?

thank you.


On Fri, Feb 8, 2013 at 8:20 PM, Jacob Kaplan-Moss wrote:

> Hi Anderson --
>
> First, I need to point out something:
>
> On Fri, Feb 8, 2013 at 2:07 PM, Anderson 
> wrote:
> >  'password':
> >
> u'pbkdf2_sha256$1$ObXZ2yN3HATp$3ADUPZrzdvQCkPdJPCakfzILAIF8lPbKgAZLiXm54UI=',
>
> You just posted a password -- yours or one of your users -- on a
> public mailing list.
>
> PLEASE RESET THIS PASSWORD IMMEDIATELY. Also if this "activation_key"
> is anything sensitive, you should scrub it right away. Django uses a
> one-way hashing algorithm that partially protects you against leaking
> passwords, but given enough time an attacker could reverse what you
> just posted.
>
> So once again, you need to reset that password immediately. If it's a
> password you use elsewhere, you should reset it everywhere you use it.
> If it's one of your users' passwords, you should notify them
> immediately.
>
> Sorry if this comes across as harsh, but the consequences here are
> potentially disastrous, and I want to make sure you get the severity
> and respond immediately.
>
> Now, as to the issue at hand: I think the answer depends on what
> version of Django you're using:
>
> * If this is 1.4, this is probably "correct" at least according to
> what Django thinks. When you subclass User you're actually creating a
> relationship, not a subclassed model, so Django's only serializing the
> local fields on your subclass, not following the relationship.
>
> * If this is 1.5, and you're trying to create a custom User model,
> you'll want to subclass AbstractBaseUser instead of User; see
>
> https://docs.djangoproject.com/en/dev/topics/auth/customizing/#substituting-a-custom-user-model
> for more details.
>
> Thanks, and again - sorry to be harsh on the security stuff. But it's
> important!
>
> Jacob
>
> --
> 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.
>
>
>


-- 
Anderson Dias Borges
Senior Analyst Developer

Tu cumprirás o desejo do meu coração se eu Te buscar...
I can't see but I'll take my chances
To hear You call my name

-- 
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 user model json

2013-02-08 Thread Jacob Kaplan-Moss
Hi Anderson --

First, I need to point out something:

On Fri, Feb 8, 2013 at 2:07 PM, Anderson  wrote:
>  'password':
> u'pbkdf2_sha256$1$ObXZ2yN3HATp$3ADUPZrzdvQCkPdJPCakfzILAIF8lPbKgAZLiXm54UI=',

You just posted a password -- yours or one of your users -- on a
public mailing list.

PLEASE RESET THIS PASSWORD IMMEDIATELY. Also if this "activation_key"
is anything sensitive, you should scrub it right away. Django uses a
one-way hashing algorithm that partially protects you against leaking
passwords, but given enough time an attacker could reverse what you
just posted.

So once again, you need to reset that password immediately. If it's a
password you use elsewhere, you should reset it everywhere you use it.
If it's one of your users' passwords, you should notify them
immediately.

Sorry if this comes across as harsh, but the consequences here are
potentially disastrous, and I want to make sure you get the severity
and respond immediately.

Now, as to the issue at hand: I think the answer depends on what
version of Django you're using:

* If this is 1.4, this is probably "correct" at least according to
what Django thinks. When you subclass User you're actually creating a
relationship, not a subclassed model, so Django's only serializing the
local fields on your subclass, not following the relationship.

* If this is 1.5, and you're trying to create a custom User model,
you'll want to subclass AbstractBaseUser instead of User; see
https://docs.djangoproject.com/en/dev/topics/auth/customizing/#substituting-a-custom-user-model
for more details.

Thanks, and again - sorry to be harsh on the security stuff. But it's important!

Jacob

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




Pattern for Ajax Forms using Django ModelForm and Class Based Views.

2013-02-08 Thread Kelly Nicholes
What's the best practice for this?  In my function based views, I'd check 
if the form is_ajax() and if so, validate the form, render_to_string it to 
a form template, and return that in a json dump along with a status code. 
 Then I check the status code to see if there are errors.  If so, I close 
the modal that the form is in, notify the user of successful addition, and 
move on.  If there are errors, I replace the form's HTML in the modal with 
the new HTML that contains the form with error messages.  This sucks 
because I have to do this for every form and for every view that I have.  

-- 
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 user model json

2013-02-08 Thread Anderson
Hi guys I have this class that extends from Class User

class UserProfile(User):
#timezone = models.CharField(max_length=50,
default='America/Edmonton')
activation_key   = models.CharField(max_length=40)
key_expires  = models.DateTimeField()
objects = UserManager()

this is the object after UserProfile.objects.get(id=13);

{'_state': ,
 'activation_key': u'52UEOYT8F6EA5Q3K1CXRJMM9PQIFW511DG3H5J',
 'date_joined': datetime.datetime(2013, 2, 8, 16, 59, 4, tzinfo=),
 'email': u'm...@gmail.com',
 'first_name': u'Anderson',
 'id': 13L,
 'is_active': True,
 'is_staff': False,
 'is_superuser': False,
 'key_expires': datetime.datetime(2013, 2, 10, 16, 59, 4, tzinfo=),
 'last_login': datetime.datetime(2013, 2, 8, 17, 0, 37, tzinfo=),
 'last_name': u'',
 'password':
u'pbkdf2_sha256$1$ObXZ2yN3HATp$3ADUPZrzdvQCkPdJPCakfzILAIF8lPbKgAZLiXm54UI=',
 'user_ptr_id': 13L,
 'username': u''}


My problem is when I serialize the object is only showing this.
{
  "user_permissions": [],
  "activation_key": "52UEOYT8F6EA5Q3K1CXRJMM9PQIFW511DG3H5J",
  "groups": [],
  "key_expires": "2013-02-10T16:59:04Z"
}

anyone know why just UserProfile Attributes has been serialized and User
didn't?

this is my function

def serializeModel(objs, mindent=10, mrelations=True):

try:
raw_data =  json.loads(serializers.serialize('json',objs,
ensure_ascii=False,indent=mindent))
return [d['fields'] for d in raw_data]
except:
raw_data = json.loads(serializers.serialize('json',[objs],
ensure_ascii=False,indent=mindent))

return [d['fields'] for d in raw_data][0]




-- 
Anderson Dias Borges
Senior Analyst Developer

Tu cumprirás o desejo do meu coração se eu Te buscar...
I can't see but I'll take my chances
To hear You call my name

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




ValueError at /admin/flatpages/flatpage/1/

2013-02-08 Thread frocco
If I add a record and do not select the sites dropdown, I get
ValueError at /admin/flatpages/flatpage/1/

Cannot use None as a query value

Request Method:POSTRequest URL:
http://127.0.0.1:8000/admin/flatpages/flatpage/1/Django Version:1.4.3Exception 
Type:ValueErrorException Value:

Cannot use None as a query value

Exception Location:C:\Python27\lib\site-packages\django\db\models\sql\query.py 
in add_filter, line 1095Python Executable:C:\Python27\python.exe

-- 
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: Any good books for learning django?

2013-02-08 Thread Young Park
Online document is the hero. Almost all the books are outdated for Django, 
unfortunately.

On Thursday, February 7, 2013 9:49:36 AM UTC-8, frocco wrote:
>
> Hello,
> Most of what I find are dated, 2008,2009.
> Are these still good for learning django 1.4?
>
> Which books do you recommend?
>
> 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.




Need to add to response object

2013-02-08 Thread Young Park
I'm using web socket (using gevent-socketio) and when any socket action is 
made, it gives me an error saying 

Attrbute Error: response.status_code == 404 > it gives me response has 
no status_code key...

So to handle this I wanted to do something like this in my middleware


class SocketProcessor(object):
"""
This is to handle socket request correctly
Currently using HAProxy, status_code is missing
"""
def process_response(self, request, response):
if 'status_code' not in response:
response['status_code'] = 200
return response


but still i'm getting same error can someone tell me what i'm doing 
wrong?

-- 
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: Replacing a model instance's __dict__

2013-02-08 Thread Daniel Roseman
On Friday, 8 February 2013 09:50:22 UTC-8, Tom Evans wrote:

> Hi all 
>
> I have a curious problem with a complex data replication issue. 
>
> Basically, we use SalesForce as a CRM system. We also have a bunch of 
> users who aren't allowed a SF license due to cost reasons, and they 
> interact with SF via our own Django website that communicates to SF 
> via an API. 
>
> With this API, we can CRUD all salesforce objects. We can also fetch 
> all changes since (specific time), so we maintain a local copy of all 
> our SF data in django models, synchronizing changes every 10 minutes 
> throughout the day. This actually works quite well! 
>
> The problem comes with using django idioms like get_or_create(), when 
> an object is created directly on SF in the period since the last 
> synchronization. In this example, we want to get_or_create a Contact 
> with a specific email address. There is no Contact locally with the 
> specified email address, so get_or_create tries to create a new one. 
>
> Using the API, this issues the appropriate query to SF, but since the 
> Contact already exists on SF, an exception is raised. 
>
> get_or_create(), create() all work via save(), so my idea is to catch 
> this specific error in save, re-synchronise the database against the 
> remote end, pull the freshly synced record out of the database, and 
> replace self.__dict__ with new_item.__dict__, looking something like 
> this: 
>
>   def save(self, *args, **kwargs): 
>   try: 
>   super(Contact, self).save(*args, **kwargs) 
>   except ValueError, e: 
>   if 'Contact already exists' in unicode(e): 
>   # Synchronize Contact objects with SF 
>   run_log = SyncRunLog(start_time=datetime.now()) 
>   run_log.save() 
>   Contact.update(run_log) 
>   # The contact should now be available locally 
>   try: 
>   synched_contact = Contact.objects.get(email=self.email) 
>   self.__dict__ = synched_contact.__dict__ 
>   except Contact.DoesNotExist: 
>   # Still not there, raise a new ValueError 
>   raise ValueError( 
>   'Failed to find contact %s after resyncing ' 
>   'Contact following this error: %s' 
>   % (self.email, unicode(e))) 
>   else: 
>   raise e 
>
> Is there an obvious issue with doing this? Can I simply replace 
> self.__dict__ like that without bad consequences? 
>
> Cheers 
>
> Tom 
>


The only thing I can think of is that by using simple assignment you're 
creating a linkage between the two entities' dicts, which might cause 
problems down the line. Rather than doing that, I would probably do:

self.__dict__.clear()
self.__dict__.update(synched_contact.__dict__)

or maybe even

self.__dict__ = copy.deepcopy(synched_contact.__dict__)

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




Re: Tutorials for formsets using PKs as checkboxes

2013-02-08 Thread Rafael E. Ferrero
You can choose what widget use, one of them convert selectMultiple on
checkboxes 
(checkboxSelectMultiple)
Hope to help you

See ya!

2013/2/8 David 

> Hi
>
> Does anyone know of any good tutorials or guides for using formsets, with
> PKs as checkboxes? Something not to dissimilar to the functionality found
> in the django admin when listing records belonging to a model.
>
> I have tried looking through Django's code but can't find what I need.
>
> Thanks for any 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.
>
>
>



-- 
Rafael E. Ferrero
Claro: (03562) 15514856

-- 
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: Any good books for learning django?

2013-02-08 Thread frocco
I feel the book is fairly priced, and 12 dollars should not hurt anyone.
It is sad, that most of the books out there are 2008,2009 publishing dates.

If I am starting a new project, should I be using django 1.5 or wait til 
the final release?

On Friday, February 8, 2013 12:28:53 PM UTC-5, fgallina wrote:
>
> 2013/2/8 Tom Evans : 
> > On Fri, Feb 8, 2013 at 10:13 AM, vijay shanker 
> >  
> wrote: 
> >> do u have the pdf ? 
> >> will u share it at some place (or please mail it to me 
> deon...@gmail.com ) 
> > 
> > Please don't use this list to arrange or ask others to pirate books. 
> > The author of any django book almost certainly is a subscriber, you 
> > are stealing his/her work from under their nose. 
> > 
>
> I feel the term pirating books is pretty inaccurate, in the sense 
> nobody is jumping to others boat in order to get other people stuff. 
>
> The fact that very same PDF could be copied from 1 or N times in same 
> machine and the original PDF would still be the same makes "pirating" 
> far from the reality. I believe in the particular era we are all into 
> we should be careful with the terminologies we employ for such things 
> as copying a PDF book and give it to another. 
>
> In any case I think: "Don't infringe author's copyright" is better. 
> And I agree the list shouldn't be a channel for that. 
>
> > Please don't pirate technical books anyway. If everyone pirated 
> > technical books, there would be no incentive to write new technical 
> > books, and everyone loses out. 
> > 
>
> There are plenty of free books and manuals available for free (as in 
> beer) over the net, normally pricing for their printed versions (not 
> the old way of doing things I agree, but it may well be the future). 
>
> Not looking into some discussion, I though it was worth to mention this. 
>
>
> Saludos, 
> -- 
> Fabián E. Gallina 
> http://www.from-the-cloud.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.




Replacing a model instance's __dict__

2013-02-08 Thread Tom Evans
Hi all

I have a curious problem with a complex data replication issue.

Basically, we use SalesForce as a CRM system. We also have a bunch of
users who aren't allowed a SF license due to cost reasons, and they
interact with SF via our own Django website that communicates to SF
via an API.

With this API, we can CRUD all salesforce objects. We can also fetch
all changes since (specific time), so we maintain a local copy of all
our SF data in django models, synchronizing changes every 10 minutes
throughout the day. This actually works quite well!

The problem comes with using django idioms like get_or_create(), when
an object is created directly on SF in the period since the last
synchronization. In this example, we want to get_or_create a Contact
with a specific email address. There is no Contact locally with the
specified email address, so get_or_create tries to create a new one.

Using the API, this issues the appropriate query to SF, but since the
Contact already exists on SF, an exception is raised.

get_or_create(), create() all work via save(), so my idea is to catch
this specific error in save, re-synchronise the database against the
remote end, pull the freshly synced record out of the database, and
replace self.__dict__ with new_item.__dict__, looking something like
this:

  def save(self, *args, **kwargs):
  try:
  super(Contact, self).save(*args, **kwargs)
  except ValueError, e:
  if 'Contact already exists' in unicode(e):
  # Synchronize Contact objects with SF
  run_log = SyncRunLog(start_time=datetime.now())
  run_log.save()
  Contact.update(run_log)
  # The contact should now be available locally
  try:
  synched_contact = Contact.objects.get(email=self.email)
  self.__dict__ = synched_contact.__dict__
  except Contact.DoesNotExist:
  # Still not there, raise a new ValueError
  raise ValueError(
  'Failed to find contact %s after resyncing '
  'Contact following this error: %s'
  % (self.email, unicode(e)))
  else:
  raise e

Is there an obvious issue with doing this? Can I simply replace
self.__dict__ like that without bad consequences?

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: Any good books for learning django?

2013-02-08 Thread Fabian Ezequiel Gallina
2013/2/8 Tom Evans :
> On Fri, Feb 8, 2013 at 10:13 AM, vijay shanker  wrote:
>> do u have the pdf ?
>> will u share it at some place (or please mail it to me deont...@gmail.com)
>
> Please don't use this list to arrange or ask others to pirate books.
> The author of any django book almost certainly is a subscriber, you
> are stealing his/her work from under their nose.
>

I feel the term pirating books is pretty inaccurate, in the sense
nobody is jumping to others boat in order to get other people stuff.

The fact that very same PDF could be copied from 1 or N times in same
machine and the original PDF would still be the same makes "pirating"
far from the reality. I believe in the particular era we are all into
we should be careful with the terminologies we employ for such things
as copying a PDF book and give it to another.

In any case I think: "Don't infringe author's copyright" is better.
And I agree the list shouldn't be a channel for that.

> Please don't pirate technical books anyway. If everyone pirated
> technical books, there would be no incentive to write new technical
> books, and everyone loses out.
>

There are plenty of free books and manuals available for free (as in
beer) over the net, normally pricing for their printed versions (not
the old way of doing things I agree, but it may well be the future).

Not looking into some discussion, I though it was worth to mention this.


Saludos,
-- 
Fabián E. Gallina
http://www.from-the-cloud.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: Any good books for learning django?

2013-02-08 Thread Yussi

On 08/02/13 16:54, Mike wrote:

Thanks for the recommendation! I just bought it and spent five minutes
browsing and already I learned a lot. Here's a few chapters that I'll
read right away:

Security best practices
Django app design
When to use function based views or class based views
Deploying

The book is currently in alpha but it says that buyers will get the beta
and final version when they're released. I can see that is going to be
well worth the 12 bucks.


On Thursday, February 7, 2013 7:10:01 PM UTC+1, Mayukh Mukherjee wrote:

I'd recommend two scoops of django.
It's a little more intermediate level but it's a gem.

Sent from my iPhone

On Feb 7, 2013, at 12:49, frocco  wrote:


Hello,
Most of what I find are dated, 2008,2009.
Are these still good for learning django 1.4?

Which books do you recommend?

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




--
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: Any good books for learning django?

2013-02-08 Thread Mike
Thanks for the recommendation!  I just bought it and spent five minutes 
browsing and already I learned a lot.  Here's a few chapters that I'll read 
right away:

Security best practices
Django app design
When to use function based views or class based views
Deploying

The book is currently in alpha but it says that buyers will get the beta 
and final version when they're released.  I can see that is going to be 
well worth the 12 bucks.


On Thursday, February 7, 2013 7:10:01 PM UTC+1, Mayukh Mukherjee wrote:
>
> I'd recommend two scoops of django.
> It's a little more intermediate level but it's a gem.
>
> Sent from my iPhone
>
> On Feb 7, 2013, at 12:49, frocco  wrote:
>
> Hello,
> Most of what I find are dated, 2008,2009.
> Are these still good for learning django 1.4?
>
> Which books do you recommend?
>
> 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...@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: E-commerce framework for downloadable content

2013-02-08 Thread robertlnewman
Also there is Braintree and Stripe, which are not Django specific nor Python 
specific, but offer nice Python APIs. I have especially heard nice things about 
Stripe 
(http://www.kalzumeus.com/2012/08/06/stripe-and-ab-testing-made-me-a-small-fortune/
 - ignore the fact that the post is about RoR, there is a Python version of the 
API too)

Braintree: https://www.braintreepayments.com/docs/python
Stripe: https://stripe.com/docs/libraries#python-library

Good luck,
- Rob

On Feb 8, 2013, at 5:46 AM, Avraham Serour wrote:

> don't forget satchmo.
> 
> In any case I believe all the shops have support for downloadable products, 
> it it a fairly common case
> 
> Usually the shops don't store cc info, they connect to some payment processor 
> like paypal, or are flexible so you can implement your own like collect on 
> delivery
> 
> avraham
> 
> 
> On Fri, Feb 8, 2013 at 3:02 PM, Carlos Edo Méndez  
> wrote:
> Hi!
> 
> I'm looking for a django framework for e-commerce.
> I've been searching and i found LFS, Satchless, Plata... but I don't know 
> which is the most suitable for my needs.
> My project is similar to iPhone's Appstore. The content to sell is 
> downloadable and it is uploaded by third party developers or designers. I 
> also need it to be fast and easy to pay, maybe storing credit card 
> information or a similar solution.
> Do you know which framework would be best for this?
> 
> Thanks in advance,
> Carlos
> 
> -- 
> 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.
>  
>  

-- 
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: AccountDeletion remains after expunge_deleted

2013-02-08 Thread robertlnewman
Hi Paton,

Not to be obtuse, but the question you are asking is actually unique to the 
Pinax project (http://pinaxproject.com/). AFAIK Django's manage.py doesn't have 
any expunge_deleted command (at least as far as my manage.py help output shows, 
and I am running the latest Django 1.4.2). You might get more luck asking this 
question in the Pinax Google Group (pinax-us...@googlegroups.com) which is 
specific to that project.

A quick browse of the Pinax source code (well, actually the Pinax creators 
sub-project django-user-accounts which is used by Pinax) you will see the 
following:
from django.core.management.base import BaseCommand

from account.models import AccountDeletion


class Command(BaseCommand):

help = "Expunge accounts deleted more than 48 hours ago."

def handle(self, *args, **options):
count = AccountDeletion.expunge()
print "%d expunged." % count

(source: 
https://github.com/pinax/django-user-accounts/blob/master/account/management/commands/expunge_deleted.py)

Going back up the tree (to the django-user-accounts account.models file) and 
looking at the source you will see the following (starting at line 342):
class AccountDeletion(models.Model):

user = models.ForeignKey(User, null=True, blank=True, 
on_delete=models.SET_NULL)
email = models.EmailField()
date_requested = models.DateTimeField(default=timezone.now)
date_expunged = models.DateTimeField(null=True, blank=True)

@classmethod
def expunge(cls, hours_ago=None):
if hours_ago is None:
hours_ago = settings.ACCOUNT_DELETION_EXPUNGE_HOURS
before = timezone.now() - datetime.timedelta(hours=hours_ago)
count = 0
for account_deletion in cls.objects.filter(date_requested__lt=before, 
user__isnull=False):
settings.ACCOUNT_DELETION_EXPUNGE_CALLBACK(account_deletion)
account_deletion.date_expunged = timezone.now()
account_deletion.save()
count += 1
return count

@classmethod
def mark(cls, user):
account_deletion, created = cls.objects.get_or_create(user=user)
account_deletion.email = user.email
account_deletion.save()
settings.ACCOUNT_DELETION_MARK_CALLBACK(account_deletion)
return account_deletion
(source: 
https://github.com/pinax/django-user-accounts/blob/master/account/models.py)

There you can see the expunge() method in its entirety. It actually looks like 
there is a specific time period before the users are deleted, but I am not a 
Pinax expert by any means.

Hope that helps, and good luck.
- Rob

On Feb 7, 2013, at 10:43 PM, Paton Lewis wrote:

> I started my project via:
> 
> django-admin.py startproject 
> --template=https://github.com/pinax/pinax-project-account/zipball/master 
> myproject
> 
> One of the features provided by the account system is delayed deletion of 
> accounts. When you delete an account, it isn't actually deleted. Instead, an 
> AccountDeletion object is created that tracks the deletion request. When you 
> run
> 
> manage.py expunge_deleted
> 
> then the AccountDeletion objects are iterated and any Account objects that 
> are more than 48 hours old are deleted.
> 
> My question has to do with the AccountDeletion objects. These objects aren't 
> deleted, and it looks like they remain in the database forever. Is this 
> intentional? Is there another command that expunges the AccountDeletion 
> objects? Or is this just a bug in the AccountDeletion class implementation?
> 
> -- 
> 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.




Tutorials for formsets using PKs as checkboxes

2013-02-08 Thread David
Hi

Does anyone know of any good tutorials or guides for using formsets, with 
PKs as checkboxes? Something not to dissimilar to the functionality found 
in the django admin when listing records belonging to a model.

I have tried looking through Django's code but can't find what I need.

Thanks for any 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: How to create a Django Group in case of multiple databases.

2013-02-08 Thread laxmikant ratnaparkhi
I have not trimmed traceback. This is ouput came on python manage.py shell.

And one more thing I modified save method This looks like this:

   def save(self):
if not self.id:
self.created_date_time = datetimeToUTC()
self.modified_date_time = datetimeToUTC()
self.modified_date_time = datetimeToUTC()
super(ModelName, self).save()
if not self.uid:
self.uid = idmaptoalpha.getUID(self.id)
super(ModelName, self).save()

 Can you plz tell me if anything is wrong in it.

Thanks again.

*N.B.:*But I have not  modified method for Django's Group  Table. This is
only for the new Classed I created.

Regards,
Laxmikant


On Thu, Feb 7, 2013 at 11:49 PM, Tom Evans  wrote:

> On Thu, Feb 7, 2013 at 12:16 PM, laxglx  wrote:
> >
> > Hello Everybody,
> >
> > I'm going to create a Group using Django Group.
> >
> > I have two databases one is "master" and another is "slave"
> > In master I created a user and group as usual.
> >
> > And in slave database I tried like this:
> >
> >
>  Group.objects.db_manager('slave').create(name="grp1")
> >
> > This returned an error :
> >
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "/usr/lib/python2.6/site-packages/django/db/models/manager.py",
> line
> > 138, in create
> > return self.get_query_set().create(**kwargs)
> >   File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line
> > 358, in create
> > obj.save(force_insert=True, using=self.db)
> > TypeError: save() got an unexpected keyword argument 'force_insert'
>
> Have you trimmed this traceback?
>
> >
> > I also tried as follows, but got error :
> >
>  g = Group()
>  g.name = "grp1"
>  g.save(using='slave')
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > TypeError: save() got an unexpected keyword argument 'using'
> >
>
> It looks like you have overwritten the save() method on the model you
> are trying to save, and have not given it a method signature capable
> of accepting the necessary arguments that save() is expected to
> handle.
>
> I say 'looks like', since I think you have obliterated the parts of
> the traceback that would tell me…
>
> save() takes many arguments. If you are not specifying any additional
> arguments for your save() method, then it should look like so:
>
> def save(self, *args, **kwargs):
>
> This protects you from having to change the method if more arguments
> are added in later versions of django, eg when the 'using' argument
> was added in 1.2.
>
> As usual, the docs have canonical instructions on how to override
> model methods like save():
>
>
> https://docs.djangoproject.com/en/1.4/topics/db/models/#overriding-model-methods
>
> 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: post_save signal getting called twice !

2013-02-08 Thread vijay shanker
yes that was it. thanks a ton. ;)

On Friday, February 8, 2013 5:21:19 PM UTC+5:30, Martin J. Laubach wrote:
>
> further, i tried putting a sender argument in receiver, but the sender , i 
>> found (by set_trace) is Cart_cartitems, how can i import this > 'shoppingcart.models.Cart_cartitems'> when its only a intermediary model 
>> that django's creating.
>
>
>   I think you want Cart.cartitems.through
>
>   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: Is there any way to apply a constraint on ForeignKey/OneToOneField being attached to any model based on some condition ?

2013-02-08 Thread vijay shanker
fortunately my case was really simple, i had to count number of m2m objects 
attached to my model and storing it as field, and  had to make the decision 
of having a ForeignKey/OneToOne relation based on number of m2m objects 
attached.I was already using m2m_changed signal ( on post_add ), so i 
handled the case there itself
thanks tran.
:)

On Thursday, February 7, 2013 2:33:46 PM UTC+5:30, Huu Da Tran wrote:
>
> You could overwrite the save() method... or if you are populating from a 
> form, overwrite the clean() method.
>
> On Thursday, February 7, 2013 3:23:54 AM UTC-5, vijay shanker wrote:
>>
>> Hi
>> I have these two models Cart and CartItem,
>>
>> class Cart(models.Model):
>> cart_id = models.CharField(max_length=
>> 50, null=False)
>> customer= models.ForeignKey(Customer,null=True,blank=True)
>> cartitems   = models.ManyToManyField(CartItem,null=True)
>> applied_rule= 
>> models.OneToOneField(CartRule,null=True,blank=True)
>> 
>>
>> class CartItem(models.Model):
>> content_type= models.ForeignKey(ContentType)
>> object_id   = models.PositiveIntegerField()
>> content_object  = 
>> generic.GenericForeignKey('content_type','object_id')
>> quantity= models.PositiveIntegerField(default=0)
>> is_abandoned= models.BooleanField(default=False)
>> def __str__(self):
>> return self.cart_id
>>
>> the rules to be applied only when there are more than two items in 
>> shoppingcart, i.e i am looking for a way to attach a rule to cart only if 
>> there are more than two items in cart (cartitems m2m field should have more 
>> than two objects in it).
>> How should i go about it ?
>>
>

-- 
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: Set db connections manually for each request.

2013-02-08 Thread vijay shanker
write a custom manager and use it whenever you want to do use other 
database:

https://docs.djangoproject.com/en/1.3/topics/db/multi-db/#using-get-query-set-with-multiple-databases


On Thursday, February 7, 2013 7:08:40 PM UTC+5:30, girishms wrote:
>
> Hi All,
> Is it possible to set db connection manually for each request?
>
> Here is the senerio:
> There are two dbs (lets say:db-1 and db-2) in my application.
> I need to use db-1 for some views and db-2 for others.
> I know that django creates separate connection for each request, is it 
> possible to specify
> which db to be used during connection.?
>
>
> There is a way to do this for each query by using - "using":
>ex: modelname.objects.using('db-name')
> But as there are lot of queries in views, its very hard to do for each 
> query.
>
>
> -- 
> Girish M S 
>

-- 
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: IntegrityError when creating a brand new model instance

2013-02-08 Thread Andre Terra
Please post traceback, settings.py, etc.

On Fri, Feb 8, 2013 at 5:18 AM, Some Developer wrote:

> I have a model for a Tag object with simply has two fields. A title (which
> has the unique constraint) and a description. I also have a FormView based
> view class which handles the creation of Tag objects.
>
> When I try and save the object in the form_valid() method I always get an
> IntegrityError stating that the title column is not unique. This is
> somewhat puzzling as I have deleted the SQLite database file and recreated
> it using syncdb / migrate so it is completely empty.
>
> I'm completely baffled by this error.
>
> --
> 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+unsubscribe@**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: E-commerce framework for downloadable content

2013-02-08 Thread Avraham Serour
don't forget satchmo.

In any case I believe all the shops have support for downloadable products,
it it a fairly common case

Usually the shops don't store cc info, they connect to some payment
processor like paypal, or are flexible so you can implement your own
like collect on delivery

avraham


On Fri, Feb 8, 2013 at 3:02 PM, Carlos Edo Méndez wrote:

> Hi!
>
> I'm looking for a django framework for e-commerce.
> I've been searching and i found LFS, Satchless, Plata... but I don't know
> which is the most suitable for my needs.
> My project is similar to iPhone's Appstore. The content to sell is
> downloadable and it is uploaded by third party developers or designers. I
> also need it to be fast and easy to pay, maybe storing credit card
> information or a similar solution.
> Do you know which framework would be best for this?
>
> Thanks in advance,
> Carlos
>
> --
> 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.




E-commerce framework for downloadable content

2013-02-08 Thread Carlos Edo Méndez
Hi!

I'm looking for a django framework for e-commerce.
I've been searching and i found LFS, Satchless, Plata... but I don't know 
which is the most suitable for my needs.
My project is similar to iPhone's Appstore. The content to sell is 
downloadable and it is uploaded by third party developers or designers. I 
also need it to be fast and easy to pay, maybe storing credit card 
information or a similar solution.
Do you know which framework would be best for this?

Thanks in advance,
Carlos

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




AccountDeletion remains after expunge_deleted

2013-02-08 Thread Paton Lewis
I started my project via:

django-admin.py startproject 
--template=https://github.com/pinax/pinax-project-account/zipball/master 
myproject

One of the features provided by the account system is delayed deletion of 
accounts. When you delete an account, it isn't actually deleted. Instead, 
an AccountDeletion object is created that tracks the deletion request. When 
you run

manage.py expunge_deleted

then the AccountDeletion objects are iterated and any Account objects that 
are more than 48 hours old are deleted.

My question has to do with the AccountDeletion objects. These objects 
aren't deleted, and it looks like they remain in the database forever. Is 
this intentional? Is there another command that expunges the 
AccountDeletion objects? Or is this just a bug in the AccountDeletion class 
implementation?

-- 
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: Any good books for learning django?

2013-02-08 Thread Mark Phillips
+1 to Tom

Mark


On Fri, Feb 8, 2013 at 5:58 AM, Tom Evans  wrote:

> On Fri, Feb 8, 2013 at 10:13 AM, vijay shanker  wrote:
> > do u have the pdf ?
> > will u share it at some place (or please mail it to me
> deont...@gmail.com)
>
> Please don't use this list to arrange or ask others to pirate books.
> The author of any django book almost certainly is a subscriber, you
> are stealing his/her work from under their nose.
>
> Please don't pirate technical books anyway. If everyone pirated
> technical books, there would be no incentive to write new technical
> books, and everyone loses out.
>
> 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: Any good books for learning django?

2013-02-08 Thread Tom Evans
On Fri, Feb 8, 2013 at 10:13 AM, vijay shanker  wrote:
> do u have the pdf ?
> will u share it at some place (or please mail it to me deont...@gmail.com)

Please don't use this list to arrange or ask others to pirate books.
The author of any django book almost certainly is a subscriber, you
are stealing his/her work from under their nose.

Please don't pirate technical books anyway. If everyone pirated
technical books, there would be no incentive to write new technical
books, and everyone loses out.

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: post_save signal getting called twice !

2013-02-08 Thread Martin J. Laubach

>
> further, i tried putting a sender argument in receiver, but the sender , i 
> found (by set_trace) is Cart_cartitems, how can i import this  'shoppingcart.models.Cart_cartitems'> when its only a intermediary model 
> that django's creating.


  I think you want Cart.cartitems.through

  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: Any good books for learning django?

2013-02-08 Thread yati sagade
You should read the Django tutorial and then maybe build an app that will
make you more comfortable with Django. It may be any app - a notes taking
app, for example. During the process, you'll pay a large number of visits
to the wonderful Django docs and will come to appreciate them. There is The
Django Book, which is dated, but if you carefully read it making sure you
what changed and what did not, there's a wealth of knowledge in there (I
was lucky as in when I picked up Django, The Django Book was not dated :))
Then, once you are really comfortable with Django, go for Two Scoops of
Django - really, buy it. It is worth it. The #django channel on Freenode is
an excellent way of asking help and learning new things by maybe helping
others in need.

Cheers

-- 
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: Any good books for learning django?

2013-02-08 Thread vijay shanker
do u have the pdf ?
will u share it at some place (or please mail it to me deont...@gmail.com)

On Thursday, February 7, 2013 11:40:01 PM UTC+5:30, Mayukh Mukherjee wrote:
>
> I'd recommend two scoops of django.
> It's a little more intermediate level but it's a gem.
>
> Sent from my iPhone
>
> On Feb 7, 2013, at 12:49, frocco  wrote:
>
> Hello,
> Most of what I find are dated, 2008,2009.
> Are these still good for learning django 1.4?
>
> Which books do you recommend?
>
> 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...@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: post_save signal getting called twice !

2013-02-08 Thread vijay shanker

further, i tried putting a sender argument in receiver, but the sender , i 
found (by set_trace) is Cart_cartitems, how can i import this  when its only a intermediary model 
that django's creating.
On Friday, February 8, 2013 11:26:47 AM UTC+5:30, vijay shanker wrote:
>
> Thanks Evans.That was helpful. :)
>
> On Thursday, February 7, 2013 7:54:36 PM UTC+5:30, Tom Evans wrote:
>>
>> On Thu, Feb 7, 2013 at 1:54 PM, vijay shanker  wrote: 
>> > Hi 
>> > I am using django version 1.4.3 
>> > I am using two signals in my models.py 
>> > one is m2m_changed, so i can have a counter field (numcounter) of 
>> number of 
>> > m2m fields attached, and another is post_save so i can decide whether 
>> to 
>> > have a OneToOneField (cartrule, is to be applied only if there are more 
>> than 
>> > 2 fields) or not. 
>> > my models.py is: 
>> > 
>> > class CartItem(models.Model): 
>> > content_type= models.ForeignKey(ContentType) 
>> > object_id   = models.PositiveIntegerField() 
>> > content_object  = generic.GenericForeignKey(' 
>> > content_type','object_id') 
>> > quantity= models.PositiveIntegerField(default=0) 
>> > is_abandoned= models.BooleanField(default=False) 
>> > created_at  = models.DateTimeField(auto_now_add=True) 
>> > update_at   = models.DateTimeField(auto_now=True) 
>> > def __str__(self): 
>> > return self.content_object.name 
>> > 
>> > class CartRule(models.Model): 
>> > ##some field 
>> > pass 
>> > 
>> > class Cart(models.Model): 
>> > cart_id = models.CharField(max_length=50, null=False) 
>> > customer= 
>> models.ForeignKey(Customer,null=True,blank=True) 
>> > cartitems   = models.ManyToManyField(CartItem,null=True) 
>> > created_at  = models.DateTimeField(auto_now_add=True) 
>> > update_at   = models.DateTimeField(auto_now=True) 
>> > cartrule   = 
>> > models.OneToOneField(crapclass,null=True,blank=True) 
>> > num_cartitem= models.IntegerField() 
>> > def __str__(self): 
>> > return self.cart_id 
>> > 
>> > @receiver(post_save, sender=Cart) 
>> > def apply_condition(sender,instance,created,raw,using,*args,**kwargs): 
>> > # i want to decide here if num_cartitem is greater than 2 its ok to 
>> have 
>> > a cartrule 
>> > pass 
>> > 
>> > @receiver(m2m_changed) 
>> > def save_cartitem_counter(sender, instance, signal,*args, **kwargs): 
>> > if kwargs['action'] == 'post_add': 
>> > instance.num_cartitem = instance.cartitems.all().count() 
>> > instance.save() 
>> > 
>> > the issue is apply_condition gets called twice, with similar value of 
>> args, 
>> > first with older value of m2m (cartitem) field in Cart, the other time 
>> with 
>> > the values i intended to save 
>> > I looked into older post but still could not figure out the whys.How 
>> should 
>> > i go about this ? 
>> > 
>>
>> When you save a Cart instance, the post_save signal is triggered. 
>> If the M2M relationship is changed as well, then the m2m_changed 
>> signal is triggered. Your handler for this then re-saves the Cart 
>> instance after denormalising data, which triggers the post save signal 
>> for a second time. 
>> You should probably connect the M2M receiver to a specific sender too, 
>> currently it will fire whenever any M2M on any model is changed. 
>>
>> Keeping denormalized data like that is a pain, could you do without 
>> it, and re-calculate it where necessary? 
>>
>> Alternatively, you could use a named intermediary M2M relationship: 
>>
>>
>> https://docs.djangoproject.com/en/1.4/topics/db/models/#intermediary-manytomany
>>  
>>
>> and connect signals on post_create and post_delete to the intermediary 
>> model, updating the Cart as necessary. 
>>
>> This is a little more logical, since you wish to denormalise the data 
>> whenever an item is added to or removed from a cart, ie whenever a row 
>> is added or deleted to the intermediate table. Naming the relationship 
>> allows you to connect the signals to the right place. 
>>
>> 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.