Re: help with GEOS and PROJ.4 in windows 7

2014-02-16 Thread Sam Lai
Did you try the steps listed in the geodjango documentation,
specifically 
https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#osgeo4w
and the following step to configure the environment? If you did and it
didn't work, what was the error?

On 16 February 2014 05:55, Nicholas Perez  wrote:
> Hello i am trying to install these libraries GEOS and PROJ.4 to use with
> geodjango(according to tutorial on the website). I am new to this so any
> help would be greatly appreciated. i have sqlite3 installed in windows 7 and
> want to use Spatialite but i need these (GEOS and PROJ.4) before proceeding.
> Thank you for your time.
>
> Nicholas Perez
>
> ps: please include proper instructions to install this in windows 7 since
> that is the platform i am currently using. Thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8b8366ed-80c4-4b43-86a4-4a3b155c161b%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABxbXqX2OsFA762%3DvuLUSOZy8f%3DSgid3ddNcygZTsp%2BJ0NaCHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Login at the end of form wizard

2014-02-16 Thread Camilo Torres

On Friday, February 14, 2014 6:30:46 AM UTC-4:30, parnigot wrote:
>
> To work around the problem I’m now trying to include the login form as a 
> step of the wizard view.
>
> But I’ve encountered another problem. How can i login the user after it 
> completed the login step? 
> Does WizardView have a method executed at the end of each step that I can 
> override to do this?
>

See the method:

WizardView.render_goto_step(*step*, *goto_step*, ***kwargs*) 
in
https://docs.djangoproject.com/en/dev/ref/contrib/formtools/form-wizard/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0101d389-e347-4bbb-a7e2-b870af0bb529%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about the send of file versus the django server

2014-02-16 Thread simone monteleone
Hi Russ,

The script is now running in a normal bash shell, where I import the 
DJANGO_SETTINGS_MODULE.

So it's correct to run the script on the machine where the server goes?

Or it's possible (and better) runs the commands inside Django?

Thanks 

SM



Il giorno domenica 16 febbraio 2014 01:21:46 UTC+1, Russell Keith-Magee ha 
scritto:
>
> Hi Simone,
>
> On Sun, Feb 16, 2014 at 2:53 AM, simone monteleone 
> 
> > wrote:
>
>> Hi Russ,
>>
>> My goal is to load the csv file directly in the database.
>>
>> So my idea is define a script containing the follow pseudo-code:
>>
>>  while(1) and receive_csv():
>>
>> value1, value2 = read_csv()
>>
>> MyModel.objects.create(field1=value1, field2=value2) 
>>
>> The script run on the server, ex http://127.0.0.1:8000/admin
>>
>
> Do you want the *file*, or the *data contained in the file*?
>
> Based on the script you've provided, you want the *data*. If so, you don't 
> run a script like this at a URL. You run it at a Python prompt.
>
> When you went through the Django tutorial, the first steps were all done 
> at a prompt. Those commands let you inspect the data that was in the 
> database. You can also use the prompt to *create* data in the database - 
> that's what your script needs to do.
>
> You don't need to upload the script to the server, or write any view code 
> - you're writing a set of commands that you will run at a prompt to open a 
> file, read some data, and write to the database. Then you can start your 
> Django server, and see that data *on* your server.
>  
> Is that more clear?
>
> Yours
> Russ Magee %-)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dd4990c9-11a2-43f6-9454-e1eb7dcdf94d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


caching django querysets, debug toolbar shows queries still running on page load

2014-02-16 Thread Levi McDonough



Hey everyone, I'm having problems with caching a queryset and storing the 
results of the query in the cache so the queries don't run when the page 
loads.  I am caching and pickling the queryset, however I keep just storing 
the query but not the results of the query.

  I've read through the docs several times and still am not getting 
what I need. I am caching and pickling a query set via a management command 
which should be evaluated by django so the query is not executed on page 
load, it should use cached results at the time of the cache object 
creation. But the debug toolbar is showing that the queries are still 
running when the page loads. So I'm assuming I'm just caching the query and 
not the results. Below is my code, any help would be great, I've been stuck 
on this for a few days now... thanks.

