Re: Confused with django model Limit and Offset Implementation

2012-01-23 Thread Daniel Roseman
On Monday, 23 January 2012 04:40:31 UTC, Swaroop Shankar wrote:
>
> Hi,
> Am trying to create a custom pagination for my project, but am seriously 
> struck with the django implementation of Limit and offset. I went through 
> the documents, instead of making me understand how it works, i ended up 
> more confused. So suppose I have a page limit of 3 records per page and if 
> i want to load the second set of records how should the following statement 
> be?
>
> Data = NewsFeedStory.objects.order_by('-updated_on')[?:?]
>
> and similarly if i want to load the 3rd set with same page limit, how 
> should the same statement be? I played with the django shell to figure out 
> how this works but am still confused. Please help.
>
> Thanks and Regards,
>
> Swaroop Shankar V
>
>
I'm not sure why this should confuse you. You seem to have correctly 
understood the syntax. 

This is just normal Python slicing, which Django transforms into LIMIT and 
 OFFSET. So, remembering that Python slicing is 0-based and the lower bound 
is inclusive but the upper is exclusive, the first page is [:3], the second 
page is [3:6], the third is [6:9], etc.

Note, however, that if you're doing pagination, you should really be using 
the built-in Paginator class [1], which calculates all this for you given a 
page number, rather than doing it yourself.

 [1]: https://docs.djangoproject.com/en/1.3/topics/pagination/
--
DR.

-- 
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/-/NDDsTmr8iDoJ.
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 is the best IDE to use for Python / Django

2012-01-23 Thread Sandro Dutra
The best IDE is that you fell comfortable using it.

2012/1/21 goosfancito :
> El 21/01/12 08:52, kenneth gonsalves escribió:
>
>> On Sat, 2012-01-21 at 03:34 -0800, John Yeukhon Wong wrote:
>>>
>>> While it has been asked a trillion times already, let me say TRY UT
>>> YOURSELF.
>>
>> you were requested not to feed this thread. If the OP cannot search,
>> here it is:
>>
>> http://duckduckgo.com/?q=site%3Agroups.google.com%2Fgroup%2Fdjango-users
>> +python+IDE
>
> i used gedit only.
>
>
> --
> 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: Joining tables

2012-01-23 Thread Arun P
@bruno

Dint know that you can do lookups from OneToOne related models

Thanks

On Mon, Jan 16, 2012 at 8:00 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On Jan 16, 8:04 am, Arun P  wrote:
> > Does this work?
> >
> > info =
> >
> ExtraInformation.objects.filter(user__is_active=1,user__is_staff=0,user__is_superuser=0).order_by("popularity").select_related("user")
> >
> > users = map(lambda i: i.user, info)
>
>
> That was for the "uselessly complicated and memory-hungry" method. Now
> for the "simple lazy" method:
>
> => users = User.objects.filter( here>).order_by("extrainformation__popularity")
>
> @OP : You can add a select_related if you plan on using data from
> ExtraInformation so you save on useless queries.
>
> --
> 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.
>
>


-- 
Digitally,
Arun Prabhakar 


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



Somebody please attend to me

2012-01-23 Thread coded kid
 Please how can I get user post update, make their friends comment and
share the update in django? Just like the way FB update is. I hope you
get my point?  Thanks so much

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



Re: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-23 Thread Sam Lai
On 23 January 2012 15:22, JJ Zolper  wrote:
> Hello everyone,
>
> I was able to install Django to my machine and before I was using the
> command prompt. Django's path is in my Windows 7 64 bit Enterprise
> Environment variable. Python worked fine as well too. I also installed
> IPython because I heard it was useful but I haven't tried that yet.
> Everything has been good so far. I would like some input on what I am
> currently trying now.
>
> I have gone ahead and installed IronPython. I already had Visual Studio 2010
> on my computer so I was using that. I also installed Python Tools for Visual
> Studio. As I mentioned before I already have Python 2.7.2 installed.
>
> I was able to see the image/window in step 3
> here: http://pytools.codeplex.com/wikipage?title=Installation%20-%20details&referringTitle=Home
>
> It shows the options pane for Python Tools for Visual Studio. I was able to
> see that PT4VS (Python Tools for Visual Studio) was correctly including the
> location of the Python install at C:/Python27/python.py. Everything looked
> good there as it seems that Python was incorporated into PT4VS. I was trying
> to continue through the tutorial but I was having problems. I tried this
> command: python manage.py runserver but I only recieved a traceback error.

