Re: Scaling django installation

2012-06-04 Thread Subhranath Chunder
On Mon, Jun 4, 2012 at 12:15 PM, vivek <puri.vi...@gmail.com> wrote:

>
>
> >
> > That's aggregated load time, and not a single page loading time. The test
> > comprised of navigating to multiple pages to generate more real life
> > scenario.
> >
>
> How many pages?
>
I guess it was 16.


>
> >
> > > 3. text/html , which is the output of django app, is taking 62.74 %
> > > time.
> >
> > This number might not be bad actually, taking into consideration that I
> aim
> > to reduce the number of http connections per page to something pretty
> low.
> >
>
> Number of connections/page will not bring down this figure.
>
As I said, I plan to reduce the number of connections per page. I don't
plan to reduce this figure.


>
>
> > > What is the payload of your html page ?
> >
> > 5- 10 Kb (compressed) on avg depending upon page content
> >
>
> > Since you thought the aggregated load time to be of a single page, I
> guess
> > your perspectives need to change accordingly. :)
>
> Possibly but that would depend on number of pages in testing. e.g. if
> the number of pages about 10+ it seems logical but if its 2-3 pages
> then its still on high side.


> Also the load time increases near linearly with number of users. Which
> doesn't sounds logical e.g. at peak its almost 3 miunutes.
>
Current single setup server has to handle high number of connections per
page. Around 50 - 80 connections on average.
Active connections thus linearly rose to around 2.3k. And apache webserver
currently is sitting in front of django and static, so you see thus effect.

Separation of django and static content is part of the deployment/setup
change anyway.


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


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Scaling django installation

2012-06-03 Thread Subhranath Chunder
On Monday, June 4, 2012, vivek wrote:

> Hi,
>
> > To load test I used loadimpact.com and the results of which can be
> found on:
> http://loadimpact.com/load-test/www.reviews42.com-18774e46e8f562a6eb4...
> > The test configuration consisted of 600 VUs with 10 mins step duration.
> > Got around .1 millions requests and around 200+ requests/sec max. Is this
> > good, bad, or at par?
>
> Some quick observations from results:
> 1. The user load times start from 30+ seconds

That's aggregated load time, and not a single page loading time. The test
comprised of navigating to multiple pages to generate more real life
scenario.


> 2. The error rate also increases with higher requests/sec.

Yes. With high reqs/sec it's starts to come in. An upcoming major client
side code optimization is in pipeline. A drastic change in reqs/sec is
expected.


> 3. text/html , which is the output of django app, is taking 62.74 %
> time.

This number might not be bad actually, taking into consideration that I aim
to reduce the number of http connections per page to something pretty low.


> Overall things don't seem optimal. If you are testing based on load
> times of 30+ sec then the test approach may not be practical, you dont
> expect your visitor to wait 30+ sec. Your application itself may need
> more fine tuning. text/html generation time seem on higher side.
> Also be mindful that generally database performance on Amazon EC2 is
> lower compared to bare metal servers but you have mentioned that the
> queries are minimal so not sure how much would that have any impact.
>
As I said above the 30+ secs is the aggregated number. That too for
un-optimized browser code.


>
> What is the payload of your html page ?
>
5- 10 Kb (compressed) on avg depending upon page content


>
> Without knowing much about the application its usually difficult to
> say much but based on the results, there seems to be scope of
> improvement in html generation itself.
>
Once the major client side optimization comes through, and some
deployment/setup changes, I expect the request/sec handling capability to
easily shoot the sky.

Since you thought the aggregated load time to be of a single page, I guess
your perspectives need to change accordingly. :)


>
> rgds
> vivek
>
>
> --
> 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: Scaling django installation

2012-06-02 Thread Subhranath Chunder
On Sat, Jun 2, 2012 at 7:14 AM, Tim Chase <django.us...@tim.thechases.com>wrote:

> On 06/01/12 09:17, Subhranath Chunder wrote:
> > (Given the fact that the server is deployed in Amazon EC2
> > Singapore location, as m1.xlarge with all it's network, memory
> > constrains in place)
>
> A couple of the other aspects that occurred to me:
>
> Is there geographical separation between your Django/web server and
> its backing database?  If your web server is serving Django
> pages/apps out of Singapore, but the database serving each of those
> requests is in the USA, it's asking for trouble.
>
Right you are. But NO in my case. :)


>
> Alternatively, if they're on the same (virtual?) server, are they
> competing for resources?  Most scalable sites have Django and
> database processes running on separate servers but ensuring that
> they're on the same local low-latency network
>
As I said currently, yes they are deployed as a single server setup. So are
competing for resources.
I'll probably change the setup to low-latency network cluster in the
future, once traffic starts to increase, and horizontal scaling is required.


>
> I presume your database queries have established indexes for the
> types of data queries you're executing.
>
YES.


>
>
> None of this precludes actually profiling your application to see
> where the slowness is actually happening, but it might be helpful to
> have in mind as you got chasing things down.
>
Sure. I'm chasing things down to keep them improving. It's better to
know/find possible bottlenecks, than ever getting badly caught on one.


>
> -tkc
>
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Scaling django installation

2012-06-01 Thread Subhranath Chunder
On Fri, Jun 1, 2012 at 8:20 PM, Kurtis Mullins wrote:

> To me, the biggest bottleneck in a "Django Application Installation" (not
> application) is not going to be Django at all. It's going to be I/O --
> typically to the database and/or file system.

Yup.


> Another large part are the templates (and rendering system) which
> typically read from the filesystem.
>
Okay. I might have overlooked this all the while.


>
> Write good code with a focus on minimizing DB queries.
>
Done with zero-or-none policy. And still we're improving.

-- 
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: Scaling django installation

2012-06-01 Thread Subhranath Chunder
Yup. the application performance has been kept in mind from the ground
work. Zero or one query, with extensive use of cache is what we try to
achieve at the app level.

Just to keep the thread a bit more focused on it's purpose, I would like to
remind ourselves that, the discussion is on "Scaling django installation"
and not "Scaling django application".
For e.g. (with random number representations)
- Setup 1: Single server setup:
 x1 Computation Units, x2 GB memory, n Geographical location, Max Serves
2000 requests/sec
- Setup 2: 2 servers cluster setup (1 server serving django, other media):
 y1 Computation Units, y2 GB memory, n Geographical location, Max Serves
3000 requests/sec
- Setup 3: 2 servers cluster setup (with a single load balancer):
 z1 Computation Units, z2 GB memory, n Geographical location, Max Serves
2800 requests/sec

Hope, I was able to put things in the right direction.


On Fri, Jun 1, 2012 at 7:43 PM, Javier Guerra Giraldez
<jav...@guerrag.com>wrote:

> On Fri, Jun 1, 2012 at 3:56 AM, Subhranath Chunder <subhran...@gmail.com>
> wrote:
> > how should we measure response complexity?
>
> a simple first approximation is the number of DB queries per page.


> the debug toolbar nicely gives that figure while developing.


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


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Scaling django installation

2012-06-01 Thread Subhranath Chunder
On Fri, Jun 1, 2012 at 6:57 PM, Tim Chase <django.us...@tim.thechases.com>wrote:

> On 06/01/12 03:56, Subhranath Chunder wrote:
> > With that in mind, how should we measure response complexity?
> > Any particular parameter, scale? Probably I can measure against
> > that, and share the numbers to shed more light on how many
> > requests can be handled in with a particular hardware config.
>
> There are a pretty small number of bottlenecks:
>
> 1) computation (a CPU-bound problem)
> 1b) algorithm (usually manifests as a CPU problem)
>
Not much computation involved in my case as far as I see. At most cases
it's all about zero or one db hit. memcache used to keep the data already
prepared. Still nothing like being able to measure the computation. How
would you measure it?


> 2) I/O
> 2a) disk
> 2b) network
> 2c) memory
>
Don't think these might be creating much bottleneck in my scenario. But
still, nothing like getting to exact figures. Again, how would you measure
it?


>
> Most of them can be mitigated through an improvement in algorithm or
> by adding an appropriate caching layer.  There's also perceived
> performance, so spawning off asynchronous tasks (such as via celery)
> can give the user the feel of "I've accepted your request and I'm
> letting you know it will take a little while to complete".
>
> In any testing that I do, I try to determine where the bottleneck
> is, and if that can be improved:  Did I choose a bad algorithm?  Am
> I making thousands of queries (and waiting for them to round-trip to
> the database) when a handful would suffice?  Am I transmitting data
> that I don't need to or that I could have stashed in a cache
> somewhere?  Am I limited by the CPU/pipe/disks on my machine?
>
The focus of the application has been to reduce bottlenecks as much as
possible.
Zero or one query, extensive use of memcache, async tasks(via celery), etc.
it's all there in application layer to reduce the bottlenecks.


>
> There's no single number to measure the complexity, but often
> there's an overriding factor that can be found addressed, at which
> point another issue may surface.
>
Are we sure. The round-trip response time for a request to the server,
can't that be used as a single number to measure the complexity?
(Given the fact that the server is deployed in Amazon EC2 Singapore
location, as m1.xlarge with all it's network, memory constrains in place)


>
> -tkc
>
>
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Scaling django installation

2012-06-01 Thread Subhranath Chunder
On Fri, Jun 1, 2012 at 1:39 AM, Doug Ballance <dball...@gmail.com> wrote:

> I don't think anyone will be able to give you a good evaluation
> without knowing more about the requests.  Django itself could probably
> handle 10k requests per second returning a simple "hello world"
> response, or less than 10 if you are returning very large/difficult to
> generate responses.  It is what your app does that is going to make
> all the difference.
>
Sure, I'm willing to share more info, as long as people are interested and
ready to discuss.
Just need some more traction on the thread to keep the discussion alive.

With that in mind, how should we measure response complexity? Any
particular parameter, scale?
Probably I can measure against that, and share the numbers to shed more
light on how many requests can be handled in with a particular hardware
config.

Any suggestion on how to load test/performance test django server
installation? (Comparing performance with some high-traffic sites, and
scaling application upto or better level is always desired :) )


>
> The djangobook.com site has some good info on scaling, despite being
> for a much older version of django.  Ignore the code, and skip down
> the the section on scaling:
> http://www.djangobook.com/en/1.0/chapter20/

Yeah. I'm very much aware of this. But what I always feel is, this section
is missing out on some numbers, to show how much the different setups
perform on similar hardware.

Right now, I myself am using the single server setup, as mentioned before.


>
>
> From my own experience, caching/memcache can make all the difference
> in the world.  Find out what is taking the time, and cache it.
> Different approaches to your page design can help too.  If the page is
> 95% identical for all users, cache the 95% and pull in the 5% with
> javascript to personalize.  Allowing something like varnish to sit in
> front of those expensive to generate, but cachable pages is another
> way to speed things up but it requires a bit of application specific
> configuration to be useful (ignoring cookies for certain urls, making
> sure you are setting the vary header correctly in your app, etc).
>
Memcache, etc. all in place. And we're still improving things as much as we
can.
Haven't really tried varnish till now, but will surely try it as well.

As for most of the other queries, they're still quite open. Starting with
the most important one:
> Got around .1 millions requests and around 200+ requests/sec max. Is this
good, bad, or at par?


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


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Scaling django installation

2012-05-31 Thread Subhranath Chunder
Bump!

On Wednesday, May 30, 2012, Subhranath Chunder wrote:

> As the subject suggests, wanted to discuss, acquire and share some
> knowledge on scaling django installation.
>
> Firstly, my current project is a product Reviews platform, and I wanted to
> benchmark or load test the current deployment.
> Currently the deployment/installation stands on a single server setup.
> - Single Amazon EC2 instance m1.xlarge
> - Apache Webserver (serving django and static)
>
> To load test I used loadimpact.com and the results of which can be found
> on:
>
> http://loadimpact.com/load-test/www.reviews42.com-18774e46e8f562a6eb4009495cf9d752
> The test configuration consisted of 600 VUs with 10 mins step duration.
> Got around .1 millions requests and around 200+ requests/sec max. Is this
> good, bad, or at par?
>
> - What might be the possible suggestions for scaling this installation?
> - Does separating out media server helps much, and upto what extent?
> - Can a single server setup handle 1k to 10k requests/sec?
> - Some tools for benchmarking and performance testing?
> - Other cost effective ways to scale up the installation?
> - What sort of django installation needs to be there to handle 10k
> requests/sec and .1 million parallel users at all time?
> - Any good reads on scaling/scalable django deployment or installation.
> Sort of guide.
>
> --
> Thanks,
> Subhranath Chunder.
> www.subhranath.com
>
>

-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Scaling django installation

2012-05-30 Thread Subhranath Chunder
As the subject suggests, wanted to discuss, acquire and share some
knowledge on scaling django installation.

Firstly, my current project is a product Reviews platform, and I wanted to
benchmark or load test the current deployment.
Currently the deployment/installation stands on a single server setup.
- Single Amazon EC2 instance m1.xlarge
- Apache Webserver (serving django and static)

To load test I used loadimpact.com and the results of which can be found on:
http://loadimpact.com/load-test/www.reviews42.com-18774e46e8f562a6eb4009495cf9d752
The test configuration consisted of 600 VUs with 10 mins step duration.
Got around .1 millions requests and around 200+ requests/sec max. Is this
good, bad, or at par?

- What might be the possible suggestions for scaling this installation?
- Does separating out media server helps much, and upto what extent?
- Can a single server setup handle 1k to 10k requests/sec?
- Some tools for benchmarking and performance testing?
- Other cost effective ways to scale up the installation?
- What sort of django installation needs to be there to handle 10k
requests/sec and .1 million parallel users at all time?
- Any good reads on scaling/scalable django deployment or installation.
Sort of guide.

-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: [Error] Mixing Two databases

2012-02-09 Thread Subhranath Chunder
You might be using joins in one or more of your MongoDB model declarations.
Check with the Meta section of the Mongo models.

Infact, if you are trying to span across collections in your non-relational
database on purpose, then something basic might be going wrong.


On Fri, Feb 10, 2012 at 9:32 AM, Subhodip Biswas
<subhodipbis...@gmail.com>wrote:

> Hi all,
>
> I am trying to use two database for my django(Django nonrel 1.3.1)
> project. One is Postgres and other is MongoDB.
> After filling in details in settings.py :
>
> DATABASES = {
>'default': {
>'ENGINE': 'django_mongodb_engine', # Add
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>'NAME': 'Mongo_MSTR',  # Or path to
> database file if using sqlite3.
>'USER': '',  # Not used with sqlite3.
>'PASSWORD': '',  # Not used with sqlite3.
>'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
>'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
>},
>'geodata': {
>'ENGINE': 'django.contrib.gis.db.backends.postgis', # Add
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>'NAME': 'mydatabase',  # Or path to
> database file if using sqlite3.
>'USER': 'Username',  # Not used with sqlite3.
>'PASSWORD': 'Password',  # Not used with sqlite3.
>'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
>'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
>
> }
> }
>
> Now if I am doing a
> $ Python manage.py syncdb --database=geodata
>
> I am getting a error like this :
> django.db.utils.DatabaseError: Ordering can't span tables on
> non-relational backends
>
> If however I am executing the above without postgres service started,
> I will get a error related to Postgres.
> If I am explicitly mentioning the RDMS why is it throwing me error
> based on MongoDB?
>
> What am I missing here? Any pointers or documents will be of great help.
>
>
> -
> Regards
> Subhodip Biswas
>
>
> GPG key : FAEA34AB
> Server : pgp.mit.edu
> http://subhodipbiswas.wordpress.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: [Share] Google+ and Django

2011-09-19 Thread Subhranath Chunder
Google+ is using OAuth2 pretty much like Facebook.


On Mon, Sep 19, 2011 at 10:24 PM, Javier Guerra Giraldez <jav...@guerrag.com
> wrote:

> On Sun, Sep 18, 2011 at 1:17 PM, Subhranath Chunder
> <subhran...@gmail.com> wrote:
> > I've probably made the first attempt to integrate the Google+ with Django
> > authentication backend, in the form a pluggable Django app.
>
> doesn't Google+ use oauth?
>
> --
> Javier
>
> --
> 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.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Editing djangoproject Community RSS feed info

2011-09-18 Thread Subhranath Chunder
I just added my tech blog to the https://www.djangoproject.com/community/ page
with feeds from http://scratch-blog.appspot.com/feed/rss/

Can someone with admin privileges, please edit and change the title to
'Subhranath Chunder' from the current 'ScratchBlog - The Scratch Blog'.
I had simply put the wrong info in there.

-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: [Sharing] django-custom-auths

2011-09-18 Thread Subhranath Chunder
Added the Google+ authentication app to it.


On Wed, Aug 10, 2011 at 2:52 PM, Subhranath Chunder <subhran...@gmail.com>wrote:

> I was working on these django applications which simplifies the use of
> third-party logins for a django project without breaking any existing code.
>
> My concerns were:
> - No existing code breakage.
> - Easy integration with django's own authenication system API.
>
> This is a work in progress with perhaps no documentation as of now. So,
> I've included an entire django project itself for now, to check on it's
> working.
> Currently, the Facebook authentication system is fully functional (using
> the current OAuth2 based Graph API implementation).
>
> If anyone is interested to try it out, you can check
> https://github.com/subhranath/django-custom-auths
>
> Any suggestions for improvements are very welcome.
>
> Thanks,
> Subhranath Chunder.
>



-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



[Share] Google+ and Django

2011-09-18 Thread Subhranath Chunder
Saw the Google+ API for developers released a couple of days back.

I've probably made the first attempt to integrate the Google+ with Django
authentication backend, in the form a pluggable Django app.
You can find the details in here:
http://scratch-blog.appspot.com/blog/2011/09/18/google-api-and-django-authentication-backend/
Or, to go directly to the project:
https://github.com/subhranath/django-custom-auths

-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: [Query] http redirect to non-fragmented url coming from fragmented url

2011-08-25 Thread Subhranath Chunder
I got the idea of what was happening looking at the behavior pattern itself.
But, what I was not sure whether these behaviors were defined or just
working like that. Which might lead to some other inconsistencies.

As, in my case the fragment was coming from some other third-party source.
Facebook as in this case.
So, I may not always have control over the fragment with which facebook
decides to hit on my app API.

Django seems to currently allow the sending of 302 response, with fragment,
as we saw in the second scenario.
And since it is allowing us to specify the fragment, which the browsers
seems to honor as of now. Shouldn't we also be able to explicitly specify
it's removal?
Maybe I'm asking too much out of the implementation, as I don't see that
much details in the RFC you mentioned. :)



On Thu, Aug 25, 2011 at 9:23 PM, Tom Evans <tevans...@googlemail.com> wrote:

> On Thu, Aug 25, 2011 at 4:04 PM, Subhranath Chunder
> <subhran...@gmail.com> wrote:
> > Yes, I do understand that fragment identifiers are not sent to the
> server.
> > But, I was not talking about that.
> > Infact, I was talking about the fragments send in the response as http
> 302
> > response specifically.
> > Maybe, I'll put a little code snippet below to explain the case better:
> :)
> > urls.py
> > =
> > ...
> > url(r'^$', 'dummy_app.views.index'),
> > url(r'^action/$', 'dummy_app.views.redirect_handler'),
> > ...
> > views.py
> > =
> > ...
> > def index(request):
> > if request.method == "GET":
> > return HttpResponse("Index Page  > type="button" value="Try" />")
> > else:
> > return HttpResponseRedirect("/action/")
> > def redirect_handler(request):
> > return HttpResponse("Hello")
> > ...
> > Scenario 1:
> > User opens the browser, and hits URL : http:///#test -> Gets to
> see
> > "Index Page" with a button with text "Try" -> browser url shown as
> > "http:///#test" -> User clicks the button -> New page content is
> > "Hello" -> current url in browser is "http:///action/#test"
>
> This only happens because you have omitted the action attribute from
> the form, so the browser submits to the exact same URL. When Django
> replies with a 302 'Found' response, it updates the URL with the found
> location, and keeps the identifier fragment, because that was part of
> the URL that was specified in the form.
>
> Basically, if you tell your browser to request /some/uri#fragment, and
> it receives a 302 response for that with location /some/other, it will
> interpolate the identifier fragment into the new url. If you don't
> want to have the identifier fragment in the new URL, don't link/post
> to a URL with the identifier fragment.
>
> > Scenario 2:
> > Changing the views.py as:
> > < return HttpResponseRedirect("/action/")
> > ...
> >> return HttpResponseRedirect("/action/#hello")
> > User opens the browser, and hits URL : http:///#test -> Gets to
> see
> > "Index Page" with a button with text "Try" -> browser url shown as
> > "http:///#test" -> User clicks the button -> New page content is
> > "Hello" -> current url in browser is "http:///action/#hello"
> > Now, do you see the difference. The http response did have the fragment
> > specified while issuing the 302 in the second case.
> > So, my original question still stands still for me. Is this behavior
> defined
> > and expected?
> >
> >
>
> No, its not defined. Your browser is trying to help you out. Consider
> this scenario, you are browsing some documentation and click a link in
> the index:
>
> Section 2
>
> Your browser now makes a request for /docs/. However, the index is out
> of date, and the correct URI is actually "/docs/index.html". The
> server sends an appropriate redirect:
>
> 302 Found
> Location: /docs/index.html
>
> Now, should your browser display /docs/index.html or
> /docs/index.html#section2? Your browser is deciding to do the latter,
> not all browsers do.
>
> This is discussed in an IETF draft from 1999:
> http://tools.ietf.org/html/draft-bos-http-redirect-00
>
> I can't see that its made it into an RFC proper yet. There is this
> blog post on MSDN, where an MSIE developer notices that MSIE doesn't
> do this, whilst Chrome, Opera and Firefox all do:
>
>
> http://blogs.msdn.com/b/ieinternals/archive/2011/05/17/url-fragments-and-redirects-anchor-hash-missing.aspx
>
> Cheers
>
> T

Re: [Query] http redirect to non-fragmented url coming from fragmented url

2011-08-25 Thread Subhranath Chunder
Yes, I do understand that fragment identifiers are not sent to the server.
But, I was not talking about that.

Infact, I was talking about the fragments send in the response as http 302
response specifically.
Maybe, I'll put a little code snippet below to explain the case better: :)

urls.py
=
...
url(r'^$', 'dummy_app.views.index'),
url(r'^action/$', 'dummy_app.views.redirect_handler'),
...

views.py
=
...
def index(request):
if request.method == "GET":
return HttpResponse("Index Page ")
else:
return HttpResponseRedirect("/action/")

def redirect_handler(request):
return HttpResponse("Hello")
...

Scenario 1:
User opens the browser, and hits URL : http:///#test -> Gets to see
"Index Page" with a button with text "Try" -> browser url shown as
"http:///#test"
-> User clicks the button -> New page content is "Hello" -> current url in
browser is "http:///action/#test"

Scenario 2:
Changing the views.py as:
< return HttpResponseRedirect("/action/")
...
> return HttpResponseRedirect("/action/#hello")

User opens the browser, and hits URL : http:///#test -> Gets to see
"Index Page" with a button with text "Try" -> browser url shown as
"http:///#test"
-> User clicks the button -> New page content is "Hello" -> current url in
browser is "http:///action/#hello"

Now, do you see the difference. The http response did have the fragment
specified while issuing the 302 in the second case.

So, my original question still stands still for me. Is this behavior defined
and expected?



On Thu, Aug 25, 2011 at 7:20 PM, Tom Evans <tevans...@googlemail.com> wrote:

> On Thu, Aug 25, 2011 at 12:48 PM, Subhranath Chunder
> <subhran...@gmail.com> wrote:
> > I was wondering whether this current behavior with respect to http
> redirects
> > on fragmented urls is actually a desired behavior, or some bug.
> > Let's suppose the user issues a GET request to the URI '/action#home'.
>
> Stop. Browsers do not send fragment identifiers to a server, they are
> solely used by the browser.
>
> > Now, the handler which is associated with this, processes the request and
> > lets suppose it wants to issue a http 302 to fetch the url '/' without
> any
> > specific fragment, in response.
> > Currently, this scenario seems to be not achievable in django using a
> simple
> > HttpResponseRedirect('/'), as the fragment from the last requested GET is
> > automatically appended to the next fetch request at the client side,
> which
> > results from the 302 response issued.
>
> Er - my browser doesn't do that. Are you sure you've tracked this through?
>
> Cheers
>
> Tom
>
> --
> 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.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



[Query] http redirect to non-fragmented url coming from fragmented url

2011-08-25 Thread Subhranath Chunder
I was wondering whether this current behavior with respect to http redirects
on fragmented urls is actually a desired behavior, or some bug.

Let's suppose the user issues a GET request to the URI '/action#home'.
Now, the handler which is associated with this, processes the request and
lets suppose it wants to issue a http 302 to fetch the url '/' without any
specific fragment, in response.

Currently, this scenario seems to be not achievable in django using a simple
HttpResponseRedirect('/'), as the fragment from the last requested GET is
automatically appended to the next fetch request at the client side, which
results from the 302 response issued.
So, instead of being redirected to '/' the user experiences a redirect to
'/#home', which might not be what was intended at the first place.

Issuing a 302 response with a specified fragment identifier does not have
the problem. But, the thing is, what if we want to redirect to a url without
specifying any primary fragment.

So, my query basically come down to: Is this behavior expected, or not
expected?
Or, is it the client browser whose current implementation of 302 response,
the only cause for this?


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Could not connect postgresql database

2011-08-23 Thread Subhranath Chunder
Seems to me like it has something to do with pg_hba.conf settings.

Maybe you can try out by commenting out the existing entries in it, and
inserting one specific to your requirement.
You should probably try it out. And don't forget to restart the db server
everytime you make a change.


On Tue, Aug 23, 2011 at 11:23 PM, SSozuer <selcuk.soz...@gmail.com> wrote:

> i am taking error below:
>
> psql: could not connect to server: No such file or directory
> Is the server running locally and accepting
>connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.
> 5432"?
>
> but there is no such a .s.PGSQL.5432 file. I really dont understand
> what is going on
>
> Selcuk
>
> On Aug 23, 8:12 pm, Subhranath Chunder <subhran...@gmail.com> wrote:
> > You may try to test the connection using the command line interface
> 'psql'.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Tue, Aug 23, 2011 at 10:39 PM, SSozuer <selcuk.soz...@gmail.com>
> wrote:
> > > Settings in postgresql.conf are ok. And also postgresql is running
> > > without no problem. As i said, i can connect database with pgAdmin
> > > with no error.
> > > Selcuk
> >
> > > On Aug 23, 8:03 pm, Landy Chapman <landy.chapm...@gmail.com> wrote:
> > > > Also did the the server actually start?  On debian,
> > > >   /etc/init.d/postgresql start
> >
> > > > > > > Try connecting on the local system. I would guess you can't. It
> > > looks
> > > > > > > like you have a problem with the socket directory. Permissions?
> >
> > > > > remember to edit postgresql.conf -- make sure to change
> > > > >  listen_addresses = '*'
> > > > >  port = 5432
> >
> > > --
> > > 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.
> >
> > --
> > Thanks,
> > Subhranath Chunder.www.subhranath.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: dynamic field display

2011-08-23 Thread Subhranath Chunder
Manipulating the form instance attributes at runtime in your view might be
possible by modifying some internal fields, but that leads to dirty code and
not-so-clean views.

You can rather use different django forms with different field definitions
in your view. This might be the cleanest.

You can also consider creating some generator function which can return you
a django form class on the fly, depending upon the form definition
parameters provided to the generator function during runtime. Obviously you
need to be careful with this, and consider the cons coming with it.


On Tue, Aug 23, 2011 at 12:01 AM, Axel Bock
<axel.bock.li...@googlemail.com>wrote:

> Hi group,
>
> I have another question about Django forms. I designed a Form for a Model,
> but now I want to remove fields depending on some user settings.
> Can I do that?
>
> Lets assume the following:
>
> class MyModel(models.Model):
>field1 = TextField(null=True, blank=True)
>field2 = Textfield(null=True, blank=True)
>
> class MyModelform(forms.Form):
>field1 = TextField()
>fiels2 = TextField()
>
> def viewform(request):
># some magic here :)
>return render_to_response(context_instance=RequestContext(request,
> {'form':MyModelForm()}))
>
> Now I want to disable field2 in the form on display, depending on the user
> settings. Any suggestions?
>
> Greetings & thanks,
> Axel.
>
> --
> 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.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Could not connect postgresql database

2011-08-23 Thread Subhranath Chunder
You may try to test the connection using the command line interface 'psql'.


On Tue, Aug 23, 2011 at 10:39 PM, SSozuer <selcuk.soz...@gmail.com> wrote:

