How do I create timestamp type columns in (mySQL) database?

2012-12-26 Thread Subodh Nijsure
I am working with situation where I would like to maintain timestamp (in
UTC) of when a record is created or updated.

mySQL offers such facility if one declares column of type 'timestamp' with
attributes - default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'

However I haven't found way to declare a column time as timestamp in django
(1.4).

I have come across postings - http://ianrolfe.livejournal.com/36017.html

that tries to define field as timestamp, but it doesn't seem to work.

Is there way to declare column of type  'timestamp' in django and not
datetime and assign some properties to the column.

 As a hack I can always execute alter table command, but I am not sure what
effect that will have if I want to use admin interface to edit those tables.

Would appreciate any help/pointer on how one can go about handling UTC
timestamp columns in database.

Thanks.

-Subodh

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



Replicating same model for different deployed application.

2012-12-29 Thread Subodh Nijsure
Hi,

I have following situation where. My model consist of say table1, table2,
table3.

I am going to "host" similar data and associated web interface for multiple
customers -( customer1, customer2, customer3.) they would access these
application as http://hostname/customer1 http://hostname/customer2 etc.

When customer1 application is deployed I want tables customer1_table1,
customer1_table2, customer1_table3 to be created. Same for customer2, 3 etc.

Right now I am thinking of having one "template" directory where all
database names are referred to as replaceme_table1, replaceme_table2 etc.

When I actually deploy application for real customer say customer1 I am
copying this template to directory customer1 and running sed to  change
'replaceme' with 'customer1'

Is there a better, elegant way to do this in django where you have same
 model that needs to be deployed as multiple django applications?

-Subodh

-- 
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: Replicating same model for different deployed application.

2012-12-30 Thread Subodh Nijsure
Exactly I was missing the django/web app terminology of multi-tenant app.

I tried using https://github.com/phugoid/django-simple-multitenant and it
seems to have issues. I will see if I can fix them with my limited
knowledge of django.

Are there any good multi-tenants frameworks for django out there, any
recommendations?

Regards,
-Subodh

On Sun, Dec 30, 2012 at 8:57 AM, Amirouche wrote:

> Héllo Subodh
>
>
> On Sunday, December 30, 2012 3:57:36 AM UTC+1, Subodh Nijsure wrote:
>>
>> Hi,
>>
>> I have following situation where. My model consist of say table1, table2,
>> table3.
>>
>> I am going to "host" similar data and associated web interface for
>> multiple customers -( customer1, customer2, customer3.) they would access
>> these application as http://hostname/customer1 http://hostname/customer2etc.
>>
>> When customer1 application is deployed I want tables customer1_table1,
>> customer1_table2, customer1_table3 to be created. Same for customer2, 3 etc.
>>
>> Right now I am thinking of having one "template" directory where all
>> database names are referred to as replaceme_table1, replaceme_table2 etc.
>>
>> When I actually deploy application for real customer say customer1 I am
>> copying this template to directory customer1 and running sed to  change
>> 'replaceme' with 'customer1'
>>
>> Is there a better, elegant way to do this in django where you have same
>>  model that needs to be deployed as multiple django applications?
>>
>
> If I understand this is a multitenant application or multitenancy for
> short, one django instance for several customer. They are several
> application that are labeled like that, I can't recommend any in particular
> since I don't use it them.
>
> Regards,
>
> Amirouche
>
> --
> 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/-/_np6wETOfSwJ.
>
> 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.



DateTime field when using django-crispy-form

2013-01-03 Thread Subodh Nijsure
Hello,

Sorry if this should go to some crispy-form specific mailing list. If there
is such thing kindly redirect me towards it.

I am using django-crispy-form to render my forms one thing which I haven't
been able to do is display columns that are of data-time format with some
kind of calender picker.

I have tried the examples out there that use bootstrap-datepicker

(which is only date picker but not time picker). Is there an example out
there how one can display colum that is of type DateTimeField?


-Subodh

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



Re: how to create a databse

2013-01-05 Thread Subodh Nijsure
On Ubuntu following works -

Run:
sudo dpkg-reconfigure mysql-server-5.1

Now this will allow you set password for 'root' user.

Les assume you want to create user joe and create database joedb , want to
assign password 'joepassword'

Now login to the mysql as:


 mysql -u root -p'root-password'

 select PASSWORD('joepassword');
 -- Note down string that is displayed here.
drop user joe@localhost;
grant all privileges on *.* to joe@localhost with grant option;
create user 'joe'@'localhost' IDENTIFIED BY PASSWORD  '...';
 -- Enter password you got by running select password('joedb')
command where ... is

create database joedb character set utf8;

Now you can login as:

   mysql -u joe -p'joepassword' -D joedb

Now you can use joe, joedb, joepassword in your settings file to use mysql
as backend.

-Subodh



On Sat, Jan 5, 2013 at 7:41 AM, ANKIT BAGARIA wrote:

> I have installed mysql as databse and i am not able to create a database.
> I know the command for it but dont know where to type it. Django tutorials
> tell to run the command in database interactive. But I am not able to
> figure out how to to so. Please help me in creating a database.
> Thankyou.
>
> --
> 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/-/rXKRbmFTED0J.
> 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.



Source code from book djangobook.com ?

2013-01-15 Thread Subodh Nijsure
Sorry if this is a very obvious question does any body know if source code
from the online book http://www.djangobook.com/ is available some where in
git repo? I have searched on github and most hits are for actual book
chapters.

-Subodh

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



How do I prevent delete from table that has foreign key references

2013-01-20 Thread Subodh Nijsure
Hi,

Say I have model that comprises of Books and Authors. Where a book may have
multiple authors and this has foreignkey in the books table.

Now how do I prevent deletion of an author record while the there is record
in books table that has pointer an author record (via foreign key).

Do i need to do this via stored procedure/trigger on DB level or is there
standard procedure to implement this in delete in django?

Would appreciate any pointers.

Regards,
-Subodh

-- 
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: Multi Client Django System

2013-02-25 Thread Subodh Nijsure
Could - Django multitenant cold possibly help you?

https://pypi.python.org/pypi/django-simple-multitenant


-Subodh

