save() got an unexpected keyword argument 'force_insert'

2012-09-24 Thread Laxmikant Gurnalkar

Hi guys, 
Anybody knows why I'm at this stage ?
Group.objects.using('db2').get_or_create(name='Maintenance Admin')
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 
383, in get_or_create
obj.save(force_insert=True, using=self.db)
TypeError: save() got an unexpected keyword argument 'force_insert'


I'm getting this error on creating a new group on mydatabase2
Not getting the exact reason behind this ...
plz help ...

Thanks in Advance

-- 
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/-/4Rosfupipe4J.
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: Inheritance and default value

2012-09-25 Thread Laxmikant Gurnalkar
Hi winniehell,
  I think this will help you.
Dummy.__dict__.update({"myfield":42})

regards
--Laxmikant Gurnalkar


On Tue, Sep 25, 2012 at 4:17 PM, winniehell  wrote:

> Hello list!
>
> I try to overwrite a default value of a field in a subclass of an
> abstract model. This is how I do it currently:
> https://gist.github.com/3781124
>
> Is there any better way? As far as I know the _meta-class API is subject
> to change.
>
> Just to be clear about that: I can not move myfield out of the Base
> class as there are multiple classes inheriting from it.
>
> Best regards,
> Winnie
>
> --
> 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.
>
>


-- 
*

 GlxGuru

*

-- 
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: Getting Started

2012-09-25 Thread Laxmikant Gurnalkar
Hi,
Extending to  Jani Tiainen--

 Or you have not properly installed Django, It looks like manage.py is
missing. In any of the version manage.py comes by default.
Use 7-zip   to unzip the django tarballs on windows machine.

regards,
Laxmikant



On Mon, Sep 24, 2012 at 9:37 PM, Greg Lindstrom wrote:

> Hello,
>
> I am having trouble getting started using Django 1.4.1 on my Windows 7
> machine.  Everything appears to be installed (I'm running Python 2.7 and
> have been programming in Python for over 10 years; I figure it's time to
> see what all the fuss is over "the web" :-).
>
> Reading through the tutorial on the Django page (the "polls" project), I
> start a new project using "django-admin.py startproject mysite".  It
> creates a new directory -- as promised -- but I'm in trouble, already!  My
> directory structure does not match the tutorial.  I expect:
>
> mysite/manage.py
> mysite/mysite/__init__.py
> mysite/mysite/manage.py
> mysite/mysite/settings.py
> mysite/mysite/urls.py
> mysite/mysite/wgsi.py
>
> and I get all of those.  But, I also get
>
> mysite/__init__.py
> mysite/setings.py
> mysite/urls.py
>
> giving me __init__.py, settings.py, and urls.py in both the "outter" and
> "inner" directories.  I'm I in the wrong tutorial?  The initital web server
> runs and I can edi the models.py file, but when I attempt the "python
> manage.py sql polls" command the settings file die snot know about "polls"
> (I added it to the applications).
>
> I'm eager to learn Django; can someone please give me a kick in the proper
> direction?
>
> --greg
> --
> 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/-/fkNOGLcwvpQJ.
> 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.



Unable to Store Decimal values to DecimalField

2012-09-27 Thread Laxmikant Gurnalkar
Hi ,

   While storing decimal values to database I have following error.

Exception in storeFormatMetadataTraceback (most recent call last):
  File "/var/opt/igp_acfs/acfs/bookproducts_manager.py", line 118, in 
storePricing
book.save()
  File "/var/opt/igp_acfs/acfs/models.py", line 529, in save
super(BookProductFormat, self).save()
  File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 
458, in save
self.save_base(using=using, force_insert=force_insert, 
force_update=force_update)
  File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 
524, in save_base
rows = manager.using(using).filter(pk=pk_val)._update(values)
  File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 
502, in _update
return query.get_compiler(self.db).execute_sql(None)
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", 
line 866, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", 
line 722, in execute_sql
sql, params = self.as_sql()
  File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", 
line 831, in as_sql
val = field.get_db_prep_save(val, connection=self.connection)
  File 
"/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", 
line 28, in inner
return func(*args, **kwargs)
  File 
"/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", 
line 28, in inner
return func(*args, **kwargs)
  File 
"/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", 
line 28, in inner
return func(*args, **kwargs)
  File 
"/usr/lib/python2.6/site-packages/django/db/models/fields/__init__.py", 
line 276, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, 
prepared=False)
  File 
"/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", 
line 53, in inner
return func(*args, **kwargs)
  File 
"/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", 
line 53, in inner
return func(*args, **kwargs)
  File 
"/usr/lib/python2.6/site-packages/django/db/models/fields/subclassing.py", 
line 53, in inner
return func(*args, **kwargs)
  File 
"/usr/lib/python2.6/site-packages/django/db/models/fields/__init__.py", 
line 271, in get_db_prep_value
value = self.get_prep_value(value)
  File 
"/usr/lib/python2.6/site-packages/django/db/models/fields/__init__.py", 
line 876, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: ''


This is my code :

obj = Model.objects.get(uid = formatuid)
obj.price = Decimal(price).quantize(Decimal('.01'), 
rounding='ROUND_DOWN')
obj.active = 1 if formats.get(format, "")else 0
obj.save()


This is my mdel Field

price = models.DecimalField(max_digits=3, decimal_places=2, 
blank=True, null=True)


I dont think. I'm wrong somewhere. Please HELP 
Obviously price is my decimal Field.