> Settings in postgresql.conf are ok. And also postgresql is running
> without no problem. As i said, i can connect database with pgAdmin
> with no error.
> Selcuk
>
> On Aug 23, 8:03 pm, Landy Chapman <landy.chapm...@gmail.com> wrote:
> > Also did the the server actually start?  On debian,
> >   /etc/init.d/postgresql start
> >
> >
> >
> >
> >
> >
> >
> > > > > Try connecting on the local system. I would guess you can't. It
> looks
> > > > > like you have a problem with the socket directory. Permissions?
> >
> > > remember to edit postgresql.conf -- make sure to change
> > >  listen_addresses = '*'
> > >  port = 5432
>
> --
> 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.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: can django be used in destop application?

2011-08-23 Thread Subhranath Chunder
If ORM is what you are looking for, then you could try SQLAlchemy.


On Tue, Aug 23, 2011 at 4:47 PM, smith jack <thinke...@gmail.com> wrote:

> i mean not use django for web site development, but for desktop
> application,
> it seems its orm can be used in destop application, isn't it?
>
> --
> 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.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: How to create a sub-app directly

2011-08-21 Thread Subhranath Chunder
>From what I understood, by "sub-apps" Jim meant creating the application in
a sub-directory, or more specifically maybe inside another python package,
using the manage.py command for the sake of convenience and creating using a
single command.


On Sun, Aug 21, 2011 at 10:13 PM, Praveen Krishna R <
rpraveenkris...@gmail.com> wrote:

> *Is there  a concept of sub-apps exist in Django !?*
> *I knew some concepts like independant reusable apps.*
> *You can easily handle the rest with your urls right ?! correct me?
> *
>
> On Sun, Aug 21, 2011 at 6:27 PM, Subhranath Chunder 
> <subhran...@gmail.com>wrote:
>
>> Extend the manage.py functionality, by adding your custom command.
>> https://docs.djangoproject.com/en/dev/howto/custom-management-commands/
>>
>>
>> On Sun, Aug 21, 2011 at 8:52 PM, Jim <jianbao@gmail.com> wrote:
>>
>>> Hello folks,
>>>
>>> Here is the story. I created a site, mysite, with this command django-admin
>>> startproject mysite. Then, under the directory mysite/, I created an app
>>> named apps with this command ./manage.py startapp apps. apps is meant to
>>> hold all applications for mysite. Now, here comes the question:
>>> *How do I create a sub-app under apps with manage.py directly?*
>>>
>>> I tried
>>> ../manage.py startapp someapp
>>> under apps/, but that created the someapp under mysite/ rather than under
>>> apps/.
>>>
>>> I also tried
>>> ./manage.py startapp apps/someapp
>>> and
>>> ./manage.py startapp apps.someapp
>>> under mysite/, but neither worked.
>>>
>>> So, my current work-around is to create a sub-app under mysite/ first,
>>> then move it into apps/ manually. But that seems dumb, and I suspect there
>>> is a simpler way to do this.
>>>
>>> Thanks for reading this. Any help is certainly appreciated.
>>>
>>> Jim
>>>
>>> --
>>> 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/-/QtvEmvU5QvMJ.
>>> 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.
>>>
>>
>>
>>
>> --
>> Thanks,
>> Subhranath Chunder.
>> www.subhranath.com
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Thanks and Regards,
> *Praveen Krishna R*
>
>  --
> 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.
>



-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: How to create a sub-app directly

2011-08-21 Thread Subhranath Chunder
Extend the manage.py functionality, by adding your custom command.
https://docs.djangoproject.com/en/dev/howto/custom-management-commands/


On Sun, Aug 21, 2011 at 8:52 PM, Jim <jianbao@gmail.com> wrote:

> Hello folks,
>
> Here is the story. I created a site, mysite, with this command django-admin
> startproject mysite. Then, under the directory mysite/, I created an app
> named apps with this command ./manage.py startapp apps. apps is meant to
> hold all applications for mysite. Now, here comes the question:
> *How do I create a sub-app under apps with manage.py directly?*
>
> I tried
> ../manage.py startapp someapp
> under apps/, but that created the someapp under mysite/ rather than under
> apps/.
>
> I also tried
> ./manage.py startapp apps/someapp
> and
> ./manage.py startapp apps.someapp
> under mysite/, but neither worked.
>
> So, my current work-around is to create a sub-app under mysite/ first, then
> move it into apps/ manually. But that seems dumb, and I suspect there is a
> simpler way to do this.
>
> Thanks for reading this. Any help is certainly appreciated.
>
> Jim
>
> --
> 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/-/QtvEmvU5QvMJ.
> 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.
>



-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: What I am missing is this Django "logout"?

2011-08-21 Thread Subhranath Chunder
No, it's working is not a mistake by itself. Because now, the regular
expression is extracting an absolute path, and not a relative url path.

But, you are surely using things "the wrong way". :)


On Sun, Aug 21, 2011 at 4:57 PM, Andre Lopes <lopes80an...@gmail.com> wrote:

> Hi,
>
> Thanks for the reply.
>
> I have discovered that If I use this:
>
> [code]
> Welcome {{ request.user.username }}. Logout
> [/code]
>
> Instead of:
>
> [code]
> Welcome {{ request.user.username }}. Logout
> [/code]
>
> I got the code working as expected. The thing is that I got an URL
> like this: http://localhost:8080/logout//directorio//
>
> This should be working like this, or this is just a mistake that works?
>
>
> PS: Sorry my english.
>
> On Sat, Aug 20, 2011 at 10:35 PM, Subhranath Chunder
> <subhran...@gmail.com> wrote:
> >> Welcome {{ request.user.username }}. Logout
> > This part of your code is generating a logout URL like this in your
> > template: "/logout/directorio"
> > Now, your urls.py has the pattern:
> > url(r'^logout/(?P.*)/$',
> > 'django.contrib.auth.views.logout', name='auth_logout_next'),
> >
> > This makes, the variable 'next_page' assign the value after the slash
> > 'login/' section. i.e. next_page = 'directorio'
> > Now, the logout view is invoked and it's code gets executed. But since
> you
> > provided a relative url value to this view, a http 302 is issued to the
> > client to fetch the new url. Formed as a result of joining you current
> url
> > and the relative path. i.e. '/login/directorio/directorio'. Which is
> > basically again matching with the last url pattern. So, this whole thing
> > keeps on going in a loop where:
> > '/logout/directorio' is requested the first time. In response, the client
> is
> > requested to fetch url,
> > '/logout/directorio/directorio' the second time...
> > '/logout/directorio/directorio/directorio/directorio' the third time...
> > and so on and on in a loop.
> > This is why you never see the expected output in the page. The actual
> logout
> > is done in the first request only.
> > So, when you refresh the page, you are basically pre-empting your browser
> > client to break the initial loop, and manually requesting for the new
> fetch
> > request.
> > I hope I was able to clear the reason behind the outcome you were
> > experiencing.
> >
> >
> > On Sat, Aug 20, 2011 at 2:39 PM, Andre Lopes <lopes80an...@gmail.com>
> wrote:
> >>
> >> I am new to Django, and I am trying to put the logout to work...
> >>
> >> I have installed the an App called, Django-Registration.
> >>
> >> My problem is that I can do the logout, but the page does not get
> >> refreshed, I must to press F5 after the logout to see the page for not
> >> logged users.
> >>
> >> What I have done is the following:
> >>
> >> urls.py, added to urlpatterns:
> >> [code]
> >> url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page':
> >> '/'}, name='auth_logout'),
> >> url(r'^logout/(?P.*)/$',
> >> 'django.contrib.auth.views.logout', name='auth_logout_next'),
> >> [/code]
> >>
> >> In the template I have this code:
> >> [code]
> >> {% if request.user.is_authenticated %}
> >>Welcome {{ request.user.username }}. Logout
> >> {% else %}
> >>Welcome. Please login or  >> href="/accounts/register/">register
> >> {% endif %}
> >> [/code]
> >>
> >> When I click Logout I dont see this in the screen:
> >> [code]
> >> Welcome. Please login or  >> href="/accounts/register/">register
> >> [/code]
> >>
> >> I only see this text if I use F5 to refresh the page.
> >>
> >> What I am missing here?
> >>
> >> Please give me a clue.
> >>
> >> Best Regards,
> >>
> >> --
> >> 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.
> >>
> >
> >
> >
> > --
> > Thanks,
> > Subhranath Chunder.
> > www.subhranath.com
> >
> > --
> > You r

Re: What I am missing is this Django "logout"?

2011-08-20 Thread Subhranath Chunder
> Welcome {{ request.user.username }}. Logout

This part of your code is generating a logout URL like this in your
template: "/logout/directorio"
Now, your urls.py has the pattern:
url(r'^logout/(?P.*)/$',
'django.contrib.auth.views.logout', name='auth_logout_next'),

This makes, the variable 'next_page' assign the value after the slash
'login/' section. i.e. next_page = 'directorio'
Now, the logout view is invoked and it's code gets executed. But since you
provided a relative url value to this view, a http 302 is issued to the
client to fetch the new url. Formed as a result of joining you current url
and the relative path. i.e. '/login/directorio/directorio'. Which is
basically again matching with the last url pattern. So, this whole thing
keeps on going in a loop where:
'/logout/directorio' is requested the first time. In response, the client is
requested to fetch url,
'/logout/directorio/directorio' the second time...
'/logout/directorio/directorio/directorio/directorio' the third time...
and so on and on in a loop.

This is why you never see the expected output in the page. The actual logout
is done in the first request only.

So, when you refresh the page, you are basically pre-empting your browser
client to break the initial loop, and manually requesting for the new fetch
request.

I hope I was able to clear the reason behind the outcome you were
experiencing.



On Sat, Aug 20, 2011 at 2:39 PM, Andre Lopes <lopes80an...@gmail.com> wrote:

> I am new to Django, and I am trying to put the logout to work...
>
> I have installed the an App called, Django-Registration.
>
> My problem is that I can do the logout, but the page does not get
> refreshed, I must to press F5 after the logout to see the page for not
> logged users.
>
> What I have done is the following:
>
> urls.py, added to urlpatterns:
> [code]
> url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page':
> '/'}, name='auth_logout'),
> url(r'^logout/(?P.*)/$',
> 'django.contrib.auth.views.logout', name='auth_logout_next'),
> [/code]
>
> In the template I have this code:
> [code]
> {% if request.user.is_authenticated %}
>Welcome {{ request.user.username }}. Logout
> {% else %}
>Welcome. Please login or  href="/accounts/register/">register
> {% endif %}
> [/code]
>
> When I click Logout I dont see this in the screen:
> [code]
> Welcome. Please login or  href="/accounts/register/">register
> [/code]
>
> I only see this text if I use F5 to refresh the page.
>
> What I am missing here?
>
> Please give me a clue.
>
> Best Regards,
>
> --
> 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.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: extending the User profile - which way to go?

2011-08-20 Thread Subhranath Chunder
My suggestion, do it the Django way. In any case, even if you use the
inheritance model, the additional data would be stored in a separate
database table, and the data belonging to the super-class would be stored in
the main user's database table.


On Sun, Aug 21, 2011 at 1:26 AM, Axel Bock
<axel.bock.li...@googlemail.com>wrote:

> Hi again,
>
> I will need to add some properties to a user in the future. Now I found two
> ways of doing it. First, the Django-way (as described in the Django 
> docs<https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users>).
> Then I found some other posts from other people, all doing an inheritance of
> the original User-class and using this one. That seems rather elegant, cause
> there is one database lookup less necessary per user lookup. Now I want to
> go a way which is most "Djangonic" - cause I don't want to be stuck
> somewhere in the future with something that breaks on Django 1.4 or
> whatever.
>
> Any recommendations from the users here?
>
>
> Thanks in advance!
> Axel.
>
> --
> 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.
>



-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: How to store variable timedeltas in a Django model?

2011-08-14 Thread Subhranath Chunder
You can something like the following code to create a custom TimeDeltaField
in django.
Here I'm using python object serialization of represent the object as a
character object in the database.


models.py
===
import datetime
import pickle
from django.db import models

class TimeDeltaField(models.Field):
__metaclass__ = models.SubfieldBase

def __init__(self, *args, **kwargs):
kwargs['max_length'] = 200
if 'default' in kwargs:
kwargs['default'] = pickle.dumps(kwargs['default'])
super(TimeDeltaField, self).__init__(*args, **kwargs)

def get_internal_type(self):
return 'CharField'

def to_python(self, value):
if isinstance(value, basestring):
return pickle.loads(str(value))
return value

def get_prep_value(self, value):
return pickle.dumps(value)

class MyModel(models.Model):
timedelta = TimeDeltaField(default=datetime.timedelta(days=30))

def __unicode__(self):
return unicode(self.id)

===

This will enable you to use API like:

MyModel.objects.create()
MyModel.objects.create(datetime.timedelta(days=10, seconds=90))

I, guess you can now work on the so called "extra complications". :)

Thanks,
Subhranath Chunder.
www.subhranath.com


On Sun, Aug 14, 2011 at 10:40 AM, Karen Rustad <karen.rus...@gmail.com>wrote:

> Hello all,
>
> In one of my models, I want to store a timedelta--a length of time not
> tied to a particular start and end date. Although timedeltas are built
> into Python, tragically there's no TimeDeltaField in Django.
>
> Extra complications:
>
> * The timedelta can be quite large -- on the scale of one week to
> several months.
> * The timedelta has a default value, but it can be changed by the
> administrator.
> * I want the default timedelta length to be one month (which, of
> course, has a variable number of days!)
>
> It seems like *someone* has to have been able to do this, if only as a
> custom model field. But I wasn't able to find anything in the archives
> on this list and the #django IRC logger down so I couldn't search
> that. :/
>
> I did read the docs on how to write a custom model, but it looks
> terribly confusing--it's not clear which or how many of the attributes
> mentioned in the docs I would need to customize, given that it *is* a
> built-in Python variable type, and I have exactly zero experience
> dealing with databases directly.
>
> If anyone's got a hack around this limitation to recommend, or even
> some more relevant sample code than what's in the custom model docs,
> that would be super helpful!
>
> -- Karen
>
> --
> 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: Redisplay form with different field value?

2011-08-14 Thread Subhranath Chunder
If you are okay with overriding the values in you view, then can use
something like:

...
form = MyForm(request.POST)
if form.is_valid():
...

else:
data = form.data.copy()
data['field_name'] = 'default_value'
form = MyForm(data)
...

Not very efficient, but clean code.

Thanks,
Subhranath Chunder.
www.subhranath.com


On Sun, Aug 14, 2011 at 2:55 AM, Jonas H. <jo...@lophus.org> wrote:

> On 08/13/2011 05:00 PM, Karen Tracey wrote:
>
>> Plus, afaik, fields can not access form instances so this code would have
>>> to live in the form subclass -- not practical in my use case.
>>>
>>>  Where I have done this (reluctantly) has been in the form (or perhaps it
>> was
>> the field) clean method, where self is the form. I am not sure why in your
>> case you believe that to be not practical.
>>
>
> The field's clean method does not have access to the form; but the
> value-changing logic should go into the field code because I want to re-use
> the field on multiple forms.  Well, I guess that's just not possible with
> Django's form framework. I'll have to find some workarounds.
>
>
> --
> 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+unsubscribe@**
> googlegroups.com <django-users%2bunsubscr...@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 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: Connecting to the django app from outside the server

2011-08-14 Thread Subhranath Chunder
If the external IP or some domain name lands you directly on your machine,
then:
python manage.py runserver 0.0.0.0:
would do.

To access you can use: http://:

This should do. Hope it helps.

Thanks,
Subhranath Chunder.
www.subhranath.com


On Sun, Aug 14, 2011 at 9:12 AM, Python_Junkie <
software.buy.des...@gmail.com> wrote:

> I have placed my django application on the virtual server from go
> daddy.  The application runs  when I remote into the server and run
> the web pages with localhost on the 8000 port.
>
> How do I connect to this web page for demonstration purposes when I am
> not remoting into the virtual server.
>
> I tried just replacing localhost with the IP address with port 8000
> and that does not work.
>
> Do I need to open up port 8000 ?
>
> Is it possibly a permissions issue.
>
> I am presuming that I can continue to use the django light weight web
> server for demonstration purposes.
>
> Any assistance would be appreciated.
>
>
> Thanks in advance
>
> --
> 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.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Template tag: how to output success message above input field

2011-08-14 Thread Subhranath Chunder
Setting a simple context variable in your view would solve your purpose.

Thanks,
Subhranath Chunder.
www.subhranath.com


On Sun, Aug 14, 2011 at 1:22 PM, doniyor <doniyor@googlemail.com> wrote:

> Hey Guys,
>
> i need a litle help in working with forms. i have a button and i want
> to output a success text above the button if the user presses the
> button. how to do this ? is there any template tag like  {% if
> form.is_submitted %} or so?
>
> main point is that i dont want to write another html file only to show
> the success message.
>
> thanks in advance..
>
> Doni
>
> --
> 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.
>
>


-- 
Thanks,
Subhranath Chunder.
www.subhranath.com

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



Re: Admin app_index.html

2011-08-14 Thread Subhranath Chunder
The admin is supposed to provide an easy and ready to use interface for
content manipulation.
If your app doesn't have models, then the admin makes no sense for it.

Thanks,
Subhranath Chunder.
www.subhranath.com


On Sun, Aug 14, 2011 at 1:26 PM, doniyor <doniyor@googlemail.com> wrote:

> Hey Guys, i have here another problem..
>
> i wrote an app, without models, the whole thing happens in views.py
> and functions are coming from another file. so the thing i want is
> that my app should be visible in admin site. i read about overriding
> the app_index.html and put it under admin directory in my template
> directories. my problem is i dont know where to change in
> app_index.html sothat i see my app in admin.
>
> here is the app_index.html file in row view. i didnot change here
> anything yet.
>
> {% extends "admin/index.html" %}
> {% load i18n %}
> {% if not is_popup %}
>
> {% block breadcrumbs %}
> 
> {% trans "Home" %}
> {% for app in app_list %}
> {% blocktrans with app.name as name %} {{ name }} {% endblocktrans %}
> {% endfor %}{% endblock %}
>
> {% endif %}
> {% block sidebar %}{% endblock %}
>
>
> 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.
>
>

-- 
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: MySQLdb module not found even though it's installed.

2011-08-10 Thread Subhranath Chunder
On Wed, Aug 10, 2011 at 2:20 PM, babak <babak.vah...@avail.net> wrote:

> Did that and it didn't fail.
> But when I run:
> python2.6 manage.py syncdb
>
> everything works fine, so problem solved.
>
Your python mysql library binder is currently installed with the python2.6
instance only, and not with python2.5

You might consider changing the default python link to the python2.6
instance.


>
> On 10 Aug, 10:48, Subhranath Chunder <subhran...@gmail.com> wrote:
> > You can check with the following:
> >
> > python manage.py shell
> >
> > then do the,
> > import MySQLdb
> >
> > If this fails then you are probably running on different python
> > environments.
> >
> >
> >
> > On Wed, Aug 10, 2011 at 2:02 PM, babak <babak.vah...@avail.net> wrote:
> > > Hi I've installed MySQLdb om my mac and can import it:
> >
> > > Python 2.6.7 (r267:88850, Jul 20 2011, 12:30:08)
> > > [GCC 4.2.1 (Apple Inc. build 5664)] on darwin
> > > Type "help", "copyright", "credits" or "license" for more information.
> > > >>> import MySQLdb
> >
> > > But when I try to create database I get the following error
> >
> > > $./manage.py syncdb
> >
> > > Traceback (most recent call last):
> > >  File "./manage.py", line 14, in 
> > >execute_manager(settings)
> > >  File "/Users/project/django/core/management/__init__.py", line 438,
> > > in execute_manager
> > >utility.execute()
> > >  File "/Users/project/django/core/management/__init__.py", line 379,
> > > in execute
> > >self.fetch_command(subcommand).run_from_argv(self.argv)
> > >  File "/Users/project/django/core/management/__init__.py", line 261,
> > > in fetch_command
> > >klass = load_command_class(app_name, subcommand)
> > >  File "/Users/project/django/core/management/__init__.py", line 67,
> > > in load_command_class
> > >module = import_module('%s.management.commands.%s' % (app_name,
> > > name))
> > >  File "/Users/project/django/utils/importlib.py", line 35, in
> > > import_module
> > >__import__(name)
> > >  File "/Users/project/django/core/management/commands/syncdb.py",
> > > line 7, in 
> > >from django.core.management.sql import custom_sql_for_model,
> > > emit_post_sync_signal
> > >  File "/Users/project/django/core/management/sql.py", line 5, in
> > > 
> > >from django.contrib.contenttypes import generic
> > >  File "/Users/project/django/contrib/contenttypes/generic.py", line
> > > 6, in 
> > >from django.db import connection
> > >  File "/Users/project/django/db/__init__.py", line 77, in 
> > >connection = connections[DEFAULT_DB_ALIAS]
> > >  File "/Users/project/django/db/utils.py", line 91, in __getitem__
> > >backend = load_backend(db['ENGINE'])
> > >  File "/Users/project/django/db/utils.py", line 32, in load_backend
> > >return import_module('.base', backend_name)
> > >  File "/Users/project/django/utils/importlib.py", line 35, in
> > > import_module
> > >__import__(name)
> > >  File "/Users/project/django/db/backends/mysql/base.py", line 14, in
> > > 
> > >raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> > > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> > > module: No module named MySQLdb
> >
> > > Any idea? could it have something to do with that I also have python
> > > 2.5 installed on my computer?
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: {django-tables} Caught NameError while rendering: global name 'name' is not defined.

2011-08-10 Thread Subhranath Chunder
You seem to have heavily used external django apps like django-pagination
and django-tables.
I haven't used either of them myself, so it'll be difficult for me to follow
your code like this. Maybe, some else with experience on those might be able
to help you better.

On Wed, Aug 10, 2011 at 4:22 PM, Kayode Odeyemi <drey...@gmail.com> wrote:

> Thanks.
>
> Here's the views.py
>
> class TransactionReport(tables.ModelTable):
> identifier = tables.Column(sortable=False, visible=False)
> created = tables.Column(sortable=True, visible=True)
>
> @classmethod
> def get_reports_paid(self, object, req):
> return TransactionReport(object, order_by=req)
>
> class Meta:
> model = Transaction
>
>
> @login_required
> def display_reports(request):
> logger = logging.getLogger(__name__)
> dataqs = Transaction.objects.filter(paid="TRUE")
> req = request.GET.get('sort', 'created')
> tx = TransactionReport().get_reports_paid(dataqs, req)
>
> return render_to_response('webapp/reports.html', {'table': tx,
> 'rows' : tx.rows})
>
>
> rows is of type TransactionReport.
>
>
> On Wed, Aug 10, 2011 at 11:46 AM, Subhranath Chunder <subhran...@gmail.com
> > wrote:
>
>>
>>
>> On Mon, Aug 8, 2011 at 5:04 PM, Kayode Odeyemi <drey...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> Please why am I get the following error:
>>>
>>> Caught NameError while rendering: global name 'name' is not defined.
>>>
>>> Initially I did not receive this sort of error, it just surfaced all
>>> off a sudden. I restored my app to the state where everything worked
>>> and I'm still getting the same error.
>>>
>>> Full stack trace:
>>>
>>> Caught NameError while rendering: global name 'name' is not defined
>>> Request Method: GET
>>> Request URL:http://site/reports
>>> Django Version: 1.3
>>> Exception Type: TemplateSyntaxError
>>> Exception Value:
>>> Caught NameError while rendering: global name 'name' is not defined
>>> Exception Location: build\bdist.win32\egg\django_tables\models.py in
>>> _default_render, line 73
>>> Python Executable:  C:\path\apache\apache2.2.10\bin\httpd.exe
>>> Python Version: 2.7.1
>>>
>>> In my template file:
>>>
>>> {% load humanize %}
>>> {% load tables %}
>>> {% load pagination_tags %}
>>> {% autopaginate rows 2 %}
>>>
>> What is data type of this variable named 'rows' in here?
>>
>>
>>>
>>>{% for row in table.rows %}
>>>  
>>>  {% for value in row %}
>>>{{ value }}
>>>  {% endfor %}
>>>  
>>>{% endfor %}
>>>
>>> When i remove the above code from my template the error goes away but
>>> table rows are not displayed.
>>>
>>> Any suggestions please.
>>>
>>> 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.
>>>
>>>
>>  --
>> 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.
>>
>
>
>
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde
>
>  --
> 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: {django-tables} Caught NameError while rendering: global name 'name' is not defined.

2011-08-10 Thread Subhranath Chunder
On Mon, Aug 8, 2011 at 5:04 PM, Kayode Odeyemi  wrote:

> Hello,
>
> Please why am I get the following error:
>
> Caught NameError while rendering: global name 'name' is not defined.
>
> Initially I did not receive this sort of error, it just surfaced all
> off a sudden. I restored my app to the state where everything worked
> and I'm still getting the same error.
>
> Full stack trace:
>
> Caught NameError while rendering: global name 'name' is not defined
> Request Method: GET
> Request URL:http://site/reports
> Django Version: 1.3
> Exception Type: TemplateSyntaxError
> Exception Value:
> Caught NameError while rendering: global name 'name' is not defined
> Exception Location: build\bdist.win32\egg\django_tables\models.py in
> _default_render, line 73
> Python Executable:  C:\path\apache\apache2.2.10\bin\httpd.exe
> Python Version: 2.7.1
>
> In my template file:
>
> {% load humanize %}
> {% load tables %}
> {% load pagination_tags %}
> {% autopaginate rows 2 %}
>
What is data type of this variable named 'rows' in here?


>
>{% for row in table.rows %}
>  
>  {% for value in row %}
>{{ value }}
>  {% endfor %}
>  
>{% endfor %}
>
> When i remove the above code from my template the error goes away but
> table rows are not displayed.
>
> Any suggestions please.
>
> 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.
>
>

-- 
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: Keep filtering from change_list in admin in custom page?

2011-08-10 Thread Subhranath Chunder
You can either override a particular, or give a completely alternative
change_list page.

For your case, overriding seems to be a better option to me
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

If you are going for new change_list template
https://docs.djangoproject.com/en/dev/ref/contrib/admin/#custom-template-options


On Wed, Aug 10, 2011 at 2:49 PM, Thomas Weholt <thomas.weh...@gmail.com>wrote:

> Hmmm ... Not sure how to do that. You could say I want an alternative
> change_list page, but not by overriding or extending the existing
> default one.
>
> Do you know of any example or documentation on how to achive this?
>
> Anyway, thanks for your input :-)
>
> Regards,
> Thomas
>
> On Wed, Aug 10, 2011 at 11:07 AM, Subhranath Chunder
> <subhran...@gmail.com> wrote:
> > Yes, you can do that. You would have to override the default
> > change_view_template. And if required, then probably the
> changelist_view()
> > too.
> >
> > On Wed, Aug 10, 2011 at 2:28 PM, Thomas Weholt <thomas.weh...@gmail.com>
> > wrote:
> >>
> >> Is it possible to keep the filtering done in an admin change_list in a
> >> custom page? For instance, I got a app showing photos where you can
> >> filter on camera, width, height, exif-date, iso speed, exposure etc
> >> and the admin makes filtering my data very easy using a custom
> >> AdminModel. My filter shows up on the right side of the page. But I
> >> want to have a custom page for displaying the actual photos using the
> >> same filter set in the change_list page. Is this possible?
> >>
> >> --
> >> Mvh/Best regards,
> >> Thomas Weholt
> >> http://www.weholt.org
> >>
> >> --
> >> 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.
> >
>
>
>
> --
> Mvh/Best regards,
> Thomas Weholt
> http://www.weholt.org
>
> --
> 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: Generating urls for a search-engine-like application

2011-08-10 Thread Subhranath Chunder
If you are planning for reverse URL in your templates, then named URL
pattern is the thing for you.
https://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns

Else to simply, you might also consider changing the url patterns to
something like:
/country//
/city//
If you have the opportunity to do so.



On Wed, Aug 10, 2011 at 2:50 PM, samuele.mattiuzzo wrote:

> Hi all, i'm developing a search-engine-like application using django
> 1.3 and apache-solr as "database"
>
> I'm now stuck with urls handling. Basically, i need to compose urls
> with the parameters used to query solr. Fair enough, but i faced a
> problem.
>
> Basically, you can filter your results by choosing a country, a city,
> or both (example)
>
> My urls may look like this
>
> url(//, search_view),
> url(//, search_view),
> url(///, search_view)
>
> as you can see, case 1 and case 2 are a trouble: country and city are
> both strings, how's the url supposed to know if a link pointed to one
> url or another? Should i use named views in templating? What's the
> best way i can use them in my case?
>
> my boss told me to use get requests instead of post, so i could
> explicit the parameters, but SEO experts said "NO WAY!". i don't like
> get method either, but the reason is different :P
> i cannot use get_absolute_url from an object because i have no model
> objects (because, since now, there were no need... just an user object
> used to store some infos, nothing else)
>
> Any hint on how i can do this? Thanks all in advance!
>
> --
> 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.



[Sharing] django-custom-auths

2011-08-10 Thread Subhranath Chunder
I was working on these django applications which simplifies the use of
third-party logins for a django project without breaking any existing code.

My concerns were:
- No existing code breakage.
- Easy integration with django's own authenication system API.

This is a work in progress with perhaps no documentation as of now. So, I've
included an entire django project itself for now, to check on it's working.
Currently, the Facebook authentication system is fully functional (using the
current OAuth2 based Graph API implementation).

If anyone is interested to try it out, you can check
https://github.com/subhranath/django-custom-auths

Any suggestions for improvements are very welcome.

Thanks,
Subhranath Chunder.

-- 
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: making history

2011-08-10 Thread Subhranath Chunder
You could probably consider using post_save signals and make things a bit
little more generic.


On Wed, Aug 10, 2011 at 1:38 PM, Mike Dewhirst wrote:

> I want to update a history record whenever a particular record changes.
>
> Is it reasonable to call a method from within the save method of a model to
> go off and do the work?
>
> def updatehistory(recordx):
>""" if HistoryX doesn't exist, insert it so the RecordX
>author can add commentary. Also, add to the story with
>changed values from recordx every time RecordX.save() """
>pass
>
> class RecordX(models.Model):
>... various fields including 'ancestor' ...
>def save(self, **kwargs):
>super(RecordX, self).save(**kwargs)
>updatehistory(self)
>
> class HistoryX(models.Model):
>relation = models.OneToOneField(RecordX, to_field='ancestor')
>story = models.TextField()
>
>
> Is there a better way?
>
> Thanks
>
> Mike
>
> --
> 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+unsubscribe@**
> 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: Keep filtering from change_list in admin in custom page?

2011-08-10 Thread Subhranath Chunder
Yes, you can do that. You would have to override the default
change_view_template. And if required, then probably the changelist_view()
too.

On Wed, Aug 10, 2011 at 2:28 PM, Thomas Weholt wrote:

> Is it possible to keep the filtering done in an admin change_list in a
> custom page? For instance, I got a app showing photos where you can
> filter on camera, width, height, exif-date, iso speed, exposure etc
> and the admin makes filtering my data very easy using a custom
> AdminModel. My filter shows up on the right side of the page. But I
> want to have a custom page for displaying the actual photos using the
> same filter set in the change_list page. Is this possible?
>
> --
> Mvh/Best regards,
> Thomas Weholt
> http://www.weholt.org
>
> --
> 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: MySQLdb module not found even though it's installed.

2011-08-10 Thread Subhranath Chunder
You can check with the following:

python manage.py shell

then do the,
import MySQLdb

If this fails then you are probably running on different python
environments.


On Wed, Aug 10, 2011 at 2:02 PM, babak  wrote:

> Hi I've installed MySQLdb om my mac and can import it:
>
> Python 2.6.7 (r267:88850, Jul 20 2011, 12:30:08)
> [GCC 4.2.1 (Apple Inc. build 5664)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import MySQLdb
>
> But when I try to create database I get the following error
>
> $./manage.py syncdb
>
> Traceback (most recent call last):
>  File "./manage.py", line 14, in 
>execute_manager(settings)
>  File "/Users/project/django/core/management/__init__.py", line 438,
> in execute_manager
>utility.execute()
>  File "/Users/project/django/core/management/__init__.py", line 379,
> in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/Users/project/django/core/management/__init__.py", line 261,
> in fetch_command
>klass = load_command_class(app_name, subcommand)
>  File "/Users/project/django/core/management/__init__.py", line 67,
> in load_command_class
>module = import_module('%s.management.commands.%s' % (app_name,
> name))
>  File "/Users/project/django/utils/importlib.py", line 35, in
> import_module
>__import__(name)
>  File "/Users/project/django/core/management/commands/syncdb.py",
> line 7, in 
>from django.core.management.sql import custom_sql_for_model,
> emit_post_sync_signal
>  File "/Users/project/django/core/management/sql.py", line 5, in
> 
>from django.contrib.contenttypes import generic
>  File "/Users/project/django/contrib/contenttypes/generic.py", line
> 6, in 
>from django.db import connection
>  File "/Users/project/django/db/__init__.py", line 77, in 
>connection = connections[DEFAULT_DB_ALIAS]
>  File "/Users/project/django/db/utils.py", line 91, in __getitem__
>backend = load_backend(db['ENGINE'])
>  File "/Users/project/django/db/utils.py", line 32, in load_backend
>return import_module('.base', backend_name)
>  File "/Users/project/django/utils/importlib.py", line 35, in
> import_module
>__import__(name)
>  File "/Users/project/django/db/backends/mysql/base.py", line 14, in
> 
>raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
> django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb
> module: No module named MySQLdb
>
>
> Any idea? could it have something to do with that I also have python
> 2.5 installed on my computer?
>
> --
> 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: [Commercial] Freelance developer looking for long-term/contract based work

2011-08-10 Thread Subhranath Chunder
Now I'm available for immediate start of work.

Looking for long-term work only, on hourly basis. I can put in as many as
monthly 100 hours if required.
Please let me know if anyone is interested to hire me, asap.

On Fri, Aug 5, 2011 at 8:58 PM, Subhranath Chunder <subhran...@gmail.com>wrote:

> Have updated my Linkedin profile with project details.
>  On Jul 29, 2011 7:41 PM, "Subhranath Chunder" <subhran...@gmail.com>
> wrote:
> > Hi,
> >
> > I'm an experienced Django developer, with good experience in web
> application
> > development using Django as the underlying backbone. Have done numerous
> > projects in this, and my entire work experience is also build around it.
> >
> > Summary: I love to work on challenging Django/Python projects, which
> > involves working and experimenting with new and interesting ideas and
> > technologies.
> > Fancy my chances to work on performance enhancements and optimizations of
> > web applications, along with architectural designs of web products.
> >
> > Skillset: Web application development, Django/Python, GAE, jQuery,
> Facebook
> > Application Development
> >
> > Links to some publicly available code snippets of mine:
> > http://scratch-blog.appspot.com
> > https://github.com/subhranath
> >
> > LinkedIn profile (Needs to update the projects section soon):
> > http://in.linkedin.com/pub/subhranath-chunder/24/50/a01
> >
> > Currently, I'm switching work from a full-time employee to a full-time
> > freelancer.
> > Thus, I'm looking for some nice and interesting long-term or contractual
> > opportunity for work engagement.
> >
> > I could surely use some help to get some project, to get me started on my
> > freelancer career.
> > Please let me know if anyone is interested, or need any more details.
> >
> > Thanks,
> > Subhranath Chunder.
>

-- 
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 use "{% url *** %}" in django template file?

2011-08-07 Thread Subhranath Chunder
On Sun, Aug 7, 2011 at 10:35 AM, Jimmy  wrote:

> Hi,
>
> I got the error "Caught ImportError while rendering: No module named
> urls" when using:
>
> {% url 'card.views.create_card' %} in the template file
>
For django 1.2 and earlier versions you should use the syntax {% url
card.views.create_card %}

Django 1.3 supports the forward compatible {% url 'card.views.create_card'
%} syntax from the future library. You'll need to add the following line in
your templates to use the future library.
{% load url from future %}


>
> in the urls.py the route to the url is:
>
> urlpatterns = patterns('',
>   url(r'card/create$', 'card.views.create_card'),
> )
>
> The Django version I use is 1.3
>
> May I know what did I miss in setting?
>
> --
> 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: Calculation for each object in a QuerySet

2011-08-05 Thread Subhranath Chunder
Your model declarations are very confusing for me, and seems to be running
around in circles. Very difficult to follow for me.
The logical relationships are not clear. So, how to arrive at the
'rebate_pct' and 'wac' as you actually intend, is a mystery in itself for
me.

If you have the relationships clear in your mind, then you access the
related data from a model instance like as mentioned in
https://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects

Else, as suggested, you can go for raw sql queries, if the query itself is
getting too complex.


On Sat, Aug 6, 2011 at 12:19 AM, nixlists  wrote:

> On Fri, Aug 5, 2011 at 7:51 AM, bruno desthuilliers
>  wrote:
> > Without more informations about your models (and specially the
> > relationships), it's going to be rather difficult. As a general
> > consideration, if your Claim model can access these other models thru
> > relationships, well you just have to follow the relationships. This is
> > basic Django ORM stuff, well explained in the FineManual.
>
> Hi
>
> I have:
>
> class Product(models.Model):
>ndc = models.CharField(max_length=50)
>product_name = models.CharField(max_length=50)
>quantity = models.IntegerField()
>...
>
> class Pricing(models.Model):
>ndc = models.ForeignKey(Product)
># wholesale acquisition cost
>wac = models.DecimalField(max_digits=17, decimal_places=8)
>...
> class Contract(models.Model):
>name =  models.CharField(max_length=100)
>products = models.ManyToManyField(Product, through='ContractProduct')
>
> class ContractProduct(models.Model):
> contract = models.ForeignKey(Contract)
>ndc = models.ForeignKey(Product)
> wac = models.ForeignKey(Pricing)
>rebate_pct = models.DecimalField(max_digits=17, decimal_places=8)
>admin_pct = models.DecimalField(max_digits=17, decimal_places=8)
>
> class Claim(models.Model):
>contract = models.ForeignKey(Contract)
>ndc = models.ForeignKey(Product)
>quantity = models.IntegerField(blank=True, null=True)
>
> I need a view where for every row returned from Claim I make a
> calculation based on quantity from the Claim, rebate_pct and wac. Is
> it possible to write a model method that would access these fields
> from the other tables?
>
> 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.
>
>

-- 
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: splitting uploaded CSV data

2011-08-05 Thread Subhranath Chunder
Instead of writing:
f = csv.reader(open(fname, 'rb'), delimiter=',', quotechar='"')

you could have written only:
f = csv.reader(open(fname, 'rb'))

The 'delimiter' and 'quotechar' defaults to the ones you've specified.
But, it's nothing wrong to be explicit, rather than to rely on the implicit
values.


On Sat, Aug 6, 2011 at 1:47 AM, Vasu Nagalingam <nagalin...@gmail.com>wrote:

> Thanks. I am on it. Info below for future readers.
>
> What I did was:
> 1) set the order of the upload file handing in the settings.py so that
> default behavior in Django will always be to save the file to drive
> instead of keeping it in memory (for files under 2.5M)
> FILE_UPLOAD_HANDLERS = (
>'django.core.files.uploadhandler.TemporaryFileUploadHandler',
>'django.core.files.uploadhandler.MemoryFileUploadHandler',
> )
>
> 2) in my post upload routine, I opened the file using Python's CSV
> manipulation library.
> import csv
>
> fname = uploaded_data_file.temporary_file_path()
> f = csv.reader(open(fname, 'rb'), delimiter=',', quotechar='"')
> for line in f:
>   co_id = line[0]
>   co_name = line[1]
>   co_addr1 = line[2]
> and so forth.
>
>
>
> On Aug 5, 4:01 pm, Subhranath Chunder <subhran...@gmail.com> wrote:
> > Using the string split on CSV like this is bad in practice. Prefer using
> CSV
> > manipulation library instead. Like,
> http://docs.python.org/library/csv.html
> >
> > You can use the CSV reader module for your purpose.
> >
> > On Sat, Aug 6, 2011 at 1:13 AM, Vasu Nagalingam <nagalin...@gmail.com
> >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi - I am in implementing a batch file import function where the data
> file
> > > is in CSV format. The data file is uploaded (InMemoryFileHandler)
> > > successfully, but I am having trouble parsing the CSV data correctly.
> >
> > > My code:
> > > for line in imported_data:
> > >line = line.split(',')
> >
> > > My data is organized in this
> > > format: ,
> > > 0001,"google","123 Main St","san francisco","CA",94000
> > > 0002,"microsoft","1 Main St, 9th Floor","Boston","MA",17000
> >
> > > The code works fine for the first row (google). Due to the extra comma
> in
> > > the address 1 element for Microsoft, the import of row is mucked up. Is
> > > there a way to indicate the text delimiter as well as data delimiter
> for the
> > > split function? Or, any other options?
> >
> > >  --
> > > 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/-/F0cKmlxJTW8J.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: splitting uploaded CSV data

2011-08-05 Thread Subhranath Chunder
Using the string split on CSV like this is bad in practice. Prefer using CSV
manipulation library instead. Like,
http://docs.python.org/library/csv.html

You can use the CSV reader module for your purpose.


On Sat, Aug 6, 2011 at 1:13 AM, Vasu Nagalingam wrote:

> Hi - I am in implementing a batch file import function where the data file
> is in CSV format. The data file is uploaded (InMemoryFileHandler)
> successfully, but I am having trouble parsing the CSV data correctly.
>
> My code:
> for line in imported_data:
>line = line.split(',')
>
> My data is organized in this
> format: ,
> 0001,"google","123 Main St","san francisco","CA",94000
> 0002,"microsoft","1 Main St, 9th Floor","Boston","MA",17000
>
> The code works fine for the first row (google). Due to the extra comma in
> the address 1 element for Microsoft, the import of row is mucked up. Is
> there a way to indicate the text delimiter as well as data delimiter for the
> split function? Or, any other options?
>
>
>
>  --
> 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/-/F0cKmlxJTW8J.
> 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: Count users joined ordered by month

2011-08-05 Thread Subhranath Chunder
Not the exact answer you were looking for, but I was only wondering, if you
have already figured the actual SQL query then why not simply use that
instead.

It's not mandatory to use the model query APIs, if your query is complex.
Using the raw() API would still yield you model querysets or instances.
https://docs.djangoproject.com/en/dev/topics/db/sql/


On Fri, Aug 5, 2011 at 11:21 PM, Simon Zimmermann wrote:

> In SQL we can do
>
> SELECT MONTH(date_joined), YEAR(date_joined), COUNT(id) as
> joined_month
> FROM auth_user
> GROUP BY MONTH(date_joined), YEAR(date_joined)
> ORDER BY YEAR(date_joined), MONTH(date_joined)
>
> Which yields a table like this
>
> MONTH(date_joined)  YEAR(date_joined)   joined_month
> 3   200124
> 4   200186
> 5   2001133
> 6   200161
>
> Is it possible to do this with the Django ORM? So far I only got half
> of it with the following
>
> User.objects.all().extra({'month_joined':
>
> 'month(date_joined)'}).values('month_joined').annotate(created_count=Count('id'))
>
> --
> 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: [Commercial] Freelance developer looking for long-term/contract based work

2011-08-05 Thread Subhranath Chunder
Have updated my Linkedin profile with project details.
 On Jul 29, 2011 7:41 PM, "Subhranath Chunder" <subhran...@gmail.com> wrote:
> Hi,
>
> I'm an experienced Django developer, with good experience in web
application
> development using Django as the underlying backbone. Have done numerous
> projects in this, and my entire work experience is also build around it.
>
> Summary: I love to work on challenging Django/Python projects, which
> involves working and experimenting with new and interesting ideas and
> technologies.
> Fancy my chances to work on performance enhancements and optimizations of
> web applications, along with architectural designs of web products.
>
> Skillset: Web application development, Django/Python, GAE, jQuery,
Facebook
> Application Development
>
> Links to some publicly available code snippets of mine:
> http://scratch-blog.appspot.com
> https://github.com/subhranath
>
> LinkedIn profile (Needs to update the projects section soon):
> http://in.linkedin.com/pub/subhranath-chunder/24/50/a01
>
> Currently, I'm switching work from a full-time employee to a full-time
> freelancer.
> Thus, I'm looking for some nice and interesting long-term or contractual
> opportunity for work engagement.
>
> I could surely use some help to get some project, to get me started on my
> freelancer career.
> Please let me know if anyone is interested, or need any more details.
>
> Thanks,
> Subhranath Chunder.

-- 
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: manage.py dumpdata json storage problem

2011-08-01 Thread Subhranath Chunder
You would probably have to wait until the django backend for postgres is 
modified not to fetch all the records at one go.

As for now, I guess you should go ahead with writing custom serializers which 
specifically queries the db records in chunks.

Sent from my iPad 2

On Aug 1, 2011, at 7:06 PM, "Ricardo L. Dani"  wrote:

> I found the ticket to this issue (with patchs)
> 
> https://code.djangoproject.com/ticket/5423
> 
> On Mon, Aug 1, 2011 at 9:32 AM, Ricardo L. Dani  wrote:
> Hello django-users,
> 
> I'm having problems trying to serialize the data of a postgresql db of my 
> business application (lots of lots of data)
> 
> Using the command:
> 
> ./manage.py dumpdata > data.json
> 
> But, the execution of this command takes a long time and the ram and swap of 
> the computer reachs the limit causing a exeption:
> 
> django.db.utils.DatabaseError: out of memory for query result
> 
> The question is, somewone knows a way to this command write in the data.json 
> directly or in demand? I believe this is the problem and solution, am I 
> correct?
> 
> graciously,
> 
> -- 
> Ricardo Lapa Dani
> 
> 
> 
> -- 
> Ricardo Lapa Dani
> 
> -- 
> 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: Mysterious Path Issue Django & Apache

2011-07-29 Thread Subhranath Chunder
Check if the base directory is added in you current python path when running
from wsgi
Putting a line like "print >> sys.stderr, sys.path" in your wsgi file right
after the initial import should let you verify that.



On Sat, Jul 30, 2011 at 1:25 AM, Devon Young  wrote:

> I apologize in advance if this is actually a stupid question, but I'm
> thoroughly stumped since yesterday about this.
>
> First, it should be noted I come from a PHP background with a little
> experience in Perl, and I'm learning Python since Sunday. Also, I'm
> using:
>
> Python 2.7
> Apache 2 (with mod_wsgi)
> Django 1.3
> Ubuntu 11.04
>
> Ok now... I had django workin' perfectly, and then decided I wanted to
> move the folder I was keeping my projects & apps in. So I deleted that
> folder and made a new one, intending to begin over. At that time, I
> also updated the path in the .wsgi file.
>
> All runs fine when I run it as python manage.py runserver, but Apache
> now gives me a 500 server error, which in the error.log says
> "ImportError: Could not import settings 'combs.settings' (Is it on
> sys.path?): No module named movies.settings". Even though the path to
> the movies project is completely correct in the .wsgi file.
>
> I've been trying to debug this since yesterday, and just today I
> figured out that if I remake the original folder & move my project
> there & update the path in .wsgi ... then Apache is happy with it.
>
> I cannot make sense of this. Do I need to uninstall Django & then
> reinstall it from scratch? I doubt it's a permissions problem, 'cause
> I remade the directory & didn't chmod it differently. Did I have to
> hard code something during install that I've forgotten about since? My
> head is spinning with all these things to do to keep Django working
> that I can't remember half of what I did... altho, when I look back on
> the instructions I followed, I can't see anywhere that would get me to
> make a hard link or anything.
>
> Does anyone know how I can fix this so I can keep my projects in the
> folder I want to keep them?
>
> --
> 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.



[Commercial] Freelance developer looking for long-term/contract based work

2011-07-29 Thread Subhranath Chunder
Hi,

I'm an experienced Django developer, with good experience in web application
development using Django as the underlying backbone. Have done numerous
projects in this, and my entire work experience is also build around it.

Summary: I love to work on challenging Django/Python projects, which
involves working and experimenting with new and interesting ideas and
technologies.
Fancy my chances to work on performance enhancements and optimizations of
web applications, along with architectural designs of web products.

Skillset: Web application development, Django/Python, GAE, jQuery, Facebook
Application Development

Links to some publicly available code snippets of mine:
http://scratch-blog.appspot.com
https://github.com/subhranath

LinkedIn profile (Needs to update the projects section soon):
http://in.linkedin.com/pub/subhranath-chunder/24/50/a01

Currently, I'm switching work from a full-time employee to a full-time
freelancer.
Thus, I'm looking for some nice and interesting long-term or contractual
opportunity for work engagement.

I could surely use some help to get some project, to get me started on my
freelancer career.
Please let me know if anyone is interested, or need any more details.

Thanks,
Subhranath Chunder.

-- 
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: python threads and django views

2011-05-31 Thread Subhranath Chunder
Using the web-server to make such a request to open 10,000 odd URLs seems
unrealistic approach. Rather make a separate process to do the same.

Thanks,
Subhranath Chunder.

On Mon, May 30, 2011 at 11:29 PM, rahul jain <jainwolver...@gmail.com>wrote:

> All,
>
> I would like to know how to do this?
>
> For example, in my views I have to visit 10,000 websites (make url
> connection).   Each of those connections are independent connections.
> I would like to hit them as quickly as possible. Then return an
> http-response with some results.
>
> I have few questions now
>
> Obviously, I cannot hit these sites sequentially, that will take forever.
> Also, I believe its not possible, Django, put response time-out for each of
> those view responses!
>
> Creating 10,000 threads also is not a good idea.Therefore, I created queue
> based threads.
> I created 100 working threads and infinite size queue (i am not sure if
> this is a good idea)
> But receiving max URL connection error!
>
> How to fix this "max URL connection error" ? In addition, any tips for
> correctly implementing threads in django will be very helpful.
> Also, how to set the max timeout for http-responses  (django views) ?
>
> Thanks.
>
> Rahul
>
>
>
>
>
>  --
> 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: [Share] Protected web APIs (short and simple)

2011-04-25 Thread Subhranath Chunder
Updated this with a django helper (decorator) to make it work without any
view code changes at the receiving end.


On Fri, Apr 22, 2011 at 4:52 PM, Subhranath Chunder <subhran...@gmail.com>wrote:

> Hi,
>
> I've created a small and simple Python helper module to have protected web
> APIs in Django or other python projects, using a secret key string.
> It's using HMAC MD5.
>
> The main concept is of Facebook 'signed_request'.
>
> For details: https://github.com/subhranath/python-web-api-auth-helper
>
> Thanks,
> Subhranath Chunder.
>

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



Protected web APIs (short and simple)

2011-04-22 Thread Subhranath Chunder
Hi,

I've created a small and simple Python helper module to have protected web
APIs in Django or other python projects, using a secret key string.
It's using HMAC MD5.

The main concept is of Facebook 'signed_request'.

For details: https://github.com/subhranath/python-web-api-auth-helper

Thanks,
Subhranath Chunder.

-- 
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: Import error No module named urls to url login_in in html page

2011-04-19 Thread Subhranath Chunder
Hi,

The problems seems to be with the way you are using the view prefixes in the
'patterns' function in your urls.py
Refer to:
http://docs.djangoproject.com/en/dev/topics/http/urls/#the-view-prefix

You have used 'view' string twice.

Thanks,
Subhranath Chunder.

On Tue, Apr 19, 2011 at 5:11 AM, Guevara <eguevara2...@gmail.com> wrote:

> Hello!!
>
> I am getting the following error on my index.html page:
>
> Exception Type: TemplateSyntaxError
> Exception Value:
>
> Caught ImportError while rendering: No module named urls
>
>
> In this line:
>
>Login
>
> My urls.py:
>
> (r'^imobiliaria/', include('auth.urls')),
>
> In my auth app, i have this:
>
> urlpatterns = patterns('auth.views',
>url(r'^$', views.index, name="index"), <-- this is index page
>url(r'^accounts/login/$', views.login_in, name="login_in"), <--
> this is login page
>url(r'^logout/$', views.logout_view, name="logout_view"),
>url(r'^register/$',  views.register,  name="register"),
>url(r'^home/$', views.home, name="home"),
> )
>
>
> My view to render index.html is:
>
> def index(request):
>return render_to_response('imobiliaria/auth/index.html')
>
>
> In my settings.py i have this:
>
> AUTH_PROFILE_MODULE = 'imobiliaria.imobiliaria'
> LOGIN_URL = '/imobiliaria/accounts/login/'
>
> INSTALLED_APPS = (
> 'imobiliaria.auth',
> )
>
> ROOT_URLCONF = 'imobiliaria.urls'
>
>
>
> Anyone know where the problem might be?
> 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.
>
>

-- 
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 remove add and change links on admin dashboard

2011-01-23 Thread Subhranath Chunder
Override the templates.

On 23 Jan 2011 07:12, "rahul jain"  wrote:

Hi Guys,

how to remove add and change links + icons on admin dashboard ?

Thanks.

Rahul




 --
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: Django admin - action on delete

2011-01-07 Thread Subhranath Chunder
When deleting from the admin interface, the delete is actually on the entire
QuerySet rather than on the object level. So if you need to perform some
object level modification on the delete action of the admin interface, you
can remove the default 'delete_selected' action, and go a custom delete
action. Like:

class SomeModelAdmin(admin.ModelAdmin):
actions = ['custom_delete']
 def custom_delete(self, request, queryset):
 for object in queryset:
perform_some_action(object)
object.delete()
custom_delete.short_description = "Delete selected items"

def get_actions(self, request):
actions = super(SomeModelAdmin, self).get_actions(request)
del actions['delete_selected']
return actions

Thanks,
Subhranath Chunder.

On Fri, Jan 7, 2011 at 8:52 PM, galago <prog...@gmail.com> wrote:

> I made what I wanted in
> def log_deletion(self, request, object, object_repr):
>
> It's not elegant, but in Django 1.3 there is a delete_model() function:)
> But now I'm using 1.2.4 :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: Including subfolders

2011-01-07 Thread Subhranath Chunder
On Fri, Jan 7, 2011 at 10:32 PM, Mo Mughrabi <mo.mughr...@gmail.com> wrote:

> Hi,
>
> My project is getting quite large with so many apps, so i decided to create
> a folder for libs/shared and folder for apps in which libs/shared will
> contain all my generic libraries and apps will contain the project specific
> apps.
>
> I found the following
>
>
> http://solutions.treypiepmeier.com/2009/01/08/keep-your-django-applications-in-a-subfolder/
>
> and It did the job in enabling me to include apps. I just have to
> questions
>
> 1. How do create a tuple in my settings.py containing all the folders I
> need to include (in my case libs/shared and apps) and in manage.py include
> them without hard coding the folder names? It seems like the following
> function does not take tuples and only accept strings
>
> sys.path.insert(0, join(settings.PROJECT_ROOT, "apps"))
>

In your settings.py you can add:
sys.path.append(os.path.join(os.path.dirname(__file__), 'lib/shared'))
sys.path.append(os.path.join(os.path.dirname(__file__), 'app'))


> 2. Will my code works when I move it to production using mod_wsgi?
>

Yes.


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

Thanks,
Subhranath Chunder.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: creating apps inside sub folders

2011-01-07 Thread Subhranath Chunder
You can simply append the path to your 'lib/shared' directory to your system
path in the settings.py file.

sys.path.append(os.path.join(os.path.dirname(__file__), 'lib/shared'))
This should do.

Thanks,
Subhranath Chunder.

On Fri, Jan 7, 2011 at 9:20 PM, Mo Mughrabi <mo.mughr...@gmail.com> wrote:

> Hi,
>
> am trying to organize some commonly used apps in my libs/shared folder
> inside my project.
>
> When I moved the file there, I just appended libs.shared.appname to the
> INSTALLED_APP and it worked. but the views are not working, i noticed the
> urls that needed to be appended as well. What else am missing?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: list of lists in template

2011-01-06 Thread Subhranath Chunder
On Fri, Jan 7, 2011 at 12:22 PM, gintare <g.statk...@gmail.com> wrote:

>
> in view.py
> ...
> Ltarp.append([item.Wordword, item.WordTranslEn, item.WordNotesGram,
> item.WordConcl])
> ..
> Lans.append([sen.Sent, sen.SentTransl, Ltarp ] )
>
> in template.html
> {% if Lans %}
>
> {%  for smth in Lans %}
> 
>   {{smth.0}} 
>
>{%  for Ltarp in  smth.3 %}
>

Change this to:
{%  for Ltarp in  smth.2 %}

I think this is what you are trying to do.



>
> {{Ltarp.0}} 
>
>
>{% endfor %}
>
> 
> {% endfor %}
>
> {% endif %}
>
> ###
>
> the rows from smth.0 are shown
> the rows from  Ltarp in  smth.3, i.e. {{Ltarp.0}} are not shown.
>
> I tried also:Ltarp, Ltarp[0], smth.Ltarp.0
>
> nothing works in the second for cycle where i need to get items from
> list built in third item of list in the first for cycle.
>
> Could you please help with syntax, when i need to dislay item from
> list in another list in template
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
Thanks,
Subhranath Chunder.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: new user having trouble connecting django to postgres with psycopg2

2011-01-06 Thread Subhranath Chunder
I guess you'll have to set it to 'Australia/ACT Australia/Canberra
Australia/NSW Australia/Sydney' in your settings.py instead.

Thanks,
Subhranath Chunder.


On Fri, Jan 7, 2011 at 6:22 AM, Mark Brazil <markbra...@gmail.com> wrote:

> hi,
>
> I've been trying to find the answer to this for a bit, but haven't
> found anything suitable.
>
> I have postgresql 9.01, django 1.2.3 psycopg2 on ubuntu10.10
>
> When I try to use syncdb i get an error as follows
>
> "psycopg2.DataError: unrecognized time zone name"
>
> I currently have my settings.py set to "Australia/Sydney".
>
> I logged into postgres and set the TZ variable to AEST and started the
> database.
>
> But still get this.
>
> I'm guessing it is something simple, but cannot find the answer.
>
> Any ideas would be great,
> Thanks,
> Mark.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: User model being included by default

2011-01-06 Thread Subhranath Chunder
Firstly, I think this should be posted to the
django-us...@googlegroups.comgroup instead.
So, just make sure to post queries on using Django to there only.


Coming back to your question.
If you are using your own user model then, I hope you are using the not
using the import
'from django.contrib.auth.models import User' when try to '
User.objects.anymethod()'.
Make sure that you are using something like 'from yourapp.models import
User'.
And also make sure that the custom db tables for your app is properly
synced.

And when using some custom authentication backend in your application, I
think you'll probably want to specify and use it in your settings.py
as something probably like the following:
AUTHENTICATION_BACKENDS = (
'yourapp.backends.YourCustomBackend',
)

So, you'll also need to have the custom backend written too.

Thanks,
Subhranath Chunder.

On Fri, Jan 7, 2011 at 3:15 AM, Antony Vennard <antony.venn...@gmail.com>wrote:

> Hello all,
>
> For various reasons a client of mine requested that, other than using a
> framework of their choice, I implement an authentication system
> following their spec. I used Django and implemented my own app which
> contains the usual models.py which implements a user object and so on.
>
> Django has been updated via my package manager several times since I
> last tested my code. I've now come back to that and what was previously
> working is breaking like so:
>
> DatabaseError at /
> column auth_user.first_name does not exist
> LINE 1: SELECT "auth_user"."id", "auth_user"."username", "auth_user"...
>
> This happens when I import my own models.py and try to
> User.objects.anymethod()
>
> Now, my model "User" doesn't contain the same fields as Django's
> obviously, so the conclusion is that Django's User model is being
> included when I've not asked it to be.
>
> Relevant parts from Settings.py:
>
> TEMPLATE_LOADERS = (
>'django.template.loaders.filesystem.Loader',
>'django.template.loaders.app_directories.Loader',
>'django.template.loaders.eggs.Loader',
> )
>
> MIDDLEWARE_CLASSES = (
>'django.middleware.common.CommonMiddleware',
>'django.contrib.sessions.middleware.SessionMiddleware',
>'django.middleware.csrf.CsrfViewMiddleware',
>'django.contrib.messages.middleware.MessageMiddleware',
> )
>
> ROOT_URLCONF = 'Testbed.urls'
>
> TEMPLATE_DIRS = (
>"/var/www/Django/Testbed/testapp/templates",
>"/var/www/Django/Testbed/authadmin/templates",
> )
>
> AUTHENTICATION_BACKENDS = ('')
>
> TEMPLATE_CONTEXT_PROCESSORS = (
>"vxd.auth.contexts.Authentication",
> )
>
> INSTALLED_APPS = (
>'django.contrib.contenttypes',
>'django.contrib.sessions',
>'django.contrib.sites',
>'reversetag',
>'markitup',
>'vxd.auth',
>'Testbed.authadmin',
>'Testbed.testapp',
> )
>
> Can anyone please explain what's changed?
>
> Likewise, I get various strange errors on a similar project using my
> system when I try to access the request.session["username"] key.
>
> An alternative is a project-wide rename; still, this isn't ideal.
>
> Thanks,
>
> A
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To post to this group, send email to django-develop...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-developers+unsubscr...@googlegroups.com<django-developers%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-developers?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-us...@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.



Django Developer Requirement, [Full-time] Gurgaon, India

2010-12-03 Thread Subhranath Chunder
Hi,

There is opening and requirement for some Django developers in the company I
work in.
This is one the top Media companies in India, who are basically moving their
major projects and products to the Django platform.

If interested, please contact HR Parul Gupta for more details at
parul85gu...@gmail.com or 9717148584.

Thanks,
Subhranath Chunder.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Where do you put your business logic in django? Organizing big projects in django.

2010-09-27 Thread Subhranath Chunder
Sometimes I put it in some 'utils.py' in the app directory, and sometimes in
'views.py' itself, with leading underscores, whichever I feel is more
appropriate.

I guess this would be more of the developer's choice. Any better
suggestions?

Thanks,
Subhranath Chunder.

On Mon, Sep 27, 2010 at 12:43 PM, Antoni Aloy <antoni.a...@gmail.com> wrote:

> 2010/9/27 MrMuffin <thomas.weh...@gmail.com>:
> > Where do you put your business logic in django? In my project I`ve put
> > it into the models.py, but that file soon become huge and hard to
> > maintain. Of course I can just stuff it into whatever file I like, but
> > I`d like to have some standard way of doing this. There seems to be
> > something missing in django when it comes to business logic. It`s all
> > model, views and templates and that`s all great for small projects,
> > but both the models.py and views.py very soon gets huge and how do you
> > re-organize your project when that happens? Splitting views and models
> > into seperate files is only a partial solution and that requires some
> > hackish code in __init__.py to make syncdb etc work. And then there`s
> > urls.py.
> >
> > Should there be a better and standardized way to organize huge
> > projects in django?
> >
> > Thanks for your time.
> >
>
> Django allows you to split your project in applications, and Django
> applications are quite linked to models. But you can create your own
> libraries, this is Python. As an example, we create applications to
> connect to different web services and we use Django in the project.
> Each web service mapping is in its own Python packages. The Django
> urls and views just uses that package.
>
> Hope it helps!
>
> --
> Antoni Aloy López
> Blog: http://trespams.com
> Site: http://apsl.net
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: In admin, is there a post-commit hook that is executed after all models and inlines are saved?

2010-09-27 Thread Subhranath Chunder
Hi,

Since you have already done what you required, I'm not going much into
detail, but your process basically looks pretty lengthy.

Normally, to do these sort of stuff I only override two ModelAdmin methods:
- save_model()
- save_formset()

Using them together normally serves any kind of purpose, and the code looks
cleaner too. Maybe you can try with experimenting them out sometime.

Thanks,
Subhranath Chunder.

On Mon, Sep 27, 2010 at 8:19 AM, jonathan.morgan <
jonathan.morgan@gmail.com> wrote:

> Update:
>
> Well, I cobbled together a few things to accomplish most of what I
> needed to accomplish, and figured I'd write it down here so I can look
> it up later and so others can learn from it (the doc on m2m_changed,
> in particular, is not incomplete, but not detailed or particularly
> precise, and I had trouble finding a good example).
>
> The event to event_date relation was one-to-many, so there is a model
> for event dates that contains the key to each date's related event.
> For these, I overrode the save and delete methods for the event_dates
> model so it notifies the related event when any related date is added,
> changed, or deleted, after the actual save on insert, update, or
> delete, so the related event (which is still present in the instance
> even on delete, though the relation no longer exists in the database)
> can invoke a method that accepts the date and checks if it potentially
> needs to re-calculate its overall start and end dates from the
> database based on where the date lies in relation to its current start
> and end dates.  Part of the problem I was running into is that the
> internal set of event_dates for an event were not getting updated as
> updates from the admin screen were getting processed.  The database is
> updated, though, and so the event can query the database for updated
> dates and update its start and end date accurately even though its
> internal Set representation of associated dates gets out of sync.
>
> For the ManyToMany, I ended up being able to use the m2m_changed
> signal combined with overriding the save and delete on the right-hand
> side of the m2m relationship to let the event know that something had
> changed, and so it should rebuild its cached list of series and
> providers.  First, a few notes on what precisely the m2m_changed
> signal passes:
>
> - sender: Python new-class Type instance for the django-generated
> "through" class that connects the two models (Event.presenters.through
> and Event.series.through in this case).
>
> - instance: an instance of the model that contains the ManyToManyField
> relationship (Event, in this case).
>
> - model: Python new-class Type instance for the class of the model
> that is on the right side of the M2M relationship, joined by the
> "through" class that is in the "sender" parameter (Series and
> Presenter model classes in the two functions below).
>
> - action - either "pre_add"/"post_add" or
> "pre_clear"/"post_clear" ("pre_remove" and "post_remove" are never
> sent by the admin, as far as I can tell, since it just clears all
> relations each time a record is saved, then adds in relations again
> that still are present - not perhaps how I would have done it, but
> efficient).
>
> Because of how django admin implements processing changes to m2m
> relations (clear all, then re-add all that are present in form submit)
> m2m_changed doesn't actually tell you how the relation changed (so no
> signals for things getting removed, and no good signals on "add"
> versus "still here"), so I had to just use these signals to let the
> event know something had changed with a given set of relations, and
> have it call a method to update itself from the database to figure out
> what had changed and take the changes into account.  This worked, but
> wasn't quite as targeted as it could be if admin actually passed
> m2m_changed signals for removal, and didn't pass add signals for
> relations that were unchanged.
>
> I also limited the event listeners to only the "through" senders I
> cared about (see code sample below for accessing a "through" class -
> import the class that contains the ManyToManyField, then reference
> "class_name"."m2m_field_name".through).  Here is the code I ended up
> with for registering the signals (in my models.py file, so the Event
> class is already there, doesn't need to be imported, and including the
> debug and logging code I used to figure much of this out):
>
> # imports for handling signals that ManyToMany relations have changed.
> from django.db.models.signals import m2m_changed
> from django.dispatch import r

Re: DJANGO + Google App Engine, Getting Started Tutorial

2010-08-23 Thread Subhranath Chunder
You should try django non-rel project.

Thanks,
Subhranath Chunder.

On Aug 23, 2010 3:08 PM, "nobosh" <bhellm...@gmail.com> wrote:

I'm very interested in finding a up-to-date tutorial that shows steps
for getting DJANGO running on Google App Engine, anyone know of any
such tutorials?

Surprisingly, Google's App Engine DJANGO docs are almost a year old.
What gives?

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-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: [Offtopic] Freelance django dev in Spain

2010-08-11 Thread Subhranath Chunder
I'm a Django developer working on Django since December 2009. If you are
looking for freelance developer on Django, then I might be interested.

Thanks,
Subhranath Chunder.

On Wed, Aug 11, 2010 at 10:07 PM, Matias <matiassu...@gmail.com> wrote:

> Hi,
>
> We are looking for a freelance django dev located here in Spain,
> preferrably in Madrid.
>
> Please, contact me at matiassu...@gmail.com if you want to know more about
> this opportunity.
>
> Sorry for the offtopic.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: distinct() ?

2010-07-22 Thread Subhranath Chunder
With the other one, you would have got [u'ACTIVE', u'RESIGNED', u'TRANSFER']
without the unnecessary 'status' keyword each time.
Here you got only 3 results, but with more number of results, the 'status'
keyword each time would look annoying to me atleast.

But, I'm not sure which one will be faster. Can anyone please let me know,
which one would be faster. I'm not much considered about memory usage.

Thanks,
Subhranath Chunder.

On Thu, Jul 22, 2010 at 12:42 AM, rmschne <rmsc...@gmail.com> wrote:

> statuscodes=Member.objects.values('status').order_by('status').distinct()
>
> It gives me the expected results.  Three items in the dictionary from
> a database table of about 10,000 records:
> [{'status': u'ACTIVE'}, {'status': u'RESIGNED'}, {'status':
> u'TRANSFER'}]
>
> it's what i both expected and want.
>
> On Jul 21, 7:33 pm, Subhranath Chunder <subhran...@gmail.com> wrote:
> > I thought you were trying to get:
> >
> > I'm expecting only the four distinct records.
> >
> > You'll get a ValuesQuerySet or list of dictionaries with redundant keys
> this
> > way.
> >
> > Thanks,
> > Subhranath Chunder.
> >
> >
> >
> > On Wed, Jul 21, 2010 at 11:40 PM, rmschne <rmsc...@gmail.com> wrote:
> > > Member.objects.values('status').order_by('status').distinct()  from
> > > jaymzcd works perfectly. 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-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@google groups.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: distinct() ?

2010-07-21 Thread Subhranath Chunder
I would have rather done something simple like:

set(Member.objects.values_list('status', flat=True))

Thanks,
Subhranath Chunder.

On Thu, Jul 22, 2010 at 12:03 AM, Subhranath Chunder
<subhran...@gmail.com>wrote:

> I thought you were trying to get:
>
> I'm expecting only the four distinct records.
>
> You'll get a ValuesQuerySet or list of dictionaries with redundant keys
> this way.
>
> Thanks,
> Subhranath Chunder.
>
> On Wed, Jul 21, 2010 at 11:40 PM, rmschne <rmsc...@gmail.com> wrote:
>
>> Member.objects.values('status').order_by('status').distinct()  from
>> jaymzcd works perfectly. 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-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: distinct() ?

2010-07-21 Thread Subhranath Chunder
I thought you were trying to get:

I'm expecting only the four distinct records.

You'll get a ValuesQuerySet or list of dictionaries with redundant keys this
way.

Thanks,
Subhranath Chunder.

On Wed, Jul 21, 2010 at 11:40 PM, rmschne <rmsc...@gmail.com> wrote:

> Member.objects.values('status').order_by('status').distinct()  from
> jaymzcd works perfectly. 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: distinct() ?

2010-07-21 Thread Subhranath Chunder
>
>
> Member.objects.values('status').order_by('status').distinct()
>
>
I don't think this will ever work, to achieve what is required by him.

Thanks,
Subhranath

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Plese guide to solve this

2010-07-21 Thread Subhranath Chunder
Must be using very old docs:

Use these instead: http://docs.djangoproject.com/en/dev/

Thanks,
Subhranath Chunder.

On Wed, Jul 21, 2010 at 8:47 PM, n3ph <n...@terminal21.de> wrote:

>  Another one who's confused about all the deep API-Changes in Django :-(
>
> But reading the doc's is very helpful to preventing you from thees traps...
>
>
>
> Am 21.07.2010 17:04, schrieb euan.godd...@googlemail.com:
>
>  The traceback tells you exactly what the problem is. The correct kwarg
>> is max_length
>>
>>
>> On Jul 21, 2:00 pm, balu<vab...@gmail.com>  wrote:
>>
>>> Respected sir
>>>
>>> This is balu studying B.Tech third year. I started working on django
>>> in order to create dynamic website. My Python version is 2.6.5. While
>>> I'm using creating a app the following error has displayed in the
>>> command line.
>>>
>>> /
>>>
>>> */
>>>
>>> Microsoft Windows XP [Version 5.1.2600]
>>> (C) Copyright 1985-2001 Microsoft Corp.
>>>
>>> C:\Documents and Settings\Administrator>cd c:\
>>>
>>> C:\>cd projects
>>>
>>> C:\projects>manage.py startapp books
>>> 'manage.py' is not recognized as an internal or external command,
>>> operable program or batch file.
>>>
>>> C:\projects>cd mysite
>>>
>>> C:\projects\mysite>python manage.py startapp books
>>>
>>> C:\projects\mysite>cd books
>>>
>>> C:\projects\mysite\books>div
>>> 'div' is not recognized as an internal or external command,
>>> operable program or batch file.
>>>
>>> C:\projects\mysite\books>dir
>>>  Volume in drive C has no label.
>>>  Volume Serial Number is 3474-4CF2
>>>
>>>  Directory of C:\projects\mysite\books
>>>
>>> 07/21/2010  04:59 PM.
>>> 07/21/2010  04:59 PM..
>>> 07/21/2010  04:59 PM60 models.py
>>> 07/21/2010  04:59 PM   537 tests.py
>>> 07/21/2010  04:59 PM27 views.py
>>> 07/21/2010  04:59 PM 0 __init__.py
>>>4 File(s)624 bytes
>>>2 Dir(s)  27,813,937,152 bytes free
>>>
>>> C:\projects\mysite\books>cd C:\projects\mysite
>>>
>>> C:\projects\mysite>python manage.py validate
>>> Traceback (most recent call last):
>>>   File "manage.py", line 11, in
>>> execute_manager(settings)
>>>   File "C:\python26\lib\site-packages\django\core\management
>>> \__init__.py", line
>>> 438, in execute_manager
>>> utility.execute()
>>>   File "C:\python26\lib\site-packages\django\core\management
>>> \__init__.py", line
>>> 379, in execute
>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
>>> line 191,
>>>  in run_from_argv
>>> self.execute(*args, **options.__dict__)
>>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
>>> line 218,
>>>  in execute
>>> output = self.handle(*args, **options)
>>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
>>> line 347,
>>>  in handle
>>> return self.handle_noargs(**options)
>>>   File "C:\python26\lib\site-packages\django\core\management\commands
>>> \validate.p
>>> y", line 9, in handle_noargs
>>> self.validate(display_num_errors=True)
>>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
>>> line 245,
>>>  in validate
>>> num_errors = get_validation_errors(s, app)
>>>   File "C:\python26\lib\site-packages\django\core\management
>>> \validation.py", lin
>>> e 28, in get_validation_errors
>>> for (app_name, error) in get_app_errors().items():
>>>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
>>> line 146, in
>>>  get_app_errors
>>> self._populate()
>>>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
>>> line 61, in
>>> _populate
>>> self.load_app(app_name, True)
>>>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
>>&g

Re: import model from other module

2010-07-18 Thread Subhranath Chunder
Obviously it can be done. Just make sure to add the app to your
INSTALLED_APPS and use the proper path while importing.
Things should go fine if properly done.

Thanks,
Subhranath Chunder.

On Mon, Jul 19, 2010 at 1:28 AM, Andreas Pfrengle <a.pfren...@gmail.com>wrote:

> Hello,
>
> is there a possibility to import a model into models.py from any other
> module? In my models.py I'm trying to do:
>
> #models.py:
> from _external_modules.django_timer import Tim
>
> #django_timer.py:
> from django.db import models
> print 'test'
> class Tim(models.Model):
>
>
> This should import a database-based timer I've written. In fact, code
> from django_timer seems to be imported, since 'test' is printed when I
> execute "manage.py syncdb" - however, the database table is not
> created. Why? What would I need to change to make it work (except copy-
> paste the code into my models.py)?
>
> Thanks for answers,
> Andreas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: can foreign key fields be empty?

2010-07-18 Thread Subhranath Chunder
Ohh yes it's "null=True". Meant to say set field as None while using.

Eg:
class YourClass(models.Model):
your_model_field = models.ForeignKey('RelatedModel', null=True)
...

instance = YourClass.objects.create(your_model_field=None, ...)

Thanks,
Subhranath Chunder.

On Mon, Jul 19, 2010 at 1:35 AM, Ramiro Morales <cra...@gmail.com> wrote:

> On Sun, Jul 18, 2010 at 4:33 PM, rmschne <rmsc...@gmail.com> wrote:
> > Thanks ... but where does "None=True" go?
>
> That should be null=True winn defining the ForeignKey field.
>
> See
>
> http://docs.djangoproject.com/en/1.2/topics/db/models/#field-options
>
> Please accept this humble suggestion:
>
> Reading the documentation from beginning to end once
> will help you a lot when beginning. It would be unfortunate
> to not take advantage of such a great body of documents.
> There are other projects where this is not possible
> because the docs are very basic. But this isn´t the
> case with Django.
>
> Regards,
>
> --
> Ramiro Morales  |  http://rmorales.net
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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.



Tutorial: Custom Feed Generation using Django Syndication Feed Framework

2010-07-18 Thread Subhranath Chunder
Hi,

I was working with Django syndication feed framework sometime back, and
found the existing documentation missing certain things if you are planning
for customizing your feeds.

So, I just wrote up a tutorial to help others get started with it. If you
want, you can find it here:

http://scratch-blog.appspot.com/blog/2010/07/18/tutorial-custom-feed-generation-using-django-syndication-feed-framework-12-and-later/

Thanks,
Subhranath Chunder.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Django IDE

2010-07-18 Thread Subhranath Chunder
Obviously it's the user personal choice, always! :)

Thanks,
Subhranath Chunder.

On Sun, Jul 18, 2010 at 11:45 PM, Roald de Vries <downa...@gmail.com> wrote:

> On Jul 18, 2010, at 7:19 PM, Biju Varghese wrote:
>
>> Eclipse is the best IDE for python and django.
>>
>> On Jul 17, 8:53 pm, Jitendra Joshi <joshijitendra...@gmail.com> wrote:
>>
>>> What is the best open source Django IDE ?
>>>
>>
> I would say VIM, too. Emacs should be very good too, but I've never used
> it. Their advantage:
> 1) you can use them from the command line, so over SSH too, and they (at
> least VI) are available everywhere
> 2) they're so wide spread that there's a plug-in for almost everything
> 3) they're so configurable that you can write a plug-in to do anything you
> want
> 4) learn once, use for anything
>
> Admitted, there are disadvantages: they have a learning curve, expecially
> VIM, but once you know how to use them, they increase your productivity a
> lot.
>
> Features:
> - autocompletion
> - very very very strong search and replace
> - macro's
> - configurable key bindings/commands
>
> Comparison of VIM and Emacs (what I've read):
> - Emacs is monolithic (does everything, for example includes shell), VIM is
> unix style (does one thing well, why reproduce the shell?)
> - The unix cli uses Emacs key bindings (but VI bindings are optional)
> - Emacs doesn't have different (confusing) modes, VIM doesn't leave you
> with a crippled little finger (from all the 's)
> - VIM has more commands than Emacs
>
> I would say Emacs makes you more productive on shorter term, VIM makes you
> more productive on longer term.
>
> Cheers, Roald
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: can foreign key fields be empty?

2010-07-18 Thread Subhranath Chunder
A simple "None=True" should work.

Thanks,
Subhranath Chunder.

On Sun, Jul 18, 2010 at 11:25 PM, rmschne <rmsc...@gmail.com> wrote:

> I have two tables where one is a foreign key for the other. For some
> of the "children" there is no "parent".  Hence I want to leave the
> linking field NULL (empty) in the child database table.  I am having
> trouble making a queryset which finds all children without parents.  I
> was thinking looking for the linking field to be <1 or None or
> something.  Not working.  I'm thinking that it is because Django
> cannot allow a child record to no have a parent when their a foreign
> key defined?
>
> I'm not using Django, yet, to put data into the database, so there are
> children with no parents in the database.  This makes sense for the
> purpose of the application, but I can't get Django to tell me which
> children have no parents.
>
> Thoughts?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: Error with passing 'form_class' arg in urls.py for Django Profiles app

2010-07-15 Thread Subhranath Chunder
Could you provide the code for the custom ProfileForm class and the views
first.

Thanks,
Subhranath Chunder.

On Thu, Jul 15, 2010 at 2:49 AM, Ricko <rickentr...@gmail.com> wrote:

> Using ubernostroms Django Registration app coupled with his Profile
> app, both highly recommended, got the default app up and running no
> problems at all.
> I'm unable to override any default behaviour the proper way, as I
> can't seem to pass any extra parameters through the urls.py file. Here
> is my urls:
>
> from django.conf.urls.defaults import *
> from profiles import views
> from django.contrib.auth.decorators import login_required
> from userinfo.forms import ProfileForm
>
> urlpatterns = patterns('',
>   url(r'^edit/$',
>   login_required(views.edit_profile),
> {'form_class' : ProfileForm},
>   name='profiles_edit_profile'),
>   url(r'^(?P\w+)/$',
>   login_required(views.profile_detail),
>   name='profiles_profile_detail'),
>   )
>
> I have my custom form class ProfileForm. When I try this I get a
> stack:
>
> Original Traceback (most recent call last):
>  File "/Library/Python/2.5/site-packages/django/template/debug.py",
> line 71, in render_node
>result = node.render(context)
>  File "/Library/Python/2.5/site-packages/django/template/
> defaulttags.py", line 155, in render
>nodelist.append(node.render(context))
>  File "/Library/Python/2.5/site-packages/django/template/debug.py",
> line 87, in render
>output = force_unicode(self.filter_expression.resolve(context))
>  File "/Library/Python/2.5/site-packages/django/utils/encoding.py",
> line 71, in force_unicode
>s = unicode(s)
> TypeError: unbound method __unicode__() must be called with
> ProfileForm instance as first argument (got nothing instead)
>
>
> Now, the docs say to pass in the Class name, and the stack seems to be
> saying I need an Instance? Whatever extra parameter I pass I get the
> same error.
>
> What am I doing wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: problem models.py code

2010-07-14 Thread Subhranath Chunder
I'm not exactly sure what you want. So, I'm only assuming that you might be
trying to do something like:

jono = models.AutoField(unique=True)

instead of what you're currently using.

Thanks,
Subhranath Chunder.

On Wed, Jul 14, 2010 at 11:08 PM, Jagdeep Singh Malhi <
singh.malh...@gmail.com> wrote:

> I try  this code to create database in using django.
>
> file :models.py
> class amount(models.Model):
> jono = models.PositiveIntegerField(unique=True)
> name = models.CharField(max_length=750)
> receipt = models.CharField(max_length=200)
> phno = models.CharField(max_length=25)
> type = models.CharField(max_length=50)
> rdate = models.DateField('date published')
> site = models.CharField(max_length=200)
>
> after run
> #python manage.py sql tcc
> command i get
> BEGIN;
> CREATE TABLE `tcc_amount` (
>`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
>`jono` integer UNSIGNED NOT NULL UNIQUE,
>`name` varchar(750) NOT NULL,
>`receipt` varchar(200) NOT NULL,
>`phno` varchar(25) NOT NULL,
>`type` varchar(50) NOT NULL,
>`rdate` date NOT NULL,
>`site` varchar(200) NOT NULL
> )
> ;
> COMMIT;
>
> But i want 'jono'  is also AUTO_INCREMENT with 'id'  or  only jono
> not include the 'id '.
> Which code is used to make 'jono ' to auto increment.??
> Pleases help ,if possible.
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: Comparing DateTimeField to datetime.now()