On Fri, Feb 22, 2013 at 7:43 PM, Delcio Torres  wrote:
> Dear Sirs,
>
> Maybe this is a concept question, but here we go.
>
> I'm doing test development to learn django and using admin for everything.
>
> This is a Company/Employee/HeathInsurance CRUD system.
>
> The main ideia is that I want to provide this for different companies and
> still not allow them to see each others registers.
>
> A Django Admin user , should belong to Company or be associated with it
> somehow and only see the registers created by other members of the same
> company.
>
> My question is Django Admin Groups from Auth Model would do the task or not.
>
> I've thought about overriding save_mode and get the group to which the user
> belongs , then save it into some group field at HeathInsurance and Employee.
>
> Then on admin.py thought about overriding the queryset and use a filter so
> you would only see registers from your company.
>
> Is this feasible ? Is this the way?
>
> Thanks everyone!
>
> Best Regards,
>
> Delcio
>
> Here some model example
> ## models.py ##
> class Company(models.Model):
> name = models.CharField(max_length=200, null=False)
>
>
> class HeathInsurance(models.Model):
> nome = models.CharField(max_length=200, null=False)
>
>
> class Employee(models.Model):
> name = models.CharField(max_length=200, null=False)
> company = models.ForeignKey(Company)
> health_insurance = models.ForeignKey(HeathInsurance)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




django DB optimization

2013-03-04 Thread Subodh Nijsure
Hi,

I have implemented a django application that willl maintain schedule
for 100s of people that work for a company. People access this
schedule using desktop or mobile device to lookup their task list for
current day, this week etc.

Now the question is how do I scale this -- example when user joe looks
up his schedule for today essentially I end up doing a query get
records for today, where user name is joe. Same thing would happen
when Mary looks up her schedule, we do DB lookup for records for Mary.

I am worried that when 10,000 people start to query this my database
is going to become a bottleneck (?) Should I be implementing some of
home grown daemon that caches the data associated with most common
queries and serve the data out of that daemon.

I am sure I am not the first one to encounter this issue, how do
people scale their query response time when using django as their
framework.

(Hope this Q made sense...)

-Subodh

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




A generic 'search' framework for forms?

2013-03-05 Thread Subodh Nijsure
I have lot of forms in my django application and would like to present
a generic way for end user to do search query, is there a package out
there that allows one to construct such a thing?

Example I have a form that shows customers it has fields like
customer_name, customer_address , I have another form that shows
technicians information such as first_name, last_name, location.

I would like to add a "widget" at top of the customer form so that end
user can say, I want to search by name, type search string and all
entries that match that search string will show up. Same for
technician form I want them to be able to pick they want to search by
first_name or last_name and type the search string to narrow the
listing.

Thanks
-Subodh

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




Multi-tenant database model with new user model?

2013-04-30 Thread Subodh Nijsure
Hi,

We have old model for one of my django application that requires
multi-tenant deployment. The database model I came up with is kind of
_ugly_ to support the multi-tenancy.

Are there any good examples of how one can write multi-tenant django
application using the new AbstractUser classes?

-Subodh

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




Registration module in 1.5.1 use of django.views.generic.simple

2013-05-02 Thread Subodh Nijsure
I am not certain how one goes about submitting changes to django. But
if I setup my virtualenv with 1.5.1 and import the registration
backend I end up getting error on importing direct_to_template. Which
can be fixed with following code change.

First, is this correct code change? Should this change be pushed to
django 1.5.X?




 diff 
/home/snijsure/.virtualenvs/django15-broken/local/lib/python2.7/site-packages/registration/backends/default/urls.py
/home/snijsure/.virtualenvs/django15-fixed/local/lib/python2.7/site-packages/registration/backends/default/urls.py
22c22,24
< from django.views.generic.simple import direct_to_template
---
> from django.conf.urls import patterns
> from django.views.generic import TemplateView
>
30,31c32

> TemplateView.as_view(template_name='registration/activation_complete.html'),
46,47c47