Best Regards,
Laxmikant

-- 
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/-/K6k0jAEaxYcJ.
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: last changed by User

2012-09-27 Thread Laxmikant Gurnalkar
Hello.
   You can Hack the *Default models* & add new fields in User Table
created_datetime, modified_datetime & created by, modified by etc.


Cheers

On Fri, Sep 28, 2012 at 9:03 AM, Lachlan Musicman  wrote:

> On Friday, September 28, 2012, Lachlan Musicman wrote:
>
>>
>> I wanted to display the user that last changed a model instance.
>>
>> Despite this, I've found a couple of pages, with this being the most like
>> what I want:
>>
>> https://code.djangoproject.com/wiki/CookBookNewformsAdminAndUser
>>
>> I like this solution - simple and clean, easy to implement.
>>
>> My only reservation is that I was under the impression that this
>> information was already being kept and that putting a
>>
>> user = ForeignKey("User")
>>
>> in each model that I want to track is doubling up on the data I'm keeping?
>>
>
> To clarify - I can see the last ten actions I've taken when I'm logged
> into the admin interface - is this info permanent and easy to access and
> display on the model DetailView?
>
> cheers
> L.
>
>
> --
> ...we look at the present day through a rear-view mirror. This is
> something Marshall McLuhan said back in the Sixties, when the world was in
> the grip of authentic-seeming future narratives. He said, “We look at the
> present through a rear-view mirror. We march backwards into the future.”
>
> http://www.warrenellis.com/?p=14314
>
> --
> 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.
>



-- 
*

 GlxGuru

*

-- 
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: i am getting ConfigParser.NoSectionError: No section: 'database' plz help

2012-09-28 Thread Laxmikant Gurnalkar
ohh sorry I didnt checked, I thought it was the part of settings itself.

On Fri, Sep 28, 2012 at 10:06 AM, Nick Dokos  wrote:

> Laxmikant Gurnalkar  wrote:
>
> > Thats the same I'm saying to you.
> > In your settings.conf. There is no section named 'database'
>
> Look again: there *is* a [database] section at the very bottom:
>
> [database]
> engine: django.db.backends.mysql
> name  : kasakoo
> user  : root
> password  : password
> host  : localhost
> port  : 3306
>
> Nick
>
> > create a section in that file to store your database info.
> > >>>>Check the file located at :
> > os.path.join(PROJECT_PATH, 'settings.conf')
> >
> > On Fri, Sep 28, 2012 at 9:50 AM, Navnath Gadakh 
> wrote:
> >
> > my setting.py is
> >  and a have also created a new setting.conf .may be there is problem
> of path,plz  help. thnks in
> > adv
> > # Django settings for kasakooproj project.
> >
> > import os
> > import ast
> >
> > from ConfigParser import RawConfigParser
> >
> > config = RawConfigParser()
> > PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
> > config.read(os.path.join(PROJECT_PATH, 'settings.conf'))
> >
> > DEBUG = True
> > TEMPLATE_DEBUG = DEBUG
> >
> > MANAGERS = ADMINS
> >
> > DATABASES = {
> > 'default': {
> > 'ENGINE'  : config.get('database','engine'),
> > 'NAME': config.get('database','name'),
> > 'USER': config.get('database','user'),
> > 'PASSWORD': config.get('database','password'),
> > 'HOST': config.get('database','host'),
> > 'PORT':
> config.get('database','port'), }
> > }
> >
> > # Local time zone for this installation. Choices can be found here:
> > # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> > # although not all choices may be available on all operating systems.
> > # On Unix systems, a value of None will cause Django to use the same
> > # timezone as the operating system.
> > # If running in a Windows environment this must be set to the same
> as your
> > # system time zone.
> > TIME_ZONE = 'America/Chicago'
> >
> > # Language code for this installation. All choices can be found here:
> > # http://www.i18nguy.com/unicode/language-identifiers.html
> > LANGUAGE_CODE = 'en-us'
> >
> > SITE_ID = 1
> >
> > # If you set this to False, Django will make some optimizations so
> as not
> > # to load the internationalization machinery.
> > USE_I18N = True
> >
> > # If you set this to False, Django will not format dates, numbers and
> > # calendars according to the current locale
> > USE_L10N = True
> >
> > # Absolute filesystem path to the directory that will hold
> user-uploaded files.
> > # Example: "/home/media/media.lawrence.com/media/"
> > MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
> >
> > # URL that handles the media served from MEDIA_ROOT. Make sure to
> use a
> > # trailing slash.
> > # Examples: "http://media.lawrence.com/media/";, "
> http://example.com/media/";
> > MEDIA_URL = config.get('media_url', 'value')
> >
> > # Absolute path to the directory static files should be collected to.
> > # Don't put anything in this directory yourself; store your static
> files
> > # in apps' "static/" subdirectories and in STATICFILES_DIRS.
> > # Example: "/home/media/media.lawrence.com/static/"
> > STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
> >
> > # URL prefix for static files.
> > # Example: "http://media.lawrence.com/static/";
> > STATIC_URL = config.get('static_url', 'value')
> >
> > # URL prefix for admin static files -- CSS, JavaScript and images.
> > # Make sure to use a trailing slash.
> > # Examples: "http://foo.com/static/admin/";, "/static/admin/".
> > ADMIN_MEDIA_PREFIX = '/static/admin/'

Re: Newbie question - setting a model form foriegn key