You've left out the most important bit - the actual traceback error. What is it?

If it can't find something, then it could be a PYTHONPATH issue.
Google tells me PT4VS may not support the usual way modules are
discovered (http://pytools.codeplex.com/discussions/254602), although
that should affect IronPython only, and not CPython (possibly
intellisense as well).

Inside PT4VS, in the interactive window, type in the following and
paste the result -

import sys
print sys.path

> Additionally in PT4VS there is a field for a startup script. I wrote one and
> here it is:
>
> import os
> import IPython
> import django
> os.chdir('c:\\MTDevelopment\\Django\\newartists')
>
> This so that I could change my directory to where my startproject was set
> with all the django web framework files. Also to import IPython and django
> as you see here. That seemed to work as I anticipated.

This smells like a hack. Your default working directory should already
be the directory your app is in. If it isn't, you need to check your
project settings (you are using a Python VS project right?).

> What I am asking you is why am I not able to get the full power of Django?
> In my command prompt I wasn't inside the python interpreter and ran the
> Django commands and everything worked fine. However, I was under the
> impression that with a Python interpreter in VS that I could have everything
> come in in a start up script and just go on my way coding with Django having
> set the directory to the location of my startproject?
>
> When I type: django and IPython into my PT4VS now I see:
>
 IPython
>  'C:\Python27\lib\site-packages\ipython-0.11-py2.7.egg\IPython\__init__.pyc'>
 django
>  'C:\Python27\lib\site-packages\django-1.3.1-py2.7.egg\django\__init__.pyc'>
>
> so it is imported it correctly I think but I'm not able to use it. I've been
> working hard on teaching myself how to get all this set up and any help from
> you all would make my time working on this a lot easier!
>
> Thanks so much,
>
> JJ Zolper
>
> --
> 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/-/P5AJ334Yr8YJ.
> 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.



ANN: Two-Step Authentication with Django

2012-01-23 Thread Nuno Maltez
django-twostepauth is a Django application that allows user authentication
with two steps for  additional security. The first step with username
and password and the
second step with a one-time code such as the codes generated by soft
token devices like
Google Authenticator.

Features:

* Authentication with TOTP (Time-Based One-Time Password)
* Authentication HOTP (HMAC-Based One-Time Password)
* Support for the login in the admin site
* Selective activation of two-step for the admin site, the main site or both
* Support for authentication backup codes
* Automatic adjustment for clock synchronization issues

It comes with an example project that shows how to use in a site and
also how to integrate with django-registration and
django-profiles.

We've released the code at
https://bitbucket.org/cogni/django-twostepauth

an it's also at pypi:
http://pypi.python.org/pypi/django-twostepauth


Quick demo video:
http://youtu.be/-vXcZKzGXl0

Hope this is useful to someone. Feedback deeply appreciated.

Cheers

-- 
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: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

2012-01-23 Thread bruno desthuilliers
On Jan 21, 6:31 pm, Chris Seberino  wrote:
> On Jan 21, 6:44 am, Tom Evans  wrote:
>
> > Models are representations of rows in a database.
> > Deleting a model instance implies removing a row from a database.
> > Model instances have an id attribute which denotes their row in the 
> > database.
> > Models whose id is None don't exist in the database, and so it is
> > nonsense to delete them - they don't exist.

This should read "they don't exist _in the database_" - a model
instance is not a database row, it's a python object. The database row
only exists if and when the model instance has been saved, and until
the database row is deleted.

> That makes perfect sense but then why do these zombie id=None objects
> show up?

That's one question... And I don't have the answer.

> *WHERE* are they living if not in the database?  Does the Django shell
> somehow have a secondary storage area for this zombie id=None object
> stuff I can delete somehow?

And that's another question, which has a very simple answer: model
instances live in your python process (django's dev server, wsgi
process, custom management command, django shell or whatever). If you
fire a django shell, import your model class and instanciate it
directly and don't save it you will have a model instance with no id
(assuming you're using the auto id field which is the default).


-- 
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: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

2012-01-23 Thread bruno desthuilliers


On Jan 22, 1:34 pm, akaariai  wrote:
> There is still the possibility that you really have a row where the PK
> is somehow null.

Very unlikely given the model definition, but well, sh*t happens.

-- 
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: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

2012-01-23 Thread bruno desthuilliers
On Jan 22, 12:39 am, Chris Seberino  wrote:
> On Jan 21, 2:43 pm, JohnA  wrote:
>
> > How are you finding these objects?  That might point to the answer.
>
> > Probably the likeliest explanation is that you are creating the
> > objects but not saving them.
>
> In the Django shell I do
>
> quests = Question.objects.all()
> quests[579].delete()
>
> Why does the objects.all() invocation add this id=None

No reason it should do this, and I really doubt this is the case -
unless you're using a (broken) custom Manager you didn't mention when
you posted your model definition.


> to quests list?

"quests" is not a list, it's a QuerySet (https://
docs.djangoproject.com/en/1.3/ref/models/querysets/).

-- 
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 is the best IDE to use for Python / Django

2012-01-23 Thread Mario Gudelj
I've used gedit, sublime text 2, emacs, vi, but the best Django IDE by far
is PyCharm. I'm seriously amazed at how awesome it is. It's worth every
cent.

On 23 January 2012 22:20, Sandro Dutra  wrote:

> The best IDE is that you fell comfortable using it.
>
> 2012/1/21 goosfancito :
> > El 21/01/12 08:52, kenneth gonsalves escribió:
> >
> >> On Sat, 2012-01-21 at 03:34 -0800, John Yeukhon Wong wrote:
> >>>
> >>> While it has been asked a trillion times already, let me say TRY UT
> >>> YOURSELF.
> >>
> >> you were requested not to feed this thread. If the OP cannot search,
> >> here it is:
> >>
> >>
> http://duckduckgo.com/?q=site%3Agroups.google.com%2Fgroup%2Fdjango-users
> >> +python+IDE
> >
> > i used gedit only.
> >
> >
> > --
> > 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.



Mediawiki access with Django

2012-01-23 Thread krumru...@googlemail.com
Hello,

I use mediawiki as semantic wiki for saving articles from newspapers
and journals. Now I want to write a Django application for better
handling all functions. Are there expiriences in this group for the
access to mediawiki with Django? For the access I want to use the
pywikipedia framework.

Thanx in advance for your answers
Karsten

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



Debug = false ruins template

2012-01-23 Thread Krondaj
Hi,

After going through to tutorial 3 there is a little bit about setting
DEBUG = False to redirect the the 404.html.

I have set this, but now the template from  the tutorials (also in /
admin/) has changed and is not as 'pretty' or well laid out as before.

Can someone tell me what has happened and how should this be
rectified?

Regards,

Chris

-- 
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 is the best IDE to use for Python / Django

2012-01-23 Thread yati sagade
I think someone has already requested NOT to reply to this thread anymore.
Please STOP replying people.

On Mon, Jan 23, 2012 at 6:05 PM, Mario Gudelj wrote:

> I've used gedit, sublime text 2, emacs, vi, but the best Django IDE by far
> is PyCharm. I'm seriously amazed at how awesome it is. It's worth every
> cent.
>
>
> On 23 January 2012 22:20, Sandro Dutra  wrote:
>
>> The best IDE is that you fell comfortable using it.
>>
>> 2012/1/21 goosfancito :
>> > El 21/01/12 08:52, kenneth gonsalves escribió:
>> >
>> >> On Sat, 2012-01-21 at 03:34 -0800, John Yeukhon Wong wrote:
>> >>>
>> >>> While it has been asked a trillion times already, let me say TRY UT
>> >>> YOURSELF.
>> >>
>> >> you were requested not to feed this thread. If the OP cannot search,
>> >> here it is:
>> >>
>> >>
>> http://duckduckgo.com/?q=site%3Agroups.google.com%2Fgroup%2Fdjango-users
>> >> +python+IDE
>> >
>> > i used gedit only.
>> >
>> >
>> > --
>> > 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.
>



-- 
Yati Sagade 

(@yati_itay )

-- 
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: Setting Network settings from Python/Django

2012-01-23 Thread yati sagade
Hi Ganesh
Why do you want to do it with Django? You can go about building a light GUI
in python that accomplishes your task, but, again, since you say the
system's embedded, I don't know what libraries are you willing to put on
it. Also, it will require the Python runtime to be installed. That said,
this  might help.

Cheers!


On Sun, Jan 22, 2012 at 2:50 PM, Ganesh Kumar  wrote:

> Hi guys
>
> I'm working on a simple web interface for an embedded computer. The
> computer will ship with a static default ip that will then need to be
> updated by the install tech who may not be tech/linux savvy.
>
> Basicly I need to change the following system settings from a Django app.
>
>1. IP Addres
>2. Subnet
>3. Default Gateway
>4. DNS Servers 1&2
>
> I realize that I can could just overwrite the config files in linux but I
> was wondering if there is a more "Python" way of doing it.
>
> I want any ready to use module is there, please guide me.
>
>
> -Ganesh.
> Did I learn something today? If not, I wasted 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.
>



-- 
Yati Sagade 

(@yati_itay )

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



Re: How can I go about this?

2012-01-23 Thread yati sagade
Hi
You should probably start off by doing some homework and studying other
such systems which atleast partially implement what you want - I have done
a Twiiter clone with Django/MongoDB-Mongoengine
here.
Then, read up on the Django comments framework and I'm sure you'll pull it
off.
And be sure not to re-invent the wheel - use what's already been done!

Cheers!
Yati Sagade

On Sun, Jan 22, 2012 at 2:14 PM, coded kid  wrote:

> Thanks for the reply. I don't really mean twitter clone, just want
> want users to post update, so their friends can comment, and reshare
> the post. And it will be build in django.
>
> Donald Casson wrote:
> > This is a very open ended question.  There are many different ways in
> which you could achieve the same thing.
> >
> >
> > Just offering a suggestion here:
> >
> > I would take a read through the retwis docs, although it is php and
> redis it should give you enough of an understanding on how to implement
> some of the ideas in django.
> >
> > http://redis.io/topics/twitter-clone
> >
> > Cheers
> > Don
> >
> >
> >
> > On 22/01/2012, at 6:11 PM, coded kid wrote:
> >
> > > Hey guys, please I want you to give me a brief on how I can go about
> > > making users post status update for their friends to see. Just like
> > > how its been done on twitter. Where you tweet whats happening and
> > > after tweeting its will display your status with reply, retweet and
> > > favourite button below. Hope you get my point?
> > >
> > > --
> > > 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.
>
>


-- 
Yati Sagade 

(@yati_itay )

-- 
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: Debug = false ruins template

2012-01-23 Thread Martin J. Laubach
  Probably you are not serving your static files any more as the built-in 
staticfiles app only works in debug mode (that's a feature).

mjl

-- 
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/-/58dc9Hpj0_8J.
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 .po files for RTL languages

2012-01-23 Thread Ryan
I'm needing to translate several Django sites/apps into arabic (a
Right-To-Left language) and I'm having difficulty editing the .po
files when the message to translate contains Left-To-Right variables
or HTML markup.

Whether I'm using TextMate, TextWrangler or poedit, if I'm editing a
translation it correctly has the text RTL, but it also turns any
variables/markup RTL when it needs to stay LTR.

For example, I get this:

verbose_name)s)% تم تحديثه بنجاح.