> TemplateView.as_view(template_name='registration/registration_complete.html'),
49,51c49
url(r'^register/closed/$', 
> TemplateView.as_view(template_name='registration/registration_closed.html'),

-Subodh

-- 
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: Registration module in 1.5.1 use of django.views.generic.simple

2013-05-02 Thread Subodh Nijsure
So adding something like this to my requirements.txt should work?

-e 
hg+https://bitbucket.org/ubernostrum/django-registration#egg=django-registration

( Sorry if this very trivial, never have imported something from hg)

-Subodh

On Thu, May 2, 2013 at 12:12 PM, James Bennett  wrote:
> Check out the latest hg tip of django-registration, which does not have this
> problem.
>
> --
> 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.




Benchmarking django application using ab (apache benchmark)

2013-05-07 Thread Subodh Nijsure
Hi,

I have deployed a web site that using nginx for serving static content
and apache2 (mod_wsgi) to handle the django requests. I have optimized
obvious things  that chrome browser show things like compression,
expiration, js minification etc.

Now I am looking at doing some bench marking of this setup.

Basically I have extracted the sessionid and csrftoken after I login
to my web site and then run

ab -n 1 -c 1 -C
"csrftoken=4BAfoZRrvvATWISgLcCIOOA963YpmNk0;sessionid=bxw1yy9jpmx1ox9y1nxfl8t8aptkkd0r"
http://mywebsite.com/customer/list

Is that how most people do the performance bench mark of the web site
or is there better way to keep tab on web site performance.

Is there another, better way to do stress testing and keeping tab of
django based web site?

-Subodh

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




Handling delete and ability to support undo

2013-05-13 Thread Subodh Nijsure
Hi,

I have requirement where users should be able to 'delete' the data
from database.

But at the same time we want to provide undo features. So what that
essentially means is keeping column 'is_deleted'  for every table and
when uses delete the data set value to 1.

And when users want to retrive some old records that were deleted show
them all the data regardless of value of is_deleted column.

Is there better way to provide this functionality when using django as your CMS?

-Subodh

-- 
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: Creating a "Django Course" and would like some feedback

2013-05-28 Thread Subodh Nijsure
This is all IMHO.

One of the thing that has been missing from many django books:

How do you "marry" the current best practices for --deploying-- large
scale web applications when using django.

What are the best practices for enabling, monitoring caching?
Implementing search using haystack or some other extensions?
Would be interesting to find out, learn from best practices regarding
how large  software development teams work on django projects.

-Subodh

On Tue, May 28, 2013 at 11:34 AM, Kevin  wrote:
> Sean,
>
>   Thank you for your input.  Having those types of examples would actually
> be a great idea for the course, as these are some of the most popular
> website being developed in our social web 2.0 these days.
>
>   As for your thought on inputting financial data, I actually built a
> personal financial manager in Django, and Django has the form facilities to
> validate complex financial forms and tell the user to correct any issues
> with their input.  This would actually be a great idea for an example as
> well, since Django manages form validation very well.  I have this personal
> application up on my BitBucket page if you wanted to take a look at it,
> here's a link to the actual app:
>
> https://bitbucket.org/kveroneau/django-pim/src/fffb63b6d03050b30d134bbe39d862e5004a90da/pcbank?at=default
>
>   Keep in mind that this app is some of my much earlier work, stuff I built
> when I was first learning the framework.  This was first built on Django 1.2
> I believe, so it still does use function-based generic views.  I do have it
> running currently on a website, and use it all the time to manage my
> personal financial data, such as bills and debt.
>
>
> Best Regards,
>   Kevin Veroneau
>   PythonDiary.com
>
>
> On Tuesday, 28 May 2013 12:29:20 UTC-5, SeanJ wrote:
>>
>> Kevin,
>>
>> Looking forward to what you come up with.  I'd be willing to be a guinea
>> pig for the course.
>>
>> First, I am a hobbyist developer (Java, Groovy/Grails, JS/Jquery/HTML5,
>> PL/SQL, Python/Django), not a pro, and relatively new at it.  My day job is
>> a Software QA Manager for 40,000+ employee ERP Web App.
>> Just for the fun of it I've been exploring Django.  I've been through all
>> the usual places on the web (djangoproject, djangobook, and others, and all
>> the youtube tutorials) and I'm currently redeveloping 2 apps in django that
>> I originally wrote in other languages/frameworks -- just as an exercise to
>> see how django handles them.
>>
>> Second, My 2 cents on your outline and my request for content:  I know
>> with its newsy roots django excels in the blog/wiki/social posting space so
>> there is a bit of glut in the django tutorial world for these types of
>> examples, but I'm coming from a business web perspective and I don't find
>> much out there on incorporating user number input (financial or other
>> quantity) type data from forms which is then processed through some business
>> logic in the view and redisplayed for validation by the user before being
>> comitted to the database for storage.
>>
>> Apart from those 2 cents, your outline looks good.  And I think JQuery is
>> almost as much a part of the finished product as HTML these days.  I think
>> many will benefit from learning how to incorporate that library.
>>
>> Regards,
>>
>> Sean
>>
>> On Monday, May 27, 2013 3:02:58 PM UTC-7, Kevin wrote:
>>>
>>> Hello everyone!
>>>
>>>   It's been quite sometime since I have been on here, well I came back
>>> with some great news!  I am currently in the process of building an online
>>> Django web course aimed at both new and old Django developers.  I will be
>>> charging a minimal fee for access to the entire course, but the first 3
>>> chapters of the main sections will be free for everyone to read and enjoy.
>>> The course software itself is built using Django naturally.
>>>
>>>   The course software has been completed and uploaded online.  I am now
>>> in the lengthily process of writing up all the chapters, quizzes, example
>>> code, and full projects.  This is going to be a large amount of work,
>>> however at the current moment this is my only job and that is why I am
>>> planning on charging for admittance.  I am aiming to have a large amount of
>>> it completed by around the middle of June and ready for public consumption
>>> shortly after.
>>>
>>>   I have decided to give a lucky few free access to the entire course for
>>> the purpose of reviewing and providing me with feedback.  If you are
>>> interested, please reply back to me and explain why I should select you.  I
>>> will then select 5 lucky individuals and email them their access credentials
>>> and a link to the actual course's website when it's ready.
>>>
>>>   Here's a little background information about myself, since I haven't
>>> been on here recently.  I am the current maintainer and author of
>>> PythonDiary.com, which has been a relatively successful Python blog since
>>> January of 2012.  Over 500 users visit the blog each 

Django crispy form layout question

2013-06-12 Thread Subodh Nijsure
I am using django-crispy form to layout  some of the form fields as
shown below so that the first_name, last_name appear in one row, same
with primary_number, email etc.
Also I have set the label to blank and using place holder to display
hints to user.


Div(
Div('first_name',css_class='span2'),
Div('last_name',css_class='span2 offset4'),
css_class='row-fluid'),
Div(
Div('primary_number',css_class='span2 '),
Div('email',css_class='span2 offset4'),
css_class='row-fluid'),

self.fields['first_name'].label = ""
self.fields['first_name'].widget.attrs['placeholder'] = u'First Name'
self.fields['last_name'].label = ""
self.fields['last_name'].required = True
self.fields['last_name'].widget.attrs['placeholder'] = u'Last Name'

And the form looks like shown here -

https://github.com/snijsure/calparks-django/blob/master/screen-shots/crispy-form-layout.png

However I would like to show similar form during "edit" view such that
 label for the field appears on the top

First NameLast Name
 

Is there way to do that? I can also go with that scheme while adding
new entry as well.
I guess I need to find a way to arrange label vertically when using crispy-form

If this can't be done in crispy-form are there other layout packages
that would allow me to do that?


-Subodh

-- 
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-Ajax Issue

2013-07-15 Thread Subodh Nijsure
I am not sure what you mean by taking you to post view of the function.

That aside, you need to include  csrfmiddlewaretoken: '{{ csrf_token
}}' in your data: section.

   data: {
 'keyword': search_for,
 'filter': rval,
csrfmiddlewaretoken: '{{ csrf_token }}'
},

-Subodh

On Sun, Jul 14, 2013 at 8:19 AM, vijay shanker  wrote:
> Hey all
> I am trying to make a simple ajax call to show items retrieved from
> database.
> I am displaying bunch of fields like a text input for keyword and radio
> button for filter in a form like this:
>
> {% csrf_token %}
> 
>  Search 
> 
> 
> 
>  checked='checked'/>All
>  value="paying"/>Paying
>  value="uploaded"/>Uploaded
>  />Staff Pick
>  
> 
>
> This form is displayed by a function which inherits generic View class, from
> its get method.
>
> class Home(View):
> def get(self,request, *args, **kwargs):
> return render_to_response('items/search_page.html', context_instance
> = RequestContext(request) )
> def post(self, request, *args, **kwargs):
> print 'in home post'
>
> What puzzles me is that when i am trying to submit the form data via ajax
> call (on same page) with jquery when someone clicks on search button, it
> takes me to post view of Home and not on to other function i have defined.
> The javascript on the html page is:
> 
>function search(e) {
> e.preventDefault();
> search_for = $("#search").val()
> rval = $('input:radio[name=fancy_radio]:checked').val()
> $.ajax({
> url:"/search/",
> method : "POST",
> data : { 'keyword': search_for, 'filter': rval },
> success:function(result){
> alert(result)
> }
> });
>}
> 
>
> why is this happening ?
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Recommendation/alternative for multi-tenancy under django

2014-07-18 Thread Subodh Nijsure
This is the first time I am trying to implement multi-tenant setup
under django and hence the question.

Problem/Setup
- There are two companies signed up for service from portal I am
developing say  CompanyA, CompanyB.