2012-10-01 Thread Laxmikant Gurnalkar
def payments_view(request, contact_id):
payment = Payment()

payment.contact  = contact[0]


   rctx = RequestContext(request,{
> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
> })
> return render_to_response('CRMSite/contact_payments.html',rctx)
>
On Tue, Oct 2, 2012 at 4:20 AM, Keir Lawson  wrote:

> Sorry if this is a dumb question, just picking up Django.
>
> I've set up a payments form, to create payments associated with a contact
> (see payments model) however I'm having trouble figuring out how to save
> the payment with the relevant contact associated, as the contact isnt
> selected as part of the form (its in the URL instead).  I've included both
> the payment view and the view for processing it, my current approach
> results in a validation error. Anyone able to help?
>
> Thanks
>
> Keir
>
> class Payment(models.Model):
> amount = models.DecimalField(max_digits=10, decimal_places=2)
> date = models.DateField()
> contact = models.ForeignKey(Contact)
>
> def payments_view(request, contact_id):
> contact = get_object_or_404(Contact, pk=contact_id)
> payments = Payment.objects.filter(contact=contact_id)
> rctx = RequestContext(request,{
> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
> })
> return render_to_response('CRMSite/contact_payments.html',rctx)
>
> def save_payment(request,contact_id):
> PaymentForm(request.POST,contact=contact_id).save()
> return payments_view(request, contact_id)
>
>  --
> 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/-/g4cNoMI7bEoJ.
> 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 - setting a model form foriegn key

2012-10-01 Thread Laxmikant Gurnalkar
Sorry, see again!!

def payments_view(request, contact_id):
payment = Payment()
contact =   contact.objects.filter(id=contact_id)
if contact:
payment.contact  = contact[0]
payment.save()


I dont think you are looking for this kind of thing :
cheers

On Tue, Oct 2, 2012 at 10:42 AM, Laxmikant Gurnalkar <
laxmikant.gurnal...@gmail.com> wrote:

> def payments_view(request, contact_id):
> payment = Payment()
> payment.contact  = contact[0]
>
>> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
>> })
>> return render_to_response('CRMSite/contact_payments.html',rctx)
>>
>rctx = RequestContext(request,{
> On Tue, Oct 2, 2012 at 4:20 AM, Keir Lawson  wrote:
>
>> Sorry if this is a dumb question, just picking up Django.
>>
>> I've set up a payments form, to create payments associated with a contact
>> (see payments model) however I'm having trouble figuring out how to save
>> the payment with the relevant contact associated, as the contact isnt
>> selected as part of the form (its in the URL instead).  I've included both
>> the payment view and the view for processing it, my current approach
>> results in a validation error. Anyone able to help?
>>
>> Thanks
>>
>> Keir
>>
>> class Payment(models.Model):
>> amount = models.DecimalField(max_digits=10, decimal_places=2)
>> date = models.DateField()
>> contact = models.ForeignKey(Contact)
>>
>> def payments_view(request, contact_id):
>> contact = get_object_or_404(Contact, pk=contact_id)
>> payments = Payment.objects.filter(contact=contact_id)
>> rctx = RequestContext(request,{
>> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
>> })
>> return render_to_response('CRMSite/contact_payments.html',rctx)
>>
>> def save_payment(request,contact_id):
>> PaymentForm(request.POST,contact=contact_id).save()
>> return payments_view(request, contact_id)
>>
>>  --
>> 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/-/g4cNoMI7bEoJ.
>> 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.
>>
>
>
>
>
>


-- 
*

 GlxGuru

*

-- 
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: send_mail on MAC OS X 10.7

2012-10-01 Thread Laxmikant Gurnalkar
Comment the csrf from settings. It doesnt work when you want.I use session
and own credentials to do that
And just write a simple view to send mail.
This will work without csrf or any of credentials & etc.

*Cheers*

Laxmikant

On Tue, Oct 2, 2012 at 6:15 AM, Cheng  wrote:

> Hi,
>
> I am new to django.
>
> I am following The Definitive Guide to Django SECOND EDITION by Adrian
> Holovaty and Jacob Kaplan -Moss and I cannot get the contact form to send
> mail. First the eg did not work at all until I added the @csrf-exempt
> decorator. Keeps getting Error 61 Connection Failure after that.
>
> Would be grateful if someone can help.
>
> Thanks,
> Cheng
>
> --
> 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/-/r40DN0e3ybAJ.
> 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.
>



-- 
*

 GlxGuru

*

-- 
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 - setting a model form foriegn key

2012-10-02 Thread Laxmikant Gurnalkar
Hi,
I think yes, Otherwise database will raise an integrity error, like
Foreign key violates the not null constraint.

*--Laxmikant* *G.*

On Tue, Oct 2, 2012 at 12:51 PM, Keir Lawson  wrote:

> Thanks for your reply :-)
>
> So there's no way to use a model form to proccess the quest and manually
> set just the FK of it?
>
> Keir
>
>
> On Tuesday, October 2, 2012 6:18:21 AM UTC+1, Laxmikant Gurnalkar wrote:
>
>> Sorry, see again!!
>>
>> def payments_view(request, contact_id):
>> payment = Payment()
>> contact =   contact.objects.filter(id=**contact_id)
>> if contact:
>> payment.contact  = contact[0]
>> payment.save()
>>
>>
>> I dont think you are looking for this kind of thing :
>> cheers
>>
>> On Tue, Oct 2, 2012 at 10:42 AM, Laxmikant Gurnalkar <
>> laxmikant...@gmail.com**> wrote:
>>
>>> def payments_view(request, contact_id):
>>> payment = Payment()
>>> payment.contact  = contact[0]
>>>
>>>> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
>>>> })
>>>> return render_to_response('CRMSite/**contact_payments.html',rctx)
>>>>
>>>rctx = RequestContext(request,{
>>> On Tue, Oct 2, 2012 at 4:20 AM, Keir Lawson  wrote:
>>>
>>>> Sorry if this is a dumb question, just picking up Django.
>>>>
>>>> I've set up a payments form, to create payments associated with a
>>>> contact (see payments model) however I'm having trouble figuring out how to
>>>> save the payment with the relevant contact associated, as the contact isnt
>>>> selected as part of the form (its in the URL instead).  I've included both
>>>> the payment view and the view for processing it, my current approach
>>>> results in a validation error. Anyone able to help?
>>>>
>>>> Thanks
>>>>
>>>> Keir
>>>>
>>>> class Payment(models.Model):
>>>> amount = models.DecimalField(max_**digits=10, decimal_places=2)
>>>> date = models.DateField()
>>>> contact = models.ForeignKey(Contact)
>>>>
>>>> def payments_view(request, contact_id):
>>>> contact = get_object_or_404(Contact, pk=contact_id)
>>>> payments = Payment.objects.filter(**contact=contact_id)
>>>> rctx = RequestContext(request,{
>>>> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
>>>> })
>>>> return render_to_response('CRMSite/**contact_payments.html',rctx)
>>>>
>>>> def save_payment(request,contact_**id):
>>>> PaymentForm(request.POST,**contact=contact_id).save()
>>>> return payments_view(request, contact_id)
>>>>
>>>>
>>>>  --
>>>> 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/-/**g4cNoMI7bEoJ<https://groups.google.com/d/msg/django-users/-/g4cNoMI7bEoJ>
>>>> .
>>>> To post to this group, send email to django...@googlegroups.com.
>>>> To unsubscribe from this group, send email to django-users...@**
>>>> googlegroups.com.
>>>>
>>>> For more options, visit this group at http://groups.google.com/**
>>>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>>> .
>>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/UPZcFyHmGtMJ.
>
> 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: send_mail on MAC OS X 10.7

2012-10-02 Thread Laxmikant Gurnalkar
Hi,
Thanks for the suggestion Russell,
I never felt insecure when I dont use csrf. Since I hv disabled.
anyways, Thanks again.

*Laxmikant*



On Wed, Oct 3, 2012 at 4:41 AM, Russell Keith-Magee  wrote:

> On Tue, Oct 2, 2012 at 1:36 PM, Laxmikant Gurnalkar
>  wrote:
> > Comment the csrf from settings.
>
> Please be *very* careful giving this advice. Advising someone to
> disable CSRF will almost universally be the wrong advice. By disabling
> CSRF, you're exposing your site to known and avoidable security
> problems.
>
> If you're getting CSRF errors, It's *much* better to try an understand
> what's going on and deal with the actual problem, rather than just
> making the problem "go away".
>
> Yours,
> Russ Magee %-)
>
> --
> 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: Autoescape of & char ignoring safe filter

2012-10-02 Thread Laxmikant Gurnalkar
Hi,
I have not used *sace*  ever. But use *escape* this works for me.
https://docs.djangoproject.com/en/1.0/ref/templates/builtins/#escape

Cheers
*Laxmikant G.*


On Wed, Oct 3, 2012 at 4:06 AM, Marc Serra  wrote:

> Hi, i'm trying to output raw html content form the database on the
> website, so i use the safe filter on the variable. All html code is
> displayed correctly except the ampersand that are escaped ignoring the safe
> filter, or It seems to me.
>
> I also tried to use a templatetag  with the mark_safe function with the
> same outcome.
>
> Here an example:
>
> Source in database:
>
>  value="http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1";> name="allowFullScreen" value="true"> value="always"> src="http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1"; 
> type="application/x-shockwave-flash" allowscriptaccess="always" 
> allowfullscreen="true" width="560" height="340">
>
> On template with |safe filter (notice "&" replacement with "&"):
>
>  value="http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1 
> "> name="allowFullScreen" value="true"> value="always"> src="http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1 
> " 
> type="application/x-shockwave-flash" allowscriptaccess="always" 
> allowfullscreen="true" height="340" width="560">
>
> You know what can be the reason to this behaviour and how to solve it?
>
> Thank you,
> Marc Serra
>
>
>  --
> 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/-/M3FV3yY7JnoJ.
> 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.
>



-- 
*

 GlxGuru

*

-- 
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: Autoescape of & char ignoring safe filter

2012-10-02 Thread Laxmikant Gurnalkar
>>>I have not used *safe*  ever. But use *escape* this works for me.

On Wed, Oct 3, 2012 at 9:54 AM, Laxmikant Gurnalkar <
laxmikant.gurnal...@gmail.com> wrote:

> Hi,
> I have not used *sace*  ever. But use *escape* this works for me.
> https://docs.djangoproject.com/en/1.0/ref/templates/builtins/#escape
>
> Cheers
> *Laxmikant G.*
>
>
>
> On Wed, Oct 3, 2012 at 4:06 AM, Marc Serra  wrote:
>
>> Hi, i'm trying to output raw html content form the database on the
>> website, so i use the safe filter on the variable. All html code is
>> displayed correctly except the ampersand that are escaped ignoring the safe
>> filter, or It seems to me.
>>
>> I also tried to use a templatetag  with the mark_safe function with the
>> same outcome.
>>
>> Here an example:
>>
>> Source in database:
>>
>> > value="http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1";>> name="allowFullScreen" value="true">> value="always">> src="http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1"; 
>> type="application/x-shockwave-flash" allowscriptaccess="always" 
>> allowfullscreen="true" width="560" height="340">
>>
>> On template with |safe filter (notice "&" replacement with "&"):
>>
>> > value="http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1 
>> <http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1>">> name="allowFullScreen" value="true">> value="always">> src="http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1 
>> <http://www.youtube.com/v/Uq8zzBW9hlc&hl=en&fs=1&hd=1>" 
>> type="application/x-shockwave-flash" allowscriptaccess="always" 
>> allowfullscreen="true" height="340" width="560">
>>
>> You know what can be the reason to this behaviour and how to solve it?
>>
>> Thank you,
>> Marc Serra
>>
>>
>>  --
>> 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/-/M3FV3yY7JnoJ.
>> 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.
>>
>
>
>
> --
> *
>
>  GlxGuru
>
> *
>



-- 
*

 GlxGuru

*

-- 
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: send_mail on MAC OS X 10.7

2012-10-02 Thread Laxmikant Gurnalkar
Okay, Thanks. Will hv to do that.

On Wed, Oct 3, 2012 at 9:54 AM, Russell Keith-Magee  wrote:

> On Wed, Oct 3, 2012 at 12:19 PM, Laxmikant Gurnalkar
>  wrote:
> > Hi,
> > Thanks for the suggestion Russell,
> > I never felt insecure when I dont use csrf. Since I hv disabled.
> > anyways, Thanks again.
>
> I don't want to appear rude, but I suspect the only reason you don't
> feel insecure is because you don't fully understand the risks.
>
> There's a reason Django has CSRF protection turned on by default. CSRF
> attacks are very real, very common, and very easy to manufacture. If
> you're not taking steps to prevent CSRF attacks, any website you
> produce is potentially at risk. I *strongly* urge you to do some
> research into CSRF attacks, and if you have problems with Django's
> CSRF framework, ask about and solve those problems -- don't just turn
> off CSRF protection and declare that your site works.
>
> Yours,
> Russ Magee %-)
>
> --
> 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.
>
>


-- 
*

 GlxGuru

*

-- 
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: Bug with collapse fieldsets?

2012-10-03 Thread Laxmikant Gurnalkar
What do you expect from None?


On Thu, Oct 4, 2012 at 4:02 AM, Janusz Jaworski  wrote:

> Hello. I found probably a little bug or it's just a feature (dunno). But
> my question is why i can't unhide collapsed fields when i use 'None' for
> name of group and use 'collapse' in dictionary in fieldsets. Here is the
> line of code and screens:
>
> fieldsets = [(None, {'fields': (('title', 'slug', 'category'),),
> 'classes':('collapse',),}), ...] and screens: first is when i use 'None' -
> http://i49.tinypic.com/b88pxg.png and second is when i use name "Example"
> for subgroup of fields - http://i50.tinypic.com/140lvg5.png . As you can
> see subgroup with 'None' and collapse turned on can't unhide cause there is
> just line with no button :( Sorry for my poor language.
>
> --
> 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/-/RhQm2vz79owJ.
> 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.
>



-- 
*

 GlxGuru

*

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



Disabling CSRF is not working.

2012-10-04 Thread Laxmikant Gurnalkar
Hi, Guys

Disabling CSRF is not working.
These are my midlewares., Removed {% csrf_token %} all templates.

MIDDLEWARE_CLASSES = (
'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.csrf.CsrfResponseMiddleware',
# 'igp_acfs.acfs.disablecsrf.DisableCSRF',
)


Also tried by writing disablecsrf.py like this :

class DisableCSRF(object):
def process_request(self, request):
"""
"""
setattr(request, '_dont_enforce_csrf_checks', True)


Thanks in Advance!!!

Laxmikant

-- 
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: Missing manage.py

2012-10-04 Thread Laxmikant Gurnalkar
you can update, instead of reinstalling.
cheers
Laxmikant

On Thu, Oct 4, 2012 at 6:29 PM, Ramiro Morales  wrote:

> I think so. The usual reason for the problem you are experiencing is a
> previous installation of Django on top of which the one you are trying
> to use was installed without unintalling the older one first *.
>
> So, the recommended action in such cases is to ensure you start with a
> clean slate buy removing any and all traces of the old files causing
> trouble.
>
> 2012/10/4, Django_Newbie :
> > Hi..
> > I am using Django 1.4.1 on Windows 7 and face similar problem. I dont see
> > manage.py
> >
> > All I have is:
> > __init__.py
> > settings.py
> > urls.py
> > wsgi.py
> >
> >
> > Is reinstalling Django only option?
> >
> >
> > On Monday, 16 April 2012 16:56:32 UTC+5:30, Faeez wrote:
> >>
> >> Hi,
> >>
> >> I have a problem whenever I create a new project using the start project
> >> command, no manage.py file is created.
> >>
> >> I'm using Mac OS X. Thank you in advance
> >>
> >
> > --
> > 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/-/_GE2ct9_qi0J.
> > 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.
> >
> >
>
> --
> Enviado desde mi dispositivo móvil
>
> Ramiro Morales
>
> --
> 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: Print html the normal way

2012-10-05 Thread Laxmikant Gurnalkar
Use
 {{yourvar|html|striptags}}

https://docs.djangoproject.com/en/dev/ref/templates/builtins/#striptags

Cheers
*Laxmikant Gurnalkar*
On Fri, Oct 5, 2012 at 2:32 PM, Ashish Jain wrote:

> Hi,
>
> Thanks a ton!!
>
> using mark_safe() worked perfectly.
>
> - Regards
> Ashish
>
> On Friday, 5 October 2012 14:10:31 UTC+5:30, Tom Evans wrote:
>
>> On Fri, Oct 5, 2012 at 9:20 AM, Ashish Jain 
>> wrote:
>> > Hi,
>> >
>> > I wrote a simple filter as:
>> >
>> > @register.filter()
>> > def html(value):
>> > return 'Check'
>> >
>> > when I use this filter in my template, it displays html as:
>> >
>> > Check
>> >
>> > I want to display as:
>> >
>> > Check
>> >
>> > am I missing something.
>> >
>>
>> You haven't marked the output as safe, so Django escapes it:
>>
>> https://docs.djangoproject.**com/en/1.4/howto/custom-**
>> template-tags/#filters-and-**auto-escaping<https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/#filters-and-auto-escaping>
>>
>> You want option 2.
>>
>> Cheers
>>
>> Tom
>>
>  --
> 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/-/Sz5auuOkyYcJ.
>
> 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.
>



-- 
*

 GlxGuru

*

-- 
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: Disabling CSRF is not working.

2012-10-07 Thread Laxmikant Gurnalkar
Thanks, for the response.
I had a problem like this
   I was trying to create a  storesite which can be worked without django
framework but using django. i.e just static template index.html &
a java-script file. With all the stuff dynamically generated & only urls by
the django, so that anybody can use my index.html, just calls my server for
the url to display dynamic content using users information.
so for this purpose I had a cookies resided in my browser and I was trying
to create database objecst using javascript with api urls.

When I studied CSRF in detail, I understood that, *private dynamic
 javascript cookies *cannot be directly used to  retrieve or access the
database related to your site. Hence, my javascript was considered by
django as a *malicious/attack *content and thrown a 403 forbidden error. So
I was trying to remove the CSRF from my project. But* Failed. Due to the
same reason as you guys have told me.*
*So on understanding CSRF  just removed code of cookies & just added
parameters to url just before when user refreshes the page. And whole thing
worked.  That was the Great  experience.*
*
*
*anyways,*
*Plz tell me if I can hv any other method to do this. adding parameters to
url is definitely not secure always.*
*
*
*One more thing I am using csrf_exempt to handle api views.*
*
*
*Thanks a lot again.*
*
*
On Sat, Oct 6, 2012 at 4:38 AM, Bill Freeman  wrote:

> Right you are.
>
> On Fri, Oct 5, 2012 at 6:20 PM, Ian Clelland  wrote:
> >
> >
> > On Friday, October 5, 2012, Bill Freeman wrote:
> >>
> >> I believe that I read somewhere that newer Djangos force the CSRF
> >> middleware even if it's not listed in MIDDLEWARE_CLASSES.
> >
> >
> > You might be thinking of the CSRF context processor, which is always
> > enabled, no matter what is in settings. Even the most recent docs don't
> say
> > anything about forcing the middleware.
> >>
> >>
> >> You could dive into the middleware code to see how this happens, and
> >> come up with a stable strategy to circumvent it.  Or you could just
> >> fix the necessary views and templates.  There is, after all, a chance
> >> that you will want to be able to upgrade this site without jumping
> >> through hoops.
> >>
> >> On Thu, Oct 4, 2012 at 4:56 AM, Laxmikant Gurnalkar
> >>  wrote:
> >> > Hi, Guys
> >> >
> >> > Disabling CSRF is not working.
> >> > These are my midlewares., Removed {% csrf_token %} all templates.
> >> >
> >> > MIDDLEWARE_CLASSES = (
> >> > '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.csrf.CsrfResponseMiddleware',
> >> > # 'igp_acfs.acfs.disablecsrf.DisableCSRF',
> >> > )
> >> >
> >> >
> >> > Also tried by writing disablecsrf.py like this :
> >> >
> >> > class DisableCSRF(object):
> >> > def process_request(self, request):
> >> > """
> >> > """
> >> > setattr(request, '_dont_enforce_csrf_checks', True)
> >> >
> >> >
> >> > Thanks in Advance!!!
> >> >
> >> > Laxmikant
> >> >
> >> > --
> >> > 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.
> >>
> >
> >
> > --
> > Regards,
> > Ian Clelland
>

Re: Translation outside the broswer

2012-10-07 Thread Laxmikant Gurnalkar
Yeah, i18n works anywhere just put _(message) to send a mail.
*
*
*cheers *


On Fri, Oct 5, 2012 at 10:16 PM, Bastian  wrote:

> Thanks Tom, the logic seems pretty clear. I just didn't know about
> translation.activate. What does it do exactly? Change the current language?
> Anyway I will do my homework and google it and read the code...
>
> Cheers.
>
>
> On Friday, October 5, 2012 12:19:38 PM UTC+2, Tom Evans wrote:
>
>> On Fri, Oct 5, 2012 at 10:12 AM, Bastian  wrote:
>> > Hi,
>> >
>> > I understand quite well how translations and i18n work inside a browser
>> for
>> > Django but I'm not sure about the correct way to do it outside a
>> browser. I
>> > mean when sending a mail or a tweet. What should I use to get the
>> language
>> > of the user that is going to receive the mail or in case of a tweet the
>> > language of the user that I will send it on behalf of. And then how do
>> I ask
>> > Django to translate that?
>> > I could not find it in the docs, if it exists please point me to it.
>> >
>> > Cheers
>> >
>>
>> You will need to have a mechanism for storing what the user's chosen
>> language is. Once you have that, simply do this:
>>
>> from django.utils import translation
>>
>> cur_language = translation.get_language()
>> translation.activate(get_lang_**for_user(user))
>> # send email, tweet, etc
>> translation.activate(cur_**language)
>>
>> You would need to define the 'get_lang_for_user' function.
>>
>> Cheers
>>
>> Tom
>>
>  --
> 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/-/UWQFiq5SddQJ.
>
> 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.
>



-- 
*

 GlxGuru

*

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



Javascript encoding and python decoding and vice versa

2012-10-08 Thread Laxmikant Gurnalkar
Hi, Guys.

Anybody knows to encrypt the content in javascript and decode it using
python and vice versa.
I am doing a high security data transfer. The things are showstopper to
transferring data through javascript to the python. Is it possible to hide
data or send data over web in that should not be  human readable.

Thanks

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



Re: Disabling CSRF is not working.

2012-10-09 Thread Laxmikant Gurnalkar
Yeah, Thanks a lot. now I preferred to work with CSRF.

On Wed, Oct 10, 2012 at 2:24 AM, Bill Freeman  wrote:

> If you can't disable the middleware, you could consider marking the
> view with the csrf_exempt decorator from django.views.decorators.csrf
> (see https://docs/djangoproject.com/en/1.4/contrib/csrf/#utilities
>
> Bill
>
> On Sun, Oct 7, 2012 at 3:41 AM, Laxmikant Gurnalkar
>  wrote:
> > Thanks, for the response.
> > I had a problem like this
> >I was trying to create a  storesite which can be worked without django
> > framework but using django. i.e just static template index.html & a
> > java-script file. With all the stuff dynamically generated & only urls by
> > the django, so that anybody can use my index.html, just calls my server
> for
> > the url to display dynamic content using users information.
> > so for this purpose I had a cookies resided in my browser and I was
> trying
> > to create database objecst using javascript with api urls.
> >
> > When I studied CSRF in detail, I understood that, private dynamic
> > javascript cookies cannot be directly used to  retrieve or access the
> > database related to your site. Hence, my javascript was considered by
> django
> > as a malicious/attack content and thrown a 403 forbidden error. So I was
> > trying to remove the CSRF from my project. But Failed. Due to the same
> > reason as you guys have told me.
> > So on understanding CSRF  just removed code of cookies & just added
> > parameters to url just before when user refreshes the page. And whole
> thing
> > worked.  That was the Great  experience.
> >
> > anyways,
> > Plz tell me if I can hv any other method to do this. adding parameters to
> > url is definitely not secure always.
> >
> > One more thing I am using csrf_exempt to handle api views.
> >
> > Thanks a lot again.
> >
> > On Sat, Oct 6, 2012 at 4:38 AM, Bill Freeman  wrote:
> >>
> >> Right you are.
> >>
> >> On Fri, Oct 5, 2012 at 6:20 PM, Ian Clelland 
> wrote:
> >> >
> >> >
> >> > On Friday, October 5, 2012, Bill Freeman wrote:
> >> >>
> >> >> I believe that I read somewhere that newer Djangos force the CSRF
> >> >> middleware even if it's not listed in MIDDLEWARE_CLASSES.
> >> >
> >> >
> >> > You might be thinking of the CSRF context processor, which is always
> >> > enabled, no matter what is in settings. Even the most recent docs
> don't
> >> > say
> >> > anything about forcing the middleware.
> >> >>
> >> >>
> >> >> You could dive into the middleware code to see how this happens, and
> >> >> come up with a stable strategy to circumvent it.  Or you could just
> >> >> fix the necessary views and templates.  There is, after all, a chance
> >> >> that you will want to be able to upgrade this site without jumping
> >> >> through hoops.
> >> >>
> >> >> On Thu, Oct 4, 2012 at 4:56 AM, Laxmikant Gurnalkar
> >> >>  wrote:
> >> >> > Hi, Guys
> >> >> >
> >> >> > Disabling CSRF is not working.
> >> >> > These are my midlewares., Removed {% csrf_token %} all templates.
> >> >> >
> >> >> > MIDDLEWARE_CLASSES = (
> >> >> > '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.csrf.CsrfResponseMiddleware',
> >> >> > # 'igp_acfs.acfs.disablecsrf.DisableCSRF',
> >> >> > )
> >> >> >
> >> >> >
> >> >> > Also tried by writing disablecsrf.py like this :
> >> >> >
> >> >> > class DisableCSRF(object):
> >> >> > def process_request(self, request):
> >> >> > """
> >> >> > """
> >> >> > setattr(request, '_dont_enforce_csrf_checks', True)
> >> >> >
> >> >> >
> >> >> > Thanks i

Re: Translation outside the broswer

2012-10-10 Thread Laxmikant Gurnalkar
You can pass the latest language_code  in the url and set that to the
session
>>>Is there a way to retrieve the latest language used in the user session?

cheers
*Laxmikant*

On Wed, Oct 10, 2012 at 9:14 PM, Bastian  wrote:

> Ok this is all very clear now, and the docs are quite helpful too (
> https://docs.djangoproject.com/en/dev/topics/i18n/translation/#using-translations-outside-views-and-templates
> ).
> But now I wonder what is the best way to implement that?
> I mean in my case I use Django to automatically discover the user's
> preferred language according to the browser preferences and if it fails
> there is also a button to choose the language. I can link that button to a
> field in the user profile model to remember what language they set for
> later use with translation.activate. But in case Django displays the right
> language for the user automatically that field will remain empty and that
> would be pretty counter intuitive for the user to set their preferred
> language with a button when it is already displayed correctly. What would
> be the right thing to do in that case? Is there a way to retrieve the
> latest language used in the user session? Or something similar? Thanks!
>
>
>
> On Friday, October 5, 2012 12:19:38 PM UTC+2, Tom Evans wrote:
>
>> On Fri, Oct 5, 2012 at 10:12 AM, Bastian  wrote:
>> > Hi,
>> >
>> > I understand quite well how translations and i18n work inside a browser
>> for
>> > Django but I'm not sure about the correct way to do it outside a
>> browser. I
>> > mean when sending a mail or a tweet. What should I use to get the
>> language
>> > of the user that is going to receive the mail or in case of a tweet the
>> > language of the user that I will send it on behalf of. And then how do
>> I ask
>> > Django to translate that?
>> > I could not find it in the docs, if it exists please point me to it.
>> >
>> > Cheers
>> >
>>
>> You will need to have a mechanism for storing what the user's chosen
>> language is. Once you have that, simply do this:
>>
>> from django.utils import translation
>>
>> cur_language = translation.get_language()
>> translation.activate(get_lang_**for_user(user))
>> # send email, tweet, etc
>> translation.activate(cur_**language)
>>
>> You would need to define the 'get_lang_for_user' function.
>>
>> Cheers
>>
>> Tom
>>
>  --
> 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/-/0MvHhF60bBIJ.
>
> 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.
>



-- 
*

 GlxGuru

*

-- 
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: haystack problem - already registered error

2012-11-02 Thread Laxmikant Gurnalkar

Hey Any Solution on this ?  
On Wednesday, September 15, 2010 4:53:26 AM UTC+5:30, Kenneth Gonsalves 
wrote:
>
> hi,
>
> I have installed haystack with xapian backend. My relevant code is like
> this:
>
> import haystack
> haystack.autodiscover()
>
> from haystack.indexes import *
> from haystack import site
> from web.models import Stock
>
> class StockIndex(RealTimeSearchIndex):
> text = CharField(document=True, use_template=True)
>
> stockist = CharField(model_attr='stockist')
> location = CharField(model_attr='location')
>
> def get_queryset(self):
> return Stock.objects.all()
>
> site.register(Stock, StockIndex)
>
> but on runserver (python2.6, django-trunk, fedora12):
>
> [lawgon@xlquest clearplus]$ python manage.py
> runserver  
> Traceback (most recent call
> last): 
>  
>   File "manage.py", line 11, in
>
>  
>
> execute_manager(settings) 
>   
>   File
> "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
> line 438, in execute_manager  
>
> utility.execute() 
>   
>   File
> "/usr/lib/python2.6/site-packages/django/core/management/__init__.py",
> line 379, in execute  
>
> self.fetch_command(subcommand).run_from_argv(self.argv)   
>   
>   File
> "/usr/lib/python2.6/site-packages/django/core/management/base.py", line
> 191, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File
> "/usr/lib/python2.6/site-packages/django/core/management/base.py", line
> 209, in execute
> translation.activate('en-us')
>   File
> "/usr/lib/python2.6/site-packages/django/utils/translation/__init__.py",
> line 66, in activate
> return real_activate(language)
>   File "/usr/lib/python2.6/site-packages/django/utils/functional.py",
> line 55, in _curried
> return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
>   File
> "/usr/lib/python2.6/site-packages/django/utils/translation/__init__.py",
> line 36, in delayed_loader
> return getattr(trans, real_name)(*args, **kwargs)
>   File
> "/usr/lib/python2.6/site-packages/django/utils/translation/trans_real.py", 
> line 193, in activate
> _active[currentThread()] = translation(language)
>   File
> "/usr/lib/python2.6/site-packages/django/utils/translation/trans_real.py", 
> line 176, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
>   File
> "/usr/lib/python2.6/site-packages/django/utils/translation/trans_real.py", 
> line 159, in _fetch
> app = import_module(appname)
>   File "/usr/lib/python2.6/site-packages/django/utils/importlib.py",
> line 35, in import_module
> __import__(name)
>   File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line
> 124, in 
> handle_registrations()
>   File "/usr/lib/python2.6/site-packages/haystack/__init__.py", line
> 121, in handle_registrations
> search_sites_conf = __import__(settings.HAYSTACK_SITECONF)
>   File "/home/lawgon/clearplus/web/search_indexes.py", line 17, in
> 
> site.register(Stock, StockIndex)
>   File "/usr/lib/python2.6/site-packages/haystack/sites.py", line 45, in
> register
> raise AlreadyRegistered('The model %s is already registered' %
> model.__class__)
> haystack.exceptions.AlreadyRegistered: The model  'django.db.models.base.ModelBase'> is already registered
>
> -- 
> regards
> Kenneth Gonsalves
>
>

-- 
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/-/8jr3Jed1cVEJ.
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.