management command to generate the cache key, value:

images_query = ImageAssociations.objects.filter(place_id = 
place_id).order_by(-image_score')[:10]

images = pickle.dumps(images_query)  

cache.set('images', images, timeout=)


views.py

  images_cache = cache.get('images')

  images = pickle.loads(images_cache)

  args = {}

  args['images'] = images

  return render_to_response('place.html', args)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/47391c74-890a-43d8-a5e7-6a14b9bb33d1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Creating database in windows

2014-02-16 Thread Vernon D. Cole
Django on Windows is a poor stepchild of the real thing. If you are serious 
about using django then you really need to learn Linux at some point in time. I 
am amazed that something as complex as geodjango will even run in Windows. 
 You have two choices:
Either learn to use Windows command line very well (start with setting 
environment variables such as PATH)...
Or learn Linux commands at an advanced beginner level.

At least think about the second choice. Download Ubuntu and install it on that 
old XP box you have sitting in the closet. Ask the installer to make a 30 G 
byte Linux partition and dual boot. It will grow on you.

Meanwhile, back on Windows, you probably need to add several new folders to 
your search path. Google it.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3579ac61-f140-48e8-868d-1135f47dbcf0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: First tutorial - 404

2014-02-16 Thread Camilo Torres
On Saturday, February 15, 2014 4:41:34 PM UTC-4:30, Steve Booth wrote:
>
> I'm just trying to run through the very first tutorial, and frankly, it's 
> been a nightmare. Running under Fedora 18, Python 2.7, Django version is 
> 1.4.5.
>
> So, I got the 1.4 tutorial up, created the site.. all works fine.  Fire up 
> the server -- looks great.  Browse to http://127.0.0.1:800..
>
> And I do NOT get the nice, blue Django page, I get a Page Not Found 404 
> error telling me the URLconf in mysite.urls does not match '^admin/'
>
> Well... YEA!  So either the 1.4 tutorial doc's are wrong, or the default 
> site doesnt work, or I dont know what I'm doing.
>

You're right!!

How do you installed Django 1.4? did you a 'pip install django==1.4'?

I did installed via pip and gave the same result as yours. That is because 
the version installed via pip have the admin url configured by default. 
Please, edit your mysite/urls.py, and comment line 11 to be like this:

#url(r'^admin/', include(admin.site.urls)),

then reload your page and continue with the tutorial.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3be0804c-a93c-499e-b758-7eba9e057b7b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about the send of file versus the django server

2014-02-16 Thread simone monteleone
In other hand, it's possible to use the Django server to intercept 
a requests?

SM



Il giorno domenica 16 febbraio 2014 15:20:54 UTC+1, simone monteleone ha 
scritto:
>
> Hi Russ,
>
> The script is now running in a normal bash shell, where I import the 
> DJANGO_SETTINGS_MODULE.
>
> So it's correct to run the script on the machine where the server goes?
>
> Or it's possible (and better) runs the commands inside Django?
>
> Thanks 
>
> SM
>
>
>
> Il giorno domenica 16 febbraio 2014 01:21:46 UTC+1, Russell Keith-Magee ha 
> scritto:
>>
>> Hi Simone,
>>
>> On Sun, Feb 16, 2014 at 2:53 AM, simone monteleone wrote:
>>
>>> Hi Russ,
>>>
>>> My goal is to load the csv file directly in the database.
>>>
>>> So my idea is define a script containing the follow pseudo-code:
>>>
>>>  while(1) and receive_csv():
>>>
>>> value1, value2 = read_csv()
>>>
>>> MyModel.objects.create(field1=value1, field2=value2) 
>>>
>>> The script run on the server, ex http://127.0.0.1:8000/admin
>>>
>>
>> Do you want the *file*, or the *data contained in the file*?
>>
>> Based on the script you've provided, you want the *data*. If so, you 
>> don't run a script like this at a URL. You run it at a Python prompt.
>>
>> When you went through the Django tutorial, the first steps were all done 
>> at a prompt. Those commands let you inspect the data that was in the 
>> database. You can also use the prompt to *create* data in the database - 
>> that's what your script needs to do.
>>
>> You don't need to upload the script to the server, or write any view code 
>> - you're writing a set of commands that you will run at a prompt to open a 
>> file, read some data, and write to the database. Then you can start your 
>> Django server, and see that data *on* your server.
>>  
>> Is that more clear?
>>
>> Yours
>> Russ Magee %-)
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3bf8f942-d3fe-432e-8730-a9673ca1eadc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: First tutorial - 404