- Each user with this setup is identified by unique email address,
users login using their email address and password.

- CompanyA has following users
A-tech1
A-tech2
A-tech3

- CompanyB has following users
B-tech1
B-tech2
B-tech3

Requirements:

1. Data security/isolation:Technician A-tech1, A-tech2, A-tech3
should only be able to view data associated with companyA. Same for
B-tech* technicians should only be able to see data from companyB.

2. Scalability: CompanyA, CompanyB might be of different sizes -
companyA might have 10 users. While CompanyB might have 1s users
representing large customers.
3. SLA: There might be different service level agreement with companyA
 & companyB.


I think, it doesn't make sense to lump data related to companyA, companyB
into same database.

Proposed Architecture Possibilities:

Path 1:
-  system will use one replicated database for authentication/authorization
- When a company is registered within the system, 'Administrator' will
assign a company to specific database connection. And request will be
routed  to correct database using database router, based on currently
logged in user.

See https://docs.djangoproject.com/en/dev/topics/db/multi-db/ for
multi-db applications under django.

Path 2:

Do the url based routing  c1.company.com , c2.company.com in apache
server setup  and let apache configuraion refer to different wsgi.py
scripts to set  proper values for DJANGO_SETTING_MODULE.   And each
settings file points to different databases.

Are either of these approaches (1 or 2) work better?
-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3aDxvO1L8Ov9FHyUrQj%3Dr4bQURWQz%2Bz%3DZWreqyL9bptXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Recommendation/alternative for multi-tenancy under django

2014-07-21 Thread Subodh Nijsure
Unfortunately one of our requirement is to use mySQL. So this wouldn't
work with that correct?

To be honest at this moment I am not sure of pros & cons of using
mySQl v/s postgres  I will do some more research on that and see if
switching to postgres SQL is an option.

-Subodh

On Fri, Jul 18, 2014 at 9:11 PM, carlos  wrote:
> Hi, Subodh right now i find information for multi-tenant project in django
> and see
> this app, i never used only i read information for the future project.
>
> https://github.com/bernardopires/django-tenant-schemas
>
> maybe help you.
>
> Cheers
>
>
> On Fri, Jul 18, 2014 at 6:56 PM, Mike Dewhirst 
> wrote:
>>
>> On 19/07/2014 3:51 AM, Subodh Nijsure wrote:
>>>
>>> This is the first time I am trying to implement multi-tenant setup
>>> under django and hence the question.
>>>
>>> Problem/Setup
>>> - There are two companies signed up for service from portal I am
>>> developing say  CompanyA, CompanyB.
>>>
>>> - Each user with this setup is identified by unique email address,
>>> users login using their email address and password.
>>>
>>> - CompanyA has following users
>>>  A-tech1
>>>  A-tech2
>>>  A-tech3
>>>
>>> - CompanyB has following users
>>>  B-tech1
>>>  B-tech2
>>>  B-tech3
>>>
>>> Requirements:
>>>
>>> 1. Data security/isolation:Technician A-tech1, A-tech2, A-tech3
>>> should only be able to view data associated with companyA. Same for
>>> B-tech* technicians should only be able to see data from companyB.
>>>
>>> 2. Scalability: CompanyA, CompanyB might be of different sizes -
>>> companyA might have 10 users. While CompanyB might have 1s users
>>> representing large customers.
>>> 3. SLA: There might be different service level agreement with companyA
>>>   & companyB.
>>>
>>>
>>> I think, it doesn't make sense to lump data related to companyA, companyB
>>> into same database.
>>>
>>> Proposed Architecture Possibilities:
>>>
>>> Path 1:
>>> -  system will use one replicated database for
>>> authentication/authorization
>>> - When a company is registered within the system, 'Administrator' will
>>> assign a company to specific database connection. And request will be
>>> routed  to correct database using database router, based on currently
>>> logged in user.
>>>
>>> See https://docs.djangoproject.com/en/dev/topics/db/multi-db/ for
>>> multi-db applications under django.
>>>
>>> Path 2:
>>>
>>> Do the url based routing  c1.company.com , c2.company.com in apache
>>> server setup  and let apache configuraion refer to different wsgi.py
>>> scripts to set  proper values for DJANGO_SETTING_MODULE.   And each
>>> settings file points to different databases.
>>>
>>> Are either of these approaches (1 or 2) work better?
>>
>>
>> Another possible approach (in Postgres) is to keep everything in the same
>> database but segregate the private tables into different schemas. Normally
>> in Postgres everything goes into the public schema and you deal with privacy
>> using decorators and logic. But you could use non-public schemas as a
>> different segregation level. I'm not sure how easy or otherwise that might
>> be using Django.
>>
>> I have a similar if not identical privacy/segregation requirement which
>> needs to be solved before I can advance from prototype to production. Hence
>> I'm very interested in how you solve yours. Please share ...
>>
>> Mike
>>
>>
>>
>>> -Subodh
>>>
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/53C9C227.7020405%40dewhirst.com.au.
>>
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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,

Unable to create migration with Error - One or more models did not validate:

2014-07-30 Thread Subodh Nijsure
Hello,

I have following model definition and when I try to create a migration
using command,  'python manage.py schemamigration asset_mgmt
--initial' I am getting following error:

CommandError: One or more models did not validate:
asset_mgmt.alarmtable: 'polling_config' has a relation with model
AssetPollingConfig, which has either not been installed or is
abstract.

I have other classes that extend the TimeStampedModel and I don't see
this error, can someone point me towards reason I am getting this
error?