2010-07-14 Thread Subhranath Chunder
How did u import the datetime module?
If you did:

a>
import datetime
Then, use 'datetime.datetime.now()' instead of 'datetime.now()'

b>
from datetime import datetime
Then 'datetime.now()' should work correctly.

Thanks,
Subhranath Chunder.



On Wed, Jul 14, 2010 at 9:13 PM, Chris McComas <mccomas.ch...@gmail.com>wrote:

> This is my model, I'm trying to set it so that if the game is in the
> future, based on the field date, then to return True, if not return
> False.
>
> http://dpaste.com/218111/
>
> I am importing datetime in my models.py but for some reason it's
> giving me nothing. I tried displaying future and nothing shows up?
> What have I done wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: return number instead of string in admin

2010-07-14 Thread Subhranath Chunder
Alan,

This is simple python string formatting. You may refer to the following for
more details:
http://docs.python.org/library/stdtypes.html#string-formatting

Thanks,
Subhranath Chunder.

On Wed, Jul 14, 2010 at 5:31 PM, alan-l
<alan.lough...@essexcricket.org.uk>wrote:

> brilliant, thank you.
>
> is there a python or django page that layouts all the available
> options that can be after the percentage and what they mean?
>
>
> Thanks,
>
> Alan
>
> On Jul 14, 11:35 am, Subhranath Chunder <subhran...@gmail.com> wrote:
> > Try this instead:
> >
> > def __unicode__(self):
> >return u"%d" % (self.mynumber, )
> >
> > On Wed, Jul 14, 2010 at 3:57 PM, Nuno Maltez <nuno.li...@gmail.com>
> wrote:
> > > Hi,
> >
> > > Why not
> >
> > > def __unicode__(self):
> > >return u"%d" % self.mynumber
> >
> > > ?
> >
> > > Nuno
> >
> > > On Wed, Jul 14, 2010 at 11:15 AM, alan-l
> > > <alan.lough...@essexcricket.org.uk> wrote:
> > > > Hi,
> >
> > > > in the tutorial i see that to return a string or a combination of
> > > > strings, i can do:
> > > >def __unicode__(self):
> > > >return u'%s %s' % (self.firstname, self.surname)
> >
> > > > what do i need to do to return a number? or more importantly, what is
> > > > the def called to ensure it is read and returned when looking at the
> > > > class in admin?
> >
> > > > Thanks,
> >
> > > > Alan
> >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > > To post to this group, send email to django-us...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@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-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> <django-users%2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@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-us...@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: return number instead of string in admin

2010-07-14 Thread Subhranath Chunder
Try this instead:

def __unicode__(self):
   return u"%d" % (self.mynumber, )


On Wed, Jul 14, 2010 at 3:57 PM, Nuno Maltez  wrote:

> Hi,
>
> Why not
>
> def __unicode__(self):
>return u"%d" % self.mynumber
>
> ?
>
> Nuno
>
> On Wed, Jul 14, 2010 at 11:15 AM, alan-l
>  wrote:
> > Hi,
> >
> > in the tutorial i see that to return a string or a combination of
> > strings, i can do:
> >def __unicode__(self):
> >return u'%s %s' % (self.firstname, self.surname)
> >
> >
> > what do i need to do to return a number? or more importantly, what is
> > the def called to ensure it is read and returned when looking at the
> > class in admin?
> >
> >
> > Thanks,
> >
> > Alan
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-us...@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-us...@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-us...@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.