2014-02-16 Thread Mattia Procopio


Il giorno sabato 15 febbraio 2014 22:11:34 UTC+1, Steve Booth ha scritto:
>
> I've been Googling on this for several hours.  Time to ask.
>
> I'm just trying to run through the very first tutorial, and frankly, it's 
> been a nightmare. Running under Fedora 18, Python 2.7, Django version is 
> 1.4.5.
>
> So, I got the 1.4 tutorial up, created the site.. all works fine.  Fire up 
> the server -- looks great.  Browse to http://127.0.0.1:800..
>
> And I do NOT get the nice, blue Django page, I get a Page Not Found 404 
> error telling me the URLconf in mysite.urls does not match '^admin/'
>
> Well... YEA!  So either the 1.4 tutorial doc's are wrong, or the default 
> site doesnt work, or I dont know what I'm doing.
>
> Any help would be greatly appreciated. 
>
> I shouldn't have to be asking this ... it should just work.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a86c441a-378a-4060-9c0f-d44d7100e528%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Allow the Prefetch queryset to be used with GenericForeignKey

2014-02-16 Thread Robert Kajic
I would love it if the Prefetch object allowed me to pass in custom 
querysets when prefetching related generic foreign fields. Specifically I 
want this in order to call select_related on each subgroup.
For now I've subclassed the GenericForiengKey class, overriding 
get_prefetch_queryset, to allow me to use modelless querysets like this:

.prefetch_related(
Prefetch('obj', queryset=QuerySet().select_related(
"user", "poem__user", "consumer", "producer"
))

In get_prefetch_queryset, for each subgroup, I copy the select_related 
options from the modelless queryset to the subgroup queryset:

qs = ct.get_all_objects_for_this_type(pk__in=fkeys)
# Copy any select related options from queryset to qs
qs = self.combine_select_related(qs, queryset)
ret_val.extend(qs)

Initially I thought I would simply be able to combine the two querysets 
using QuerySet.__or__, but I noticed that Query.combine refuses to run 
unless both queries are on the same model. Would there be any harm in 
allowing it to combine Queries even if the qeries are not on the same 
model, as long as one of the queries doesn't have a model at all? Then the 
above could be changed into:

# Copy any select related options from queryset to qs
qs |= queryset

This would have the added benefit of copying other options other than 
select_related.

I know this is problematic because you may not want to combine the same 
queryset with each individual group. Ideally, the developer would be able 
to specify a different queryset for each group kind.

.prefetch_related(
Prefetch('obj', queryset=QuerySet().select_related(
"user", "poem__user", "consumer", "producer"
))

Does anyone have any thoughts on this? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/07e8c964-2a65-45d4-8fae-d9eef5cb990c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Template tag render method doesn't get called

2014-02-16 Thread stevedegrace
This is a real problem. I have had the same issue, and I have seen several 
other people besides yourself bring this up without getting satisfactory 
answers.

I was having the same problem where __init__ was being called but not 
render, where the purpose of the tag is to insert several variables into 
the context and all it does is return an empty string. I don't know if this 
will work in your context, but it did in mine.

I was using the tag in a child template that extends by base template. I 
put the tag right after the load statement, but, *not within a {% block %}.*

When I put the tag within a block that is rendered, the render method got 
called and problem solved.

On Monday, June 2, 2008 9:54:26 AM UTC-3, Julien wrote:
>
> Similar issues have been raised in [1] and [2], but unfortunately I 
> could not find an answer for this. 
>
> Basically I have a custom template whose 'render' method never gets 
> called (the 'init', however, does): 
>
> class ShowParticipantNode(Node): 
> def __init__(self, participant, edit): 
> self.participant = participant 
> self.edit = edit 
>
> def render(self, context): 
> self.participant = self.participant.resolve(context) 
> request = resolve_variable('request', context) 
> context = {'me': request.user, 'participant': 
> self.participant } 
> if self.edit == 'edit': 
> return render_to_string('projects/units/ 
> participant_edit.html', context) 
> else: 
> return render_to_string('projects/units/participant.html', 
> context) 
>
> def show_participant(parser, token): 
> bits = token.contents.split(' ', 2) 
> if len(bits) > 3 : 
> raise TemplateSyntaxError("'%s' takes at most 2 argument" % 
> bits[0]) 
> if len(bits) == 3: 
> return ShowParticipantNode(parser.compile_filter(bits[1]), 
> bits[2]) 
> else: 
> return ShowParticipantNode(parser.compile_filter(bits[1]), 
> 'display') 
> show_participant = register.tag(show_participant) 
>
>
> Remark: I could not use a simple_tag for this as simple_tag doesn't 
> accept context as argument like inclusion_tag does. 
>
> The template is very simple, only a few lines: 
>
> {% load project_tags %} 
> {% for participant in participants %} 
> {% show_participant participant %} 
> {% endfor %} 
>
>
> The threads [1] and [2] mention inheritance, but I don't know if that 
> apply to my case. Do you know what I could do to troubleshoot this? 
>
> Thanks a lot! 
>
> Julien 
>
> [1] 
> http://groups.google.com/group/django-users/browse_thread/thread/4501aa624159b17d/1c363af87856a551
>  
> [2] 
> http://groups.google.com/group/django-users/browse_thread/thread/764df4d9a5b1dcc5/419fe0d904609e19

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f34c0806-da09-41a8-9070-0b2ca193e940%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about the send of file versus the django server

2014-02-16 Thread Russell Keith-Magee
On Sun, Feb 16, 2014 at 10:20 PM, simone monteleone wrote:

> Hi Russ,
>
> The script is now running in a normal bash shell, where I import the
> DJANGO_SETTINGS_MODULE.
>
> So it's correct to run the script on the machine where the server goes?
>
> Or it's possible (and better) runs the commands inside Django?
>
> You're missing my point - there's no such thing as "inside Django".
Logging onto the server and running the script is the right way to do what
you are describing.

A running Django web server isn't a "place" you can run code - it's
essentially just a way to turn http://myservice.com into a function call
that returns a web page. Requests is just a tool for using a Python script
to generate HTTP requests.

Yes, you can use requests to connect to a Django web server. However, if
you're in control of the web server, using requests to do what you
describe, instead of just logging onto the server and running a script
directly is a bit like saying "I'm going to pick up the cup that is sitting
on that table using a fishing rod". Yes, you can probably do it, but unless
you've got a good reason, it's much easier to just walk over and pick up
the cup with your hand.:-)

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq84-1ySH__CsrBqw9%2B0Bo031iMOkT%2BWVv5n1HdRN1DCk7sQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Digging Up Django Class-based Views

2014-02-16 Thread Frankline
Hi Leo,

I have struggled to understand CBVs before and avoided using them most of
the time. I looked into your posts and it has been very useful. Written in
clear simple English. Now I can't wait to use them in my current and next
projects.

:-)

Thank you.

Frank


On Fri, Feb 14, 2014 at 4:11 PM, Leonardo Giordani <
giordani.leona...@gmail.com> wrote:

> Hi all,
>
> the third issue of the small series "Digging Up Django Class-based Views"
> is out.
> This latest post is about form views.
>
> You find the whole series here
>
> http://lgiordani.github.io/blog/categories/django/
>
> I hope you will find it interesting and useful.
>
> Cheers,
>
> Leo
>
>
> Leonardo Giordani
> Author of The Digital Cat 
> My profile on About.me  - My GitHub
> page  - My Coderwall 
> profile
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEhE%2BO%3Db8ApXRSwLEmMXf%3D_XMtRDv78uZO-SMr1jzcUQuYsqjw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEAUGdWD2mHe3R50TXXwXe5qGOgWwvZaROde3TmViXw4%2B%3DF2hg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.