class TimeStampedModel(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
class Meta:
abstract = True

class AssetPollingInfo(TimeStampedModel):
id = models.AutoField(primary_key=True)
alarm_text = models.CharField(max_length=800,blank=True,null=True)
asset_id = models.ForeignKey('AssetInfo')
thresholds = models.ForeignKey('ThresholdInfo')
dispatch = models.ForeignKey('AlarmDispatchInfo')
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(self.id)

class AlarmTable(TimeStampedModel):
id = models.AutoField(primary_key=True)
polling_config = models.ForeignKey('AssetPollingConfig')
alarm_text = models.CharField(max_length=800,blank=False,null=False)
event_type = models.SmallIntegerField(blank=False,null=False)
trigger_point = models.IntegerField(blank=True,null=True)
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(self.id)


-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3YPGPTbBBXD%2Bi4F0XZ4FRTiSVYpQ2M%2Bt2fjbsG--%3D%2ButA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Unable to create migration with Error - One or more models did not validate:

2014-07-30 Thread Subodh Nijsure
duh! Thank you so much... Sometimes when you are on short-sleep you
make silly mistakes!!

-Subodh

On Wed, Jul 30, 2014 at 4:54 AM,   wrote:
> Hi,
>
> you've added a relation to the AssetPollingConfig model which is not
> defined.
>
> Cheers
>
> Am Mittwoch, 30. Juli 2014 13:34:52 UTC+2 schrieb Subodh Nijsure:
>>
>> Hello,
>>
>> I have following model definition and when I try to create a migration
>> using command,  'python manage.py schemamigration asset_mgmt
>> --initial' I am getting following error:
>>
>> CommandError: One or more models did not validate:
>> asset_mgmt.alarmtable: 'polling_config' has a relation with model
>> AssetPollingConfig, which has either not been installed or is
>> abstract.
>>
>> I have other classes that extend the TimeStampedModel and I don't see
>> this error, can someone point me towards reason I am getting this
>> error?
>>
>>
>> class TimeStampedModel(models.Model):
>> created = models.DateTimeField(auto_now_add=True)
>> modified = models.DateTimeField(auto_now=True)
>> class Meta:
>> abstract = True
>>
>> class AssetPollingInfo(TimeStampedModel):
>> id = models.AutoField(primary_key=True)
>> alarm_text = models.CharField(max_length=800,blank=True,null=True)
>> asset_id = models.ForeignKey('AssetInfo')
>> thresholds = models.ForeignKey('ThresholdInfo')
>> dispatch = models.ForeignKey('AlarmDispatchInfo')
>> class Meta:
>> ordering = ['-id']
>> def __unicode__(self):
>> return str(self.id)
>>
>> class AlarmTable(TimeStampedModel):
>> id = models.AutoField(primary_key=True)
>> polling_config = models.ForeignKey('AssetPollingConfig')
>> alarm_text = models.CharField(max_length=800,blank=False,null=False)
>> event_type = models.SmallIntegerField(blank=False,null=False)
>> trigger_point = models.IntegerField(blank=True,null=True)
>> class Meta:
>> ordering = ['-id']
>> def __unicode__(self):
>> return str(self.id)
>>
>>
>> -Subodh
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5a541fa1-208f-40ce-92f7-89546872d8d5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3YF1GrUt0DkumY80LijjPFdBzTb0RyQhjsaRUTdfU1AoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Help needed in constructing __in query

2014-08-04 Thread Subodh Nijsure
I have two tables as shown below.

class AlertTable(models.Model):
id = models.AutoField(primary_key=True)
alarm_text = models.CharField(max_length=800,blank=False,null=False)
event_type = models.SmallIntegerField(blank=False,null=False)
created = models.DateTimeField()
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(self.id)

class PendingAlertsTable(models.Model):
id = models.AutoField(primary_key=True)
alerttable = models.ForeignKey(AlertTable)
created = models.DateTimeField()
class Meta:
ordering = ['-id']
def __unicode__(self):
return str(self.id)

Idea is PendingAlertsTable holds reference to alerts that have not
been acknowledged. And AlertTable holds all the alerts.

So I want to construct query such that I can get all entries from
AlertTable that are Pending.

So I constructed query like this:

inner_qs=PendingAlertsTable.objects.all()
all_pending_events = AlertTable.objects.filter(pk__in=inner_qs)

That doesn't give me query set in all_pending_event of expected
entries. What is the correct way to construct the __in query in this
case?

-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3awheWS7AK%2BBfjGwW%3DkyoeJOTqGfr0gJ01rHbO%3Ds4PnJw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Crispy form Change default text shown for ImageField when not empty

2014-08-14 Thread Subodh Nijsure
Hello,

I have following field in my model.

photo = models.ImageField(null=True,blank=True,upload_to="product_images")

I have defined the following layout in forms.py for this field, while
using crispy-form

self.fields['photo'].label = "Asset Image"
self.helper.layout = Layout(
'photo',
HTML("""{% if form.photo.value %}
   
 {% endif %}""", ),

Now I can upload images associated with this particular field just
fine. However when I try to update the image I see the following in my
template:

http://i.imgur.com/wcB1JIP.png

Is there any way I can change the layout so that only the browse
button and existing image are shown when the image field is not empty?
In other words, remove the text Currently: product_images/km_2.jpeg
Clear Change:

-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3ZxdpY4eLx1RhwRV8%3D5j9aeysti7NbYuP5bZDZrsNrDPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Desperatly seeking help with ALLOWED_HOSTS

2014-08-17 Thread Subodh Nijsure
I am totally stumped why I can't get my site to work when DEBUG=False.

I have entered my domain name and IP address in the ALLOWED_HOSTS

I even tried putting '*' in my ALLOWED_HOST but when DEBUG=False I
always get my 400.html page served to me. As soon as DEBUG=True
everything works great.

I have search through google tried all the checks people say to try (
I think) , all my urls end in '/'. none of my local.py or base.py have
DEBUG setting or ALLOWED_HOSTS

ALLOWED_HOSTS = ['1.2.3.4', 'www.myhost.com', '*' , ]

Nothing seems to be working.

I even inserted by own dummy LoginRequierdMiddleware class it does get
called but I don't see anything wrong with request coming in.

class LoginRequiredMiddleware:
  def process_request(self, request):
print request

I am running nginx and apache2 in production environment. I am really
stuck , desperately need help!Any clues on how to debug this?

-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3Y_CvwWo1cPEcmROok13VQOneKnis2m9rwGQULbqo%3DpaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Desperatly seeking help with ALLOWED_HOSTS

2014-08-17 Thread Subodh Nijsure
Unfortunately I don't see traceback neither in my nginx log or my
apache log that is what is making it very confusing and difficult to
debug...

-Subodh

On Sun, Aug 17, 2014 at 11:37 AM, Cal Leeming [iops.io]  wrote:
> Can you please send us the traceback of the error generated? (assuming there
> is one)
>
> Cal
>
>
> On Sun, Aug 17, 2014 at 7:25 PM, Subodh Nijsure 
> wrote:
>>
>> I am totally stumped why I can't get my site to work when DEBUG=False.
>>
>> I have entered my domain name and IP address in the ALLOWED_HOSTS
>>
>> I even tried putting '*' in my ALLOWED_HOST but when DEBUG=False I
>> always get my 400.html page served to me. As soon as DEBUG=True
>> everything works great.
>>
>> I have search through google tried all the checks people say to try (
>> I think) , all my urls end in '/'. none of my local.py or base.py have
>> DEBUG setting or ALLOWED_HOSTS
>>
>> ALLOWED_HOSTS = ['1.2.3.4', 'www.myhost.com', '*' , ]
>>
>> Nothing seems to be working.
>>
>> I even inserted by own dummy LoginRequierdMiddleware class it does get
>> called but I don't see anything wrong with request coming in.
>>
>> class LoginRequiredMiddleware:
>>   def process_request(self, request):
>> print request
>>
>> I am running nginx and apache2 in production environment. I am really
>> stuck , desperately need help!Any clues on how to debug this?
>>
>> -Subodh
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CALr9Q3Y_CvwWo1cPEcmROok13VQOneKnis2m9rwGQULbqo%3DpaQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHKQagG%2BoyHxp%3DkOFZLZZBfrVLDcBYpWBPtFRAwKediRdwWkjg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3aM4KgYZa4Jwe3egoyCzvK3UFTngmY7ckCb4sPPPtrMPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Desperatly seeking help with ALLOWED_HOSTS

2014-08-17 Thread Subodh Nijsure
Thank you SO MUCH for that suggestion for logger. I have some compress
tags in my templates, but I guess I haven't configured that correctly.
And I was getting following error.


  File 
"/home/ubuntu/.virtualenvs/myvirt/lib/python2.7/site-packages/compressor/base.py",
line 121, in get_filename
filename = self.storage.path(basename)
  File 
"/home/ubuntu/.virtualenvs/myvirt/lib/python2.7/site-packages/django/core/files/storage.py",
line 261, in path
raise SuspiciousFileOperation("Attempted access to '%s' denied." % name)
SuspiciousFileOperation: Attempted access to '/css/bootstrap311.min.css' denied.
Not Found: /accounts/login/

the way I debugged this was creating following setup in my
production.py and then /tmp/debug.log had this error.

LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/tmp/debug.log',
},
},
'loggers': {
'django.request': {
'handlers': ['file'],
'level': 'DEBUG',
'propagate': True,
},
},
}