When it needs to be this:

%(verbose_name)s تم تحديثه بنجاح.

Similar problem if I need to do something like have a  or 
tag around a piece of text in the translation file. As I type the LTR
HTML tags in the RTL text it tries to make the tags RTL too.

It looks like Django's arabic translation file [1] has variables LTR,
so I'm curious what editor the Django arabic translators are using,
what fixes I need for poedit or what I'm doing wrong when I edit.

>From Googling around, I did see a poedit issue logged a few years ago
[2], but they said it's a native control issue, which might explain
why I see this same behavior in every Mac OS X editor I've tried thus
far.


[1] 
http://code.djangoproject.com/svn/django/trunk/django/conf/locale/ar/LC_MESSAGES/django.po
[2] http://www.poedit.net/trac/ticket/296

-- 
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: Mediawiki access with Django

2012-01-23 Thread Brett Epps
MediaWiki has a pretty nice HTTP API that you can use to access content
stored within it.  I've used that API with the wikitools Python package
and it worked pretty well.

Brett


On 1/23/12 7:35 AM, "krumru...@googlemail.com" 
wrote:

>Hello,
>
>I use mediawiki as semantic wiki for saving articles from newspapers
>and journals. Now I want to write a Django application for better
>handling all functions. Are there expiriences in this group for the
>access to mediawiki with Django? For the access I want to use the
>pywikipedia framework.
>
>Thanx in advance for your answers
>Karsten
>
>-- 
>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: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-23 Thread JJ Zolper
Here is the error:

>>> python manage.py runserver
  File "", line 1
python manage.py runserver
^
SyntaxError: invalid syntax
>>> 


You've left out the most important bit - the actual traceback error. What 
is it?

If it can't find something, then it could be a PYTHONPATH issue.
Google tells me PT4VS may not support the usual way modules are
discovered (http://pytools.codeplex.com/discussions/254602), although
that should affect IronPython only, and not CPython (possibly
intellisense as well).

Inside PT4VS, in the interactive window, type in the following and
paste the result -

import sys
print sys.path



I'm not too familiar with these things yet. Are you saying CPython might be 
better if I want to work in Visual Studio with the setup I am trying?



Here is the response to


import sys
print sys.path 

it is:

>>> import sys
... 
>>> print sys.path
['c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE', 
'C:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg', 
'C:\\Python27\\lib\\site-packages\\ipython-0.11-py2.7.egg', 
'C:\\Python27\\lib\\site-packages\\django-1.3.1-py2.7.egg', 
'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 
'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 
'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 
'C:\\Python27\\lib\\site-packages', 'c:\\Program Files (x86)\\Microsoft 
Visual Studio 10.0\\Common7\\IDE\\Extensions\\Microsoft\\Python Tools for 
Visual Studio\\1.1', 
'C:\\Python27\\lib\\site-packages\\ipython-0.11-py2.7.egg\\IPython\\extensions']


This smells like a hack. Your default working directory should already
be the directory your app is in. If it isn't, you need to check your
project settings (you are using a Python VS project right?). 


Well I have no idea how I am hacking here...
But I didin't start a new project just through visual studio. I had already 
within the cmd prompt run the "startproject" command naming "mysite" to be 
"newartists." That was done at an earlier time so I just wanted to move to 
that directory within the python interpreter

Well I didn't use a Python VS project because the files were already 
created but if I start a new Python file I'll most likely just pick my 
options within Visual Studio. That would make the most sense.

Thanks,

JJ Zolper

-- 
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/-/94xoFRPnfRAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-23 Thread Andre Terra
the >>> indicates you are IN a python shell, which is different from your
OS prompt. Try exiting the shell first (with exit()) and then run "python
manage.py runserver" from a command prompt or terminal window.


Cheers,
AT

On Mon, Jan 23, 2012 at 4:11 PM, JJ Zolper  wrote:

>
> >>> python manage.py runserver
>   File "", line 1
> python manage.py runserver
> ^
> SyntaxError: invalid syntax
> >>>
>

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



Re: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-23 Thread JJ Zolper
For sanity purposes I removed my "hack" or start up script that had "import 
django" and "import IPython"

Here it is:

>>> import sys
>>> sys.path
['c:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE', 
'C:\\Python27\\lib\\site-packages\\setuptools-0.6c11-py2.7.egg', 
'C:\\Python27\\lib\\site-packages\\ipython-0.11-py2.7.egg', 
'C:\\Python27\\lib\\site-packages\\django-1.3.1-py2.7.egg', 
'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 
'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 
'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 
'C:\\Python27\\lib\\site-packages', 'c:\\Program Files (x86)\\Microsoft 
Visual Studio 10.0\\Common7\\IDE\\Extensions\\Microsoft\\Python Tools for 
Visual Studio\\1.1']
>>> 

It looks like in both cases Django is included but I'm still not convinced 
that everything is right because in the windows command prompt I am able to 
start my server like a charm but in Visual Studio I don't think I can 
really do anything.

Are you not able to run Django commands from the Python prompt? That 
probably sounds stupid but to be honest I think the only time I can run 
Django commands is when I'm outside the Python interpreter in just the 
command prompt of Windows.

JJ Zolper

-- 
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/-/64kazlpsOksJ.
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: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

2012-01-23 Thread Petr Přikryl

I am a Django novice, so only a wild guess based on my Python knowledge...
 
> In the Django shell I do
> 
> quests = Question.objects.all()
> quests[579].delete()
> 
> Why does the objects.all() invocation add this id=None crud
> to quests list?
 
Are you sure that you have 580 items in the container?
A Django program is to be executed at the web server side.
Therefore, it is desirable that the program does not crash
very easily.  Search for the information on how the quests
is implemented.  It is likely that it is not a "normal", strict
container that react by raising the exception.  Returning
the special objects for the range outside the real data space
may be a good way to let you test further if the object really
exist.  My guess is that you do not have that many object.
(But I may be completely wrong ;)
 
Petr

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



High cpu usage for wsgi apache processes

2012-01-23 Thread TINO THOMAS
Hello,

I have a Django setup on cpanel  server with python 2.7, virtual env and
mod_wsgi. I can see that cpu usage is high for these wsgi apache processes.
Is there any way to control this behavior ?


Regards
Tino

-- 
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: High cpu usage for wsgi apache processes

2012-01-23 Thread Andre Terra
Hello,

Unless you tell us what your app is supposed to be doing, there's very
little chance any of us can offer any real help.


Cheers,
AT

On Mon, Jan 23, 2012 at 5:47 PM, TINO THOMAS  wrote:

> Hello,
>
> I have a Django setup on cpanel  server with python 2.7, virtual env and
> mod_wsgi. I can see that cpu usage is high for these wsgi apache processes.
> Is there any way to control this behavior ?
>
>
> Regards
> Tino
>
> --
> 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: I need help with Python Tools for Visual Studio 2010 and Django

2012-01-23 Thread JJ Zolper
Yes I knew I was in the Python shell I just never saw anything that 
described you couldn't make Django commands within the Python interpreter. 
I mean it is based on Python isn't it? That's where I thought logically you 
could make Django calls from in Python?

SO

Is your best advice to have a OS prompt open in tandem with my Visual 
Studio Python Interpreter open? That being said that would be the best 
solution given my situation I suppose. However within the interpreter 
Python Tools for VS there may be limitations. That is what I've heard at 
least. I'm just referring to the interactive intellisense I think?.. 

Thank you for the tip on starting my server Andrew I will surely exit the 
Python interpreter and use a prompt!

JJ Zolper

-- 
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/-/y2Pz2JDeEo0J.
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: Mediawiki access with Django

2012-01-23 Thread krumru...@googlemail.com
Thanx for the answer. I´ll try the wikitools package.

Karsten

On 23 Jan., 18:04, Brett Epps  wrote:
> MediaWiki has a pretty nice HTTP API that you can use to access content
> stored within it.  I've used that API with the wikitools Python package
> and it worked pretty well.
>
> Brett
>
> On 1/23/12 7:35 AM, "krumru...@googlemail.com" 
> wrote:
>
>
>
>
>
>
>
> >Hello,
>
> >I use mediawiki as semantic wiki for saving articles from newspapers
> >and journals. Now I want to write a Django application for better
> >handling all functions. Are there expiriences in this group for the
> >access to mediawiki with Django? For the access I want to use the
> >pywikipedia framework.
>
> >Thanx in advance for your answers
> >Karsten
>
> >--
> >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.



retrieve model instance from database without model instance

2012-01-23 Thread brian
How do I retrieve a model instance from the database without a model
instance?

For example from the doc[1] it has:
  product = Product.objects.get(name='Venezuelan Beaver Cheese')

I want something like getInstance( 'Product',  'Venezuelan Beaver
Cheese' )

Here are the details of what I'm doing.  I have multiple form models
that are all handled by the same post processing class.  I'm using
django-celery to do the processing.

I want to do something like this in my view:
  dbSave = form.save()
  processTask.delay('Product', dbSave.pk)

Then in the task:
 class processTask(Task):
def run(self, modelName, pk):
instance =  getInstance( modelName, pk )
….

>From what I've read about django-celery, I shouldn't pass class
instances to the task so I need a way to pass/retrieve this info via
basic datatypes.

Brian


[1] 
https://docs.djangoproject.com/en/dev/ref/models/instances/#updating-attributes-based-on-existing-fields

-- 
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: retrieve model instance from database without model instance

2012-01-23 Thread Brett Epps
Check out the content types framework[1].

You can do something like:

ct = ContentType.objects.get(app_label='products', model='product')
obj = ct.get_object_for_this_type(name='Venezuelan Beaver Cheese')

However, as you can see in the example, you'll need to know the name of
the app so that Django knows where to find your model.

1. https://docs.djangoproject.com/en/1.3/ref/contrib/contenttypes/

Brett


On 1/23/12 3:15 PM, "brian"  wrote:

>How do I retrieve a model instance from the database without a model
>instance?
>
>For example from the doc[1] it has:
>  product = Product.objects.get(name='Venezuelan Beaver Cheese')
>
>I want something like getInstance( 'Product',  'Venezuelan Beaver
>Cheese' )
>
>Here are the details of what I'm doing.  I have multiple form models
>that are all handled by the same post processing class.  I'm using
>django-celery to do the processing.
>
>I want to do something like this in my view:
>  dbSave = form.save()
>  processTask.delay('Product', dbSave.pk)
>
>Then in the task:
> class processTask(Task):
>def run(self, modelName, pk):
>instance =  getInstance( modelName, pk )
>Š.
>
>From what I've read about django-celery, I shouldn't pass class
>instances to the task so I need a way to pass/retrieve this info via
>basic datatypes.
>
>Brian
>
>
>[1] 
>https://docs.djangoproject.com/en/dev/ref/models/instances/#updating-attri
>butes-based-on-existing-fields
>
>-- 
>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: A problem with a solution, but is it the right one?

2012-01-23 Thread Derek
That sounds very interesting, Jeff - please post the link here.

On Jan 20, 3:47 pm, Jeff Heard  wrote:
> Yeah, I started doing that after I posted...  Thanks for the advice.  I'll
> be posting this code up on GitHub in a few days, as it's part of a
> reasonably complete implementation for Django of ISO 19142, Open Geospatial
> Consortium's Web Feature Service.
>
> -- Jeff
>
> On Fri, Jan 20, 2012 at 7:30 AM, francescortiz wrote:
>
>
>
>
>
>
>
> > I would pass bound data instead of calling from_request:
>
> >https://docs.djangoproject.com/en/dev/ref/forms/api/#ref-forms-api-bo...
>
> > This way you don't have to worry about forms logic, but just about
> > filling the default data.
>
> > Francesc
>
> > On Jan 18, 8:42 pm, Jeff Heard  wrote:
> > > My basic problem is this: I have multiple kinds of requests that come in,
> > > and some of them share parameters and valid values and default values. I
> > > cannot expect my users to pass all form values on the URL line, but
> > > unpassed parameters must be set to appropriate defaults, not merely None.
>
> > > These shared parameter sets are broken out into separate RequestForm
> > > classes, but I also wanted to put the parsing and default values into
> > those
> > > classes. So I came up with the "from_request" method, which I put into
> > each
> > > RequestForm subclass and created a class method called "create" in
> > > RequestForm that class every class in cls.mro()'s from_request method
> > > independently, then calls .clean() on the form to validate it.
>
> > > Another caveat is that I must shadow the request.GET dictionary with a
> > > case-insensitive dictionary, which I take care of in the
> > > django.views.generic.View.dispatch() method.
>
> > > The code for my proposed solution is here:
>
> > >http://dpaste.com/hold/689872/
>
> > > Does this make sense to people?  Sorry to kind of flood the list with
> > this
> > > problem all day in different forms, but i think I'm close to having
> > > something I like.
>
> > > -- Jeff
>
> > --
> > 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.