I removed the {% compress %} tags from my templates for now so I can
disable DEBUG on my "production/demo" server and everything works
great now!

-Subodh

On Sun, Aug 17, 2014 at 11:53 AM, Cal Leeming [iops.io]  wrote:
> Interesting, you could try removing the 400.html and allow it to raise the
> original exception that caused it.
>
> You could also try using a different WSGI server, such as uWSGI or gunicorn,
> as it could be a problem with that.
>
> Another option would be to use something like Sentry to capture the errors,
> or modify your `settings.LOGGING` to send to stderr.
>
> Cal
>
>
> On Sun, Aug 17, 2014 at 7:46 PM, Subodh Nijsure 
> wrote:
>>
>> Unfortunately I don't see traceback neither in my nginx log or my
>> apache log that is what is making it very confusing and difficult to
>> debug...
>>
>> -Subodh
>>
>> On Sun, Aug 17, 2014 at 11:37 AM, Cal Leeming [iops.io] 
>> wrote:
>> > Can you please send us the traceback of the error generated? (assuming
>> > there
>> > is one)
>> >
>> > Cal
>> >
>> >
>> > On Sun, Aug 17, 2014 at 7:25 PM, Subodh Nijsure
>> > 
>> > wrote:
>> >>
>> >> I am totally stumped why I can't get my site to work when DEBUG=False.
>> >>
>> >> I have entered my domain name and IP address in the ALLOWED_HOSTS
>> >>
>> >> I even tried putting '*' in my ALLOWED_HOST but when DEBUG=False I
>> >> always get my 400.html page served to me. As soon as DEBUG=True
>> >> everything works great.
>> >>
>> >> I have search through google tried all the checks people say to try (
>> >> I think) , all my urls end in '/'. none of my local.py or base.py have
>> >> DEBUG setting or ALLOWED_HOSTS
>> >>
>> >> ALLOWED_HOSTS = ['1.2.3.4', 'www.myhost.com', '*' , ]
>> >>
>> >> Nothing seems to be working.
>> >>
>> >> I even inserted by own dummy LoginRequierdMiddleware class it does get
>> >> called but I don't see anything wrong with request coming in.
>> >>
>> >> class LoginRequiredMiddleware:
>> >>   def process_request(self, request):
>> >> print request
>> >>
>> >> I am running nginx and apache2 in production environment. I am really
>> >> stuck , desperately need help!Any clues on how to debug this?
>> >>
>> >> -Subodh
>> >>
>> >> --
>> >> 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.
>> >> To view this discussion on the web visit
>> >>
>> >> https://groups.google.com/d/msgid/django-users/CALr9Q3Y_CvwWo1cPEcmROok13VQOneKnis2m9rwGQULbqo%3DpaQ%40mail.gmail.com.
>> >> For more options, visit https://groups.google.com/d

Caching some application data in memcache v/s in django process itself

2014-08-19 Thread Subodh Nijsure
Hello,

I have application that servers time-series data for 10+ units. This
data can get big  and I don't want to retrieve 5-6MB worth of data
from cassandra and serve it out as JSON to the client.

I want to maintain cache of this time series data. I had horrible
thought of just storing this data in local python dictionary instead
of doing something exotic like memcach server.

What are the plus/minus of just storing this cache in process running
django? Of course this doesn't scale well for 1000+ units..

-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3bbgfe46-JzSYXhUWbbv7tgjUbHbSjDxnQxXHEsuc6hLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Caching some application data in memcache v/s in django process itself

2014-08-19 Thread Subodh Nijsure
Thank you so much for all your suggestions. I am using uWSGI I will
certainly looking into that and then redis for caching.


-Subodh

On Tue, Aug 19, 2014 at 5:16 PM, Cal Leeming [iops.io]  wrote:
> Sorry forgot to add one more thing.
>
> For what it's worth, it does sound like a key/val store (such as
> memcache/redis) would be a better fit for this.
>
> Shared memory areas are great for storing huge lookup tables in high
> performance deployments, and it's always good to know these things for
> future, never know when it might come in handy :)
>
> Cal
>
> On Wed, Aug 20, 2014 at 1:07 AM, Cal Leeming [iops.io]  wrote:
>>
>>
>>
>>
>> On Wed, Aug 20, 2014 at 12:54 AM, Russell Keith-Magee
>>  wrote:
>>>
>>>
>>> On Wed, Aug 20, 2014 at 4:27 AM, Subodh Nijsure
>>>  wrote:
>>>>
>>>> Hello,
>>>>
>>>> I have application that servers time-series data for 10+ units. This
>>>> data can get big  and I don't want to retrieve 5-6MB worth of data
>>>> from cassandra and serve it out as JSON to the client.
>>>>
>>>> I want to maintain cache of this time series data. I had horrible
>>>> thought of just storing this data in local python dictionary instead
>>>> of doing something exotic like memcach server.
>>>>
>>>> What are the plus/minus of just storing this cache in process running
>>>> django? Of course this doesn't scale well for 1000+ units..
>>>
>>>
>>> This approach will probably work, but it's a bad idea.
>>>
>>> Firstly, if you store it in-process, the process is the web server. So -
>>> your web server will have a huge memory footprint. If your web server has
>>> multiple processes - which would be a common configuration for handling load
>>> - then the memory requirements will be duplicated for every process.
>>
>>
>> Not 100% true.
>>
>> uWSGI comes with a "shared memory" feature which lets you store a large
>> chunk of data in memory which is shared by all workers;
>> http://uwsgi-docs.readthedocs.org/en/latest/SharedArea.html
>>
>> There is a higher level abstraction of this which is aptly named
>> "caching";
>> http://uwsgi-docs.readthedocs.org/en/latest/Caching.html
>>
>> Although the benefits of storing in a separate key/value store db (such as
>> redis/memcache) vs using uWSGI shared memory are debatable, and it really
>> depends on your use case.
>>
>> This is, of course, assuming you are using uWSGI as your WSGI application
>> server.
>>
>>>
>>> Secondly, web processes aren't long lived. Depending on your web server
>>> configuration, each web server process will serve a certain number of
>>> requests, and then restart itself. This means that every N requests, the
>>> process will need to restart, and reload the in-process memory cache. This
>>> will obviously take time, and that's time the end-user is going to
>>> experience as a delay in loading a page.
>>
>>
>> This wouldn't be too much concern for the shared memory feature, however
>> you may run into issues where your data requires a lot of processing on each
>> query, mostly because the "shared memory" doesn't have any of the niceties
>> of redis/memcache. Again, it's very use case specific
>>
>>>
>>>
>>> So - you'll be much better served using memcache (or similar) - this
>>> keeps the "data I need to keep readily available in memory" separate from
>>> "data needed to keep the web server running". The memcache image is shared
>>> across processes - even across machines if necessary - and only requires an
>>> initial warming (which can be done out of the request-response cycle, if
>>> necessary).
>>
>>
>> Memcache would almost certainly be the easiest way to do this. Of course,
>> you do have to consider what happens if your memcache server goes down, and
>> make sure it's given the same love/attention as your application server in
>> terms of monitoring, configuration, maintenance etc. You could also run into
>> issues of eviction, e.g. if too much RAM is used it will start to remove
>> cached entries, and one of those might be your data. And also additional
>> latency depending on how many queries you're pushing (assuming 1ms per
>> query).
>>
>> Of course, if you're not using a "shared memory" feature like the one in
>> uW

Re: Feeling some serious timezone pain

2014-08-21 Thread Subodh Nijsure
You could consider passing the timestamp in UTC to the template and
then convert it to browser's timezone using javascript function -
convertUTCDateToLocalDate(data)?

-Subodh

On Wed, Aug 20, 2014 at 5:22 AM, christophw  wrote:
> Hi there,
>
> I'm feeling some pain while wrangling with timezones in an office room
> booking application.  I'm storing bookings in a MySQL database and want to
> display them in the timezone local to the office room, so it is not
> necessarily local to the user's local machine timezone.
>
> Here is my model's datetime definition:
> class Booking(models.Model):
>  date_time = models.DateTimeField()
>
> When the booking is stored, it comes back from a post and I store it in the
> DB as such:
>
> dt = datetime.datetime.strptime(request.POST["date"] + " " +
> request.POST["time"], "%Y-%m-%d %H:%M")
> dt = pytz.timezone("America/Toronto").localize(dt)
>
> Printing the value of dt after that call, it looks correct.
>
> Later on, I pull that booking out of my database by ID and render it in my
> template, rendering the datetime like this:
>
> {{booking.date_time}}
>
> I've tried re-interpreting the timezone after pulling it out of the
> database, to no avail. When I print the datetime object directly after it is
> pulled out of MySQL, I get it in UTC like so:
> 2014-08-30 16:00:00+00:00
>
> Re-interpreting it to force it into the office's local timezone, I get the
> correct result but 1 hour off is still rendered in the web browser
> # returns 2014-08-30 12:00:00-04:00
> booking.date_time =
> pytz.timezone("America/Toronto").normalize(booking.date_time)
>
>
>
> The result of this is the time is rendered 1 hour behind the actual time.
> This is consistent across all datetimes I've tried, and I seem to be unable
> to get Django to render the correct time.
>
> My question is this: Why is my datetime consistently rendering 1 hour off,
> and how do I wrangle it into rendering at the true time?
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2dbd562a-5db3-4787-80d2-5a0f93f07860%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3ZYx0jfee1NwiQmMfi_%2BaW14H9bXOULd%3Db5SxC-Uua0eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Generic way to create forms (not admin forms)

2014-09-15 Thread Subodh Nijsure
Hi,


In my application I have situation where I would like users to define
elements in a form -- things like buttons, text input fields, radio
buttons etc.

And save those forms as templates, and then at later time instantiate
that user-defined form and save data associated with that form.

( Basically I want to create very slimmed down version of what
applications such as pronto-form, jotform (www.jotform.com) or wufoo
forms. )

I know in general I can define JSON schema that I store that can store
how UI elements are to be stored and parse this UI element and create
HTML elements.

In this case I will store store the JSON in django table , also value
associated with form instance as new forms are instantiated.

I am looking at - http://plugins.jquery.com/dform/ or
http://www.alpacajs.org/ has anyone worked with similar things under
django are there any words of wisdom or other components I should look
at?


-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3axdPx2-iQAsM0LptXD-uh57eTo-Ohqw3x2Z9zPBcaFvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


crispy form wouldn't show form level errors

2014-10-04 Thread Subodh Nijsure
I have a form that clearly form level errors (not field level) I can
print those error messages in my form_invalid method.

But they are not showing up when using crispy form.

I have set following options

self.helper.form_error_title = "Form Errors"
self.helper.form_show_errors = True


( 
http://django-crispy-forms.readthedocs.org/en/latest/form_helper.html#bootstrap-helper-attributes
)

I can display them by passing form_errors in context as:

context['form_errors'] = form.errors

And show them in my template using

{{ form_errors }}

But I can't get crispy form to natively show form level errors. What
options do I have to set so crispy form will display form level errors
correctly?

-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3YvXaKZfxVr8CnySbkG3yFxd4n99Zc6YSJS3pukcPoSDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: crispy form wouldn't show form level errors

2014-10-04 Thread Subodh Nijsure
I have tried that in my fom_invalid method it has valid messages but crispy
firm is not picking it up. But if I just try to print them in template  it
is empty so it's getting reset between fom_invalid and template rendering?

Subodh
On Oct 4, 2014 10:18 AM, "Collin Anderson"  wrote:

> try this if you haven't:
> {{ form.non_field_errors }}
>
>  --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cd50882e-03c8-4295-9b91-98c24c29f84b%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3aTmPj-%3DCFp-QBghOAs-kmQgaGR%2B_TfeNVOALBnVvnH-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django email client (reusable app) kickstarter

2014-10-08 Thread Subodh Nijsure
Why does it need to have dependence  on specific database postgres?

Subodh
On Oct 8, 2014 5:43 AM, "Internet Profil Filip Kowalski" <
bi...@internetprofil.pl> wrote:

>  Hi,
>
> I have started kickstarter campaign:
> https://www.kickstarter.com/projects/112336300/open-source-email-client-based-on-python-and-djang
>
> The aim is to create an email client based on Python/Django which would be
> shared as open source.
> It would be easy to implement in projects and simple to develop (re-usable
> app).
>
> It would also:
>
> Be supported by Django>=1.6 and Python 2>=2.6 and Python 3>=3.3.
>
> Use PostgreSQL and Elasticsearch.
>
> Only support IMAP and use Imapclient (created by developers of Mozilla)
> which is currently the most stable library available.
>
> Use SSE (Server-sent events) for all notifications from the server.
>
> Have good documentation and clean, understandable code for easy
> implementation and further development.
>
> Be provided with templates that are based on bootstrap 3.0.
>
> The amount we are trying to raise - $7000- will go towards at least 320
> hours of work on the project.
>
> 10% of all funds raised over the target will be donated to the DSF (Django
> Software Foundation).
>
> More information, mockups, production and fulfillment plan you can find at
> kickstarter project page.
>
>
>
> Thank you for your help, both in helping to publish information via fb /
> twitter accounts and for direct support.
> --
> Filip Kowalski
> Internet Profil
> www.internetprofil.pl
> mob. 506 385 326
> tel. 58 661 11 62
> skype: easy-r1der
> ul. Śląska 53
> 81-304 Gdynia
> VAT EU: PL586-203-45-48
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/54352F68.6020500%40internetprofil.pl
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3Z-GKTTOUMLU5QPUrt0k3CTyhhExEZ3A147-8%2BDXBB%2Bxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django-inplaceedit any way to remove the hint at the top?

2014-04-13 Thread Subodh Nijsure
I just started using the django-inplaceedit using latest version. It
works great.
[ https://django-inplaceedit.readthedocs.org ]

But I want to remove the hint that it shows when showing editable
items  - 'Enable Edit Inline'. Is there any easy way to remove it?

BTW I searched the documentation for it is there way to reach mailing
list associated with django-inplaceedit?

[ Are there any other good inplace edit additions to django one should look at ]

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3aoXGWNKNSZWZnm8naHH5qLiN0PUC8cM87gLPFLdCXxmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Deferred reverse geo coding upon record save/update

2014-04-17 Thread Subodh Nijsure
I have application where mobile devices are collecting data from
sensors, and along with sensor reading they also save gps co-ordinates
where the sensor data is taken. This is uploaded to web server using
REST interface on django platform.

But I am trying to figure out how do I reverse geo decode those
lat/lang numbers to actual address using google reverse geo-coder
APIs. I know I could do this in save method but that would make save
operation slower. Is there some way I can queue these operations
within django implementation so the save can proceed but queue up a
job that will reverse geo-decode lat/long and update a record.

Say:

My REST api creates a new record in table sensordata, with lat, long
of (10.1, -120.202) what I want to happen is new record for sensordata
say unique id 1234 gets created. At the same time  job is queued
somewhere that will update record #1234 that will reverse geo-decode
10.1,-120.202 to the street address.

-Subodh

-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3ZtH_MKKRhddmmRrqW_LAe7nFB6dbQ06TfGO%2B1Fe_BFTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[no subject]

2014-06-22 Thread Subodh Nijsure
I have following ajax query that gets generated from my template.

This is done after user has logged into the system. One thing I have
noticed is very first GET request always prompts a dialog box that
asks users to login with username and password. I have done
console.log and csrf_token is non-null when this dialog is shown. Does
anybody have idea why this happens on all subsequnt reloads of this
page I never get prompted to enter username & password.

$.ajax({
type: "GET",
withCredentials: true,
async: false,
url: "/api/v1/myurl/",
data: {
csrfmiddlewaretoken: '{{ csrf_token }}'
},
success: function( json) {
});

It was suggested to me that I should follow this and make sure that
csrf token is present in the  header.


https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax

I have made sure that in my javascript I have recommended code that
set the Requestheader but that doesn't help!

Can anyone help me with this?

-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3Z9RXq9FwQbZV%2BY674qtnF-4Cf4wbnBjTfG2jJTVUEG4g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Unable to add CSRF token to the header

2014-06-22 Thread Subodh Nijsure
[ Sorry this is duplicate as I posted previous messages without Subject: !! ]

I have following ajax query that gets generated from my template.

This is done after user has logged into the system. One thing I have
noticed is very first GET request always prompts a dialog box that
asks users to login with username and password. I have done
console.log and csrf_token is non-null when this dialog is shown. Does
anybody have idea why this happens on all subsequnt reloads of this
page I never get prompted to enter username & password.

$.ajax({
type: "GET",
withCredentials: true,
async: false,
url: "/api/v1/myurl/",
data: {
csrfmiddlewaretoken: '{{ csrf_token }}'
},
success: function( json) {
});

It was suggested to me that I should follow this and make sure that
csrf token is present in the  header.


https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax

I have made sure that in my javascript I have recommended code that
set the Requestheader but that doesn't help!

Can anyone help me with this?

-Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3a-hqk5fA1TP_3RZetv3gVh-D%2BR4kK0kBfeHBGz%3D0v9xQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to store/model reachable data in django.

2014-06-25 Thread Subodh Nijsure
Hello

I have need to store data that can be graphed. Example I have mobile app
that collects temperature every 30 seconds for say 5 min and uploads these
samples via REST api to my database. I happen to be using django for
visualization.

Question I am pondering is what is the best way to store these values in
database. Store each point as record in db or store csv file? Downside if
trying to upload single point means lots of request to web site to upload
data. Csv file means I can't graph across data collected over say one
month.

Any tips on how to manage graphable data within django?

Subodh

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALr9Q3Z%3D9CJvuG0vvbBPBoX_RXHJYCnuRifQN4OKautOG6ruvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.