Re: Affordable Django hosting solution in India/around?

2012-06-25 Thread Kartik Singhal
Thanks for all your answers. My response inline:

On Mon, Jun 25, 2012 at 6:35 PM, Phang Mulianto  wrote:

> Afforadble / cheap is relative variable there in my opinion. you mention
> 8$ / month stil expensive and unaffordable for you.
> in other country it is cheap (us).
>

I was actually referring to Web Faction with that price range -
http://www.webfaction.com/services/hosting - any ideas regarding this?


> better way you lease a vps and join with other fellow there to share the
> resource and split the payment.
>

Yes, I am considering this option though it's difficult to find people
interested in this. I will try anyhow.

On Tue, Jun 26, 2012 at 1:27 AM, Babatunde Akinyanmi 
 wrote:

> Alwaysdata(.com) offers free hosting but its shared hosting


I checked it up but 10 MB is too limiting for even basic needs.


On Tue, Jun 26, 2012 at 2:56 AM, Kurtis Mullins wrote:

> Just go with Amazon Web Services. You get a year for free on their
> lightest server. The only minor issue is you have to set it up yourself --
> but that's really not difficult to do.
>

AWS seems like a good option as both Kurtis and Phang point out. I am also
considering GAE but apparently for that we will need to rewrite most of the
code to fit their data storage model, can anybody shed some light on this?


> There are times when certain hosting providers do help out legitimate
> not-for-profit organizations. You can try looking into that, as well.
>

Yes, this is true, while inquiring with one web host in India, they agreed
to offer straight 20-30% discount but still their VPS-based plans were out
of reach for us.

If nothing else works out our last option will be to host in college
servers, but that involves additional headache being unreliable.

-- 
Kartik
http://k4rtik.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.



Re: setting up django with virtualenv on windows7

2012-06-25 Thread Jani Tiainen

26.6.2012 0:39, Dan Johnson kirjoitti:

On 06/25/2012 03:12 PM, mymlyn wrote:

i started a topic on stackoverflow, analysing responses on SO, on
similar topics, im not really sure wether ill get any feedback there
so im gonna try here :) described my problem here:
http://stackoverflow.com/questions/11193905/setting-up-django-with-virtualenv-on-windows7/


could any1 explain to me why isnt this working? //or how is this
supposed to work if everything was ok


import django
django.__path__
should return to you where it is installed. Check to make sure that it
is installed inside the virtualenv. I've noticed that sometimes under
windows I need to activate and deactivate the instance for pip to work
correctly, not sure why.



I've never needed to do anything extra. One thing that happens is that 
standard windows command prompt happens to bound .py(w) extensions to 
use python from c:\python27\ directory and not ones within virtualenv.


See more in my blog entry how I and my team has done it:
http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: Render time

2012-06-25 Thread Andy McKay
> Now they want me to add to that how long
> the browser takes to render the page after it gets the data.

You can use the navigation timing API:

https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html

We use this in conjuction with graphite and django-statsd to produce
graphs of hour long our sites takes to render.

http://blog.mozilla.org/webdev/2012/01/06/timing-amo-user-experience/

And some more links:

https://github.com/andymckay/django-statsd
http://django-statsd.readthedocs.org/en/latest/#front-end-timing-integration
http://graphite.wikidot.com/

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.



Does UserProfile any changed in new version ?

2012-06-25 Thread yillkid
Hi all !

When I use UserProfile/UserCreationForm in Django 1.1, 
everything is OK!

But in Django 1.4,
seems I can not hook my User Profile in Django User model,
when my UserProfile register into admin.site, 
I need reload the browser 2nd times or error message will be show:
http://paste.ideaslabs.com/show/cWfqG0H7NW

my models.py source:
http://paste.ideaslabs.com/show/Pu29BuYwMN

It seems associated with this issue ? 
But I can not commit out "admin.autodiscover()", I can't follow it's 
solution .
http://osdir.com/ml/DjangoUsers/2009-07/msg00090.html


-- 
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/-/LkgdYjh8338J.
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: Logout- Back Button

2012-06-25 Thread Sajja1260
hi all,
i'm also facing the same problm... can any one help me


thanks in advance 

On Friday, 28 November 2008 14:35:48 UTC+5:30, jai_python wrote:
>
> Any possible to clear browser cache alone using javascript? it ill 
> help to solve this back button problem.

-- 
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/-/ScJMuc2vaR4J.
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 up django with virtualenv on windows7

2012-06-25 Thread Dan Johnson

On 06/25/2012 03:12 PM, mymlyn wrote:

i started a topic on stackoverflow, analysing responses on SO, on
similar topics, im not really sure wether ill get any feedback there
so im gonna try here :)  described my problem here:
http://stackoverflow.com/questions/11193905/setting-up-django-with-virtualenv-on-windows7/

could any1 explain to me why isnt this working? //or how is this
supposed to work if everything was ok


import django
django.__path__
should return to you where it is installed.   Check to make sure that it 
is installed inside the virtualenv.  I've noticed that sometimes under 
windows I need to activate and deactivate the instance for pip to work 
correctly, not sure why.


--
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: Userena configuration

2012-06-25 Thread Bastian
The part about the terms of service is easy, just override that view's form 
in the urls:

from userena.forms import SignupFormTos

urlpatterns = patterns('',
url(r'^accounts/signup/$','userena.views.signup', {'signup_form': 
SignupFormTos}),
url(r'^accounts/', include('userena.urls')),
)

Now I'm going to try what Kurtis suggests about the privacy part.

On Sunday, June 24, 2012 11:45:56 PM UTC+2, Bastian wrote:
>
> Hi,
>
> I just installed Userena and it works fine. I would like to use the signup 
> form where the button for the terms of service appear but I can't find how. 
> And also when editing a user profile, there is a field called privacy, it 
> does not really make sense in my case so I set it up to default to Closed 
> but now I would like it to disappear from the editable fields in the 
> profile, how can I do that?
>
> Thanks for your help.
>

-- 
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/-/hh4KkTXsyQkJ.
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: Affordable Django hosting solution in India/around?

2012-06-25 Thread Kurtis Mullins
Just go with Amazon Web Services. You get a year for free on their lightest
server. The only minor issue is you have to set it up yourself -- but
that's really not difficult to do.

By the way, $8/month is incredibly little to pay. I guess in India that
might be more money than it is here -- but just remember you get what you
pay for. Also, you may have better luck in India with hosting at a better
cost since the electricity to host a site here would be way more than that.

There are times when certain hosting providers do help out legitimate
not-for-profit organizations. You can try looking into that, as well.

On Mon, Jun 25, 2012 at 3:57 PM, Babatunde Akinyanmi
wrote:

> Alwaysdata(.com) offers free hosting but its shared hosting
>
> On 6/25/12, Phang Mulianto  wrote:
> > Hi,
> >
> > some thing people search... reliable and cheap / affordable.
> >
> > Afforadble / cheap is relative variable there in my opinion. you mention
> 8$
> > / month stil expensive and unaffordable for you.
> > in other country it is cheap (us).
> >
> > even the cheap one in amazon aws around 8 -10 $ / month with standart
> > package.
> >
> > but you know amazon have free account for 1 years you can try. but if you
> > need permanent you need to pay.
> >
> > better way you lease a vps and join with other fellow there to share the
> > resource and split the payment.
> >
> > Regards,
> >
> > Mulianto
> >
> > On Mon, Jun 25, 2012 at 8:52 PM, Kartik Singhal
> > wrote:
> >
> >> Hi
> >>
> >> We are a small non-profit all-students organization conducting a
> >> TEDxevent in our college soon. We have built a
> >> basic django-based web app for
> >> speaker nomination, participant registration, blog, etc. and other
> mostly
> >> static content.
> >>
> >> Regarding this I am looking for a reliable and affordable web hosting
> >> solution (preferably in India). Since our requirement is pretty small,
> >> hosting on a VPS on upwards of 8$/month or more seems expensive and
> >> unaffordable for us. Are there any web hosts catering to requirements of
> >> small organizations like us?
> >>
> >> I should also add - our previous website was based off Drupal (PHP based
> >> CMS) and we would like to maintain an archive of that too, if possible,
> >> on
> >> this new hosting solution, but this is not a primary requirement.
> >>
> >> --
> >> Kartik
> >> http://k4rtik.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.
> >>
> >
> > --
> > 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.
> >
> >
>
> --
> Sent from my mobile device
>
> --
> 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: ForeignKey problem

2012-06-25 Thread Kurtis Mullins
>
>
> Let me follow up on this. Say I want to add list of all Teams my Players
> played for. What you're saying is that I don't have to add ForeignKey to
> Team and just use team_name field from Team model? Will it work?
>
> This relations stuff is confusing :P.
>
> Haha, no problem! It'll come natural after a while.

Let's start out with the organization of this. There's really two main
relationships you will deal with.

*Foreign Keys*

The first one is ForeignKeys, These are generally used when you want to do
what's called a "One to Many" relationship.

So, for example, let's say you have several teams and several players. We
could assume that each player is *only* playing for one team at any given
time. This means that you will not find a single player playing for two
times. Under this assumption, you would have a "One to Many" relationship
because one team will have many players. *However*, each player will only
have *one* team. That may sound confusing -- read it over a few times if it
does :) Anyways, this scenario would best be solved by using a ForeignKey.

Here's a little visualization just in case that is confusing:

Team: The Bengals
Players: John, Bob, Tim, Joe

Team: The Steelers
Players: Adam, Chris, Frank, Steve

Notice that each player is only playing for one Team. Each team, however,
has multiple players. In this situation, your models would be setup like
this:

class Team(models.Model):
name = models.CharField(max_length=50)

class Player(models.Model):
name = models.CharField(max_length=50)
team = models.ForeignKey(Team)

Now, let's say you want to grab some information about each of these.

1. We have the player Joe, how do we get his team?

print joe.team.name
>> "The Bengals"

2. We have the team "The Steelers", how do we get the list of players?

print steelers.player_set.all()
>> "Adam", "Chris", "Frank", "Steve"

*Many to Many*
*
*
The other common type of relationship you'll run into is called a Many to
Many relationship. This relationship is, essentially, two Models that can
have relationships with many objects from both sides of the relationship.
So to help you understand and visualize how this works, we're going to take
the previous example and modify it a bit.

Let's say we have Two Teams and Several People. However, now people are
allowed to play for Multiple teams. In this example, assume that each
player with the same name is the same person (each name is unique).

Team: The Bengals
Players: Adam, Bob, Charlie

Team: The Steelers
Players: Donald, Evan, Adam

Note: Adam plays for both teams.

So, looking from Adam's perspective, we see that he plays for both the
Steelers and the Bengals. That is -- he has a "many" relationship with the
Teams. Looking at the players from the Team's perspective, it's obvious
that each team has many players. Therefore, in this relationship it is okay
to have Many-to-Many objects from both sides.

Here's the basic Model setup for this:

class Team(models.Model):
name = models.CharField(max_length=50)

class Player(models.Model):
name = CharField(max_length=50)
teams = models.ManyToManyField(Team)

Let's do a couple of examples to see where this is different.

1. Just like before, we have a player but we want to see his Team:

print donald.teams.all()
>> "The Steelers"

2. Now, like before, we want to see this player's team. However, the Player
is no longer restricted to a Single Team.

print adam.teams.all()
>> "The Bengals", "The Steelers"

3. Let's get the reverse relationships -- Who all plays for the Steelers?

print steelers.player_set.all()
>> "Donald", "Evan", "Adam"

So, hopefully, from that example you can see that not much has changed from
the perspective of the Team. It already had a "many" relationship with the
players. However, the thing that has changed here is that the players now
have a "many" relationship with the Teams.

*And to answer your question directly about including the field in the Team:
*
No, you don't need to put a ForeignKey in each Model. You just put it in
once. This will automatically create a variable in your other Model called
_set which can be used to do queries/lookups. Please note that
you can also do something like this to make the naming more practical and
easier to read:

class Team(models.Model)
name = models.CharField(...)

class Player(models.Model)
name = models.CharField(...)
teams = models.ManyToManyField(Team, related_name='players')

Then, you can simply do this:
myteam.players.all() # Notice the word "set" is no longer in there.

Hopefully that helps a bit and I didn't just confuse you more :) Let us
know if you run into any more problems and good luck!

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

Re: ForeignKey problem

2012-06-25 Thread Soviet
W dniu poniedziałek, 25 czerwca 2012 18:54:48 UTC+2 użytkownik Kurtis 
napisał:
>
> Actually, I'm pretty confused about this part :) A ForeignKey is used to 
> relate to another Model -- not just a Model Field -- in Django's ORM.
>
> So for example, if you have a Team Model and a Player Model, you'd want to 
> include "team = models.ForeignKey(Team)" in your Player Model. If you want 
> to back-reference this from your Team, this is also possible (just look 
> through the docs). You don't need to declare the ForeignKey relationship 
> twice. Finally, when you want a specific field from the other Model (for 
> example, maybe a team's name) then you'd just query accordingly: 
> my_player.team.name
>

Let me follow up on this. Say I want to add list of all Teams my Players 
played for. What you're saying is that I don't have to add ForeignKey to 
Team and just use team_name field from Team model? Will it work?

This relations stuff is confusing :P.

-- 
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/-/5g6k_XxiglQJ.
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.



setting up django with virtualenv on windows7

2012-06-25 Thread mymlyn
i started a topic on stackoverflow, analysing responses on SO, on
similar topics, im not really sure wether ill get any feedback there
so im gonna try here :)  described my problem here:
http://stackoverflow.com/questions/11193905/setting-up-django-with-virtualenv-on-windows7/

could any1 explain to me why isnt this working? //or how is this
supposed to work if everything was ok

-- 
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: base_url() in django

2012-06-25 Thread Jani Tiainen
One actual use-case I have is when sending links in emails, for example
confirmations, password resets links etc. And IIRC there is a way to do it
in Django it's just not documented.

Personally I resolved it by using configuration variable in settings.py
since in my case actual Django installation is behind proxies and absolute
url user sees is not the same what Django app server sees.

On Mon, Jun 25, 2012 at 10:20 PM, Kurtis Mullins
wrote:

> Is this an actual issue? You realize that there's no difference between
>> /doc/ and http://example.com/doc/ if the current server is
>> http://example.com/?
>>
>
> +1
>
> I'd like to see the use-case where having absolute URLs everywhere is
> actually necessary. It's not hard to do in certain places where you might
> actually need it. The only place I see needing absolute URLs is when going
> from HTTP to HTTPs and for printing out links that people may copy and
> paste. Even in the former case, a permanent-redirect is better.
>
> --
> 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.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

-- 
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: Affordable Django hosting solution in India/around?

2012-06-25 Thread Babatunde Akinyanmi
Alwaysdata(.com) offers free hosting but its shared hosting

On 6/25/12, Phang Mulianto  wrote:
> Hi,
>
> some thing people search... reliable and cheap / affordable.
>
> Afforadble / cheap is relative variable there in my opinion. you mention 8$
> / month stil expensive and unaffordable for you.
> in other country it is cheap (us).
>
> even the cheap one in amazon aws around 8 -10 $ / month with standart
> package.
>
> but you know amazon have free account for 1 years you can try. but if you
> need permanent you need to pay.
>
> better way you lease a vps and join with other fellow there to share the
> resource and split the payment.
>
> Regards,
>
> Mulianto
>
> On Mon, Jun 25, 2012 at 8:52 PM, Kartik Singhal
> wrote:
>
>> Hi
>>
>> We are a small non-profit all-students organization conducting a
>> TEDxevent in our college soon. We have built a
>> basic django-based web app for
>> speaker nomination, participant registration, blog, etc. and other mostly
>> static content.
>>
>> Regarding this I am looking for a reliable and affordable web hosting
>> solution (preferably in India). Since our requirement is pretty small,
>> hosting on a VPS on upwards of 8$/month or more seems expensive and
>> unaffordable for us. Are there any web hosts catering to requirements of
>> small organizations like us?
>>
>> I should also add - our previous website was based off Drupal (PHP based
>> CMS) and we would like to maintain an archive of that too, if possible,
>> on
>> this new hosting solution, but this is not a primary requirement.
>>
>> --
>> Kartik
>> http://k4rtik.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.
>>
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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: base_url() in django

2012-06-25 Thread Kurtis Mullins
>
> Is this an actual issue? You realize that there's no difference between
> /doc/ and http://example.com/doc/ if the current server is
> http://example.com/?
>

+1

I'd like to see the use-case where having absolute URLs everywhere is
actually necessary. It's not hard to do in certain places where you might
actually need it. The only place I see needing absolute URLs is when going
from HTTP to HTTPs and for printing out links that people may copy and
paste. Even in the former case, a permanent-redirect is better.

-- 
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: acces cleaned data from a dynamic form

2012-06-25 Thread het.oosten
This is how the POST looks:

nameu'Johnson'
form-MAX_NUM_FORMS  u' '
form-1-dish u'fried egg'
dishu'steak'
form-INITIAL_FORMS  u'0'
csrfmiddlewaretoken u'c12349d127dbbd44e829e756613719c'
form-TOTAL_FORMSu'2'

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



Re: Haystack with Whoosh Not Redirecting.

2012-06-25 Thread Nikolas Stevenson-Molnar
If I am reading your view correctly, it creates a new "Meek" if the form
has been submitted, and doesn't query any records from the database. Is
this really what you want in response to a user clicking a search result?

_Nik

On 6/25/2012 11:46 AM, coded kid wrote:
> Yes the form is expecting data from users and it will filtered on the
> same page. will it still work?
>
> Nikolas Stevenson-Molnar wrote:
>> See the examples given for the permalink decorator:
>> https://docs.djangoproject.com/en/1.4/ref/models/instances/#the-permalink-decorator
>>
>> Also, review URLs in Django:
>> https://docs.djangoproject.com/en/1.4/topics/http/urls/
>>
>> In your case, you don't specify any arguments in your URL (or your view
>> function), but you are trying to generate a URL with arguments. Your
>> view function itself seems to be expecting data from a submitted form,
>> which doesn't make sense for a detail view.
>>
>> _Nik
>>
>> On 6/25/2012 10:32 AM, coded kid wrote:
>>> (r'^find/$', findme),
>>>
>>> So how will i input the arguments? any example? thanks.
>>>
>>> Nikolas Stevenson-Molnar wrote:
 Take another look at your get_absolute_url method. As written, it
 specifies several keyword arguments to the view, but the "findme" view
 does not take any arguments. Also, what does your urls.py file look like?

 _Nik

 On 6/25/2012 10:14 AM, coded kid wrote:
> I successfully installed whoosh and made it work with Haystack. Things
> are working fine but I'm facing one problem which is; after searching
> for a keyword and it print out the results, when I click on the
> result(title), It won't redirect me to the page of the keyword I
> clicked on, it's just static. I tried adding a get_absolute_url
> method. Yet it's not working.
>
> What I want is this: when a user search for a keyword and it return
> the result, so if the user click on the result, the user should be
> redirected to a page where it will display every properties of the
> result.
>
> Models
>
>   class Meek(models.Model):
>  user=models.ForeignKey(User)
>  title=models.CharField(max_length=250, unique=True)
>  address=models.CharField(max_length=200)
>  city=models.CharField(max_length=200)
>  state=models.CharField(max_length=200)
>
> main_view=models.ImageField(upload_to="photos",blank=True, null=True)
>
> side_view=models.ImageField(upload_to="photos",blank=True, null=True)
>  pub_date=models.DateTimeField()
>
>  def __unicode__(self):
>  return self.title
>
>
>  @models.permalink
>  def get_absolute_url(self):
>  return ('findme', (), {
> 'main_view': self.main_view,
> 'side_view': self.side_view,
> 'address': self.address,
> 'city': self.city,
> 'state': self.state})
>
> Search/search.html
>
>{% block content %}
>
>  Search
>
>
>
>
> 
>   {{ form.as_table }}
> 
> 
>  
> 
> 
>  
>{% if query %}
>  Results
>   {% for result in page.object_list %}
>
> > {{ result.object.title }}
>
>  {% empty %}
> No results found.
>  {% endfor %}
>
>{% if page.has_previous or page.has_next %}
>  
>{% if page.has_previous %}{% endif %}
>  Previous{% if page.has_previous %}
>{% endif%}
>
>{% if page.has_next %}{% endif %}Next {% if
> page.has_next %}{% endif %}
>{% endif %}
>
>  {% else %}
>
> {# Show some example queries to run, maybe
> query syntax, something else? #}
>
> {% endif %}
>  
>
>{% endblock %}
>
>
> Urlconf
>
>   #url where the objects are posted.
>   (r'^find/$', findme),
>
>  #haystack url where you can search
>  (r'^search/', include('haystack.urls')),
>
> Views:
>
>def findme(request):
>extra_data_context={}
>#if there's nothing in the field do nothing.
>   

Re: Haystack with Whoosh Not Redirecting.

2012-06-25 Thread coded kid
Yes the form is expecting data from users and it will filtered on the
same page. will it still work?

Nikolas Stevenson-Molnar wrote:
> See the examples given for the permalink decorator:
> https://docs.djangoproject.com/en/1.4/ref/models/instances/#the-permalink-decorator
>
> Also, review URLs in Django:
> https://docs.djangoproject.com/en/1.4/topics/http/urls/
>
> In your case, you don't specify any arguments in your URL (or your view
> function), but you are trying to generate a URL with arguments. Your
> view function itself seems to be expecting data from a submitted form,
> which doesn't make sense for a detail view.
>
> _Nik
>
> On 6/25/2012 10:32 AM, coded kid wrote:
> > (r'^find/$', findme),
> >
> > So how will i input the arguments? any example? thanks.
> >
> > Nikolas Stevenson-Molnar wrote:
> >> Take another look at your get_absolute_url method. As written, it
> >> specifies several keyword arguments to the view, but the "findme" view
> >> does not take any arguments. Also, what does your urls.py file look like?
> >>
> >> _Nik
> >>
> >> On 6/25/2012 10:14 AM, coded kid wrote:
> >>> I successfully installed whoosh and made it work with Haystack. Things
> >>> are working fine but I'm facing one problem which is; after searching
> >>> for a keyword and it print out the results, when I click on the
> >>> result(title), It won't redirect me to the page of the keyword I
> >>> clicked on, it's just static. I tried adding a get_absolute_url
> >>> method. Yet it's not working.
> >>>
> >>> What I want is this: when a user search for a keyword and it return
> >>> the result, so if the user click on the result, the user should be
> >>> redirected to a page where it will display every properties of the
> >>> result.
> >>>
> >>> Models
> >>>
> >>>   class Meek(models.Model):
> >>>  user=models.ForeignKey(User)
> >>>  title=models.CharField(max_length=250, unique=True)
> >>>  address=models.CharField(max_length=200)
> >>>  city=models.CharField(max_length=200)
> >>>  state=models.CharField(max_length=200)
> >>>
> >>> main_view=models.ImageField(upload_to="photos",blank=True, null=True)
> >>>
> >>> side_view=models.ImageField(upload_to="photos",blank=True, null=True)
> >>>  pub_date=models.DateTimeField()
> >>>
> >>>  def __unicode__(self):
> >>>  return self.title
> >>>
> >>>
> >>>  @models.permalink
> >>>  def get_absolute_url(self):
> >>>  return ('findme', (), {
> >>> 'main_view': self.main_view,
> >>> 'side_view': self.side_view,
> >>> 'address': self.address,
> >>> 'city': self.city,
> >>> 'state': self.state})
> >>>
> >>> Search/search.html
> >>>
> >>>{% block content %}
> >>>
> >>>  Search
> >>>
> >>>
> >>>
> >>>
> >>> 
> >>>   {{ form.as_table }}
> >>> 
> >>> 
> >>>  
> >>> 
> >>> 
> >>>  
> >>>{% if query %}
> >>>  Results
> >>>   {% for result in page.object_list %}
> >>>
> >>>   {{ result.object.title }}
> >>>
> >>>  {% empty %}
> >>> No results found.
> >>>  {% endfor %}
> >>>
> >>>{% if page.has_previous or page.has_next %}
> >>>  
> >>>{% if page.has_previous %}{% endif %}
> >>>  Previous{% if page.has_previous %}
> >>>{% endif%}
> >>>
> >>>{% if page.has_next %}{% endif %}Next {% if
> >>> page.has_next %}{% endif %}
> >>>{% endif %}
> >>>
> >>>  {% else %}
> >>>
> >>> {# Show some example queries to run, maybe
> >>> query syntax, something else? #}
> >>>
> >>> {% endif %}
> >>>  
> >>>
> >>>{% endblock %}
> >>>
> >>>
> >>> Urlconf
> >>>
> >>>   #url where the objects are posted.
> >>>   (r'^find/$', findme),
> >>>
> >>>  #haystack url where you can search
> >>>  (r'^search/', include('haystack.urls')),
> >>>
> >>> Views:
> >>>
> >>>def findme(request):
> >>>extra_data_context={}
> >>>#if there's nothing in the field do nothing.
> >>>if request.method=="POST":
> >>>   form=MeekForm(request.POST, request.FILES)
> >>>   if form.is_valid():
> >>>  data=form.cleaned_data
> >>>  newmeeks=Meek(
> >>>   

Re: ForeignKey problem

2012-06-25 Thread Kurtis Mullins
>
>
>>  The mechanism must involve deferred resolution of the second model by
> passing the model class name in as a string. Without string syntax python
> insists on knowing what that class is at the time it sees the reference.
> Don't know more than that though ;)
>
>
https://github.com/django/django/blob/1.4/django/db/models/fields/related.py
Line
23 :)

-- 
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: base_url() in django

2012-06-25 Thread Melvyn Sopacua
On 25-6-2012 17:02, Raitucarp wrote:
> @Melvyn
> 
> That's not simple way. I have to write every views to pass it on to 
> template? It's not elegant by the way. uhm Should I create custom template 
> tags to do it in beautiful way?

Is this an actual issue? You realize that there's no difference between
/doc/ and http://example.com/doc/ if the current server is
http://example.com/?

See here:
https://docs.djangoproject.com/en/1.4/ref/templates/builtins/#url
-- 
Melvyn Sopacua


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



Re: Haystack with Whoosh Not Redirecting.

2012-06-25 Thread Nikolas Stevenson-Molnar
See the examples given for the permalink decorator:
https://docs.djangoproject.com/en/1.4/ref/models/instances/#the-permalink-decorator

Also, review URLs in Django:
https://docs.djangoproject.com/en/1.4/topics/http/urls/

In your case, you don't specify any arguments in your URL (or your view
function), but you are trying to generate a URL with arguments. Your
view function itself seems to be expecting data from a submitted form,
which doesn't make sense for a detail view.

_Nik

On 6/25/2012 10:32 AM, coded kid wrote:
> (r'^find/$', findme),
>
> So how will i input the arguments? any example? thanks.
>
> Nikolas Stevenson-Molnar wrote:
>> Take another look at your get_absolute_url method. As written, it
>> specifies several keyword arguments to the view, but the "findme" view
>> does not take any arguments. Also, what does your urls.py file look like?
>>
>> _Nik
>>
>> On 6/25/2012 10:14 AM, coded kid wrote:
>>> I successfully installed whoosh and made it work with Haystack. Things
>>> are working fine but I'm facing one problem which is; after searching
>>> for a keyword and it print out the results, when I click on the
>>> result(title), It won't redirect me to the page of the keyword I
>>> clicked on, it's just static. I tried adding a get_absolute_url
>>> method. Yet it's not working.
>>>
>>> What I want is this: when a user search for a keyword and it return
>>> the result, so if the user click on the result, the user should be
>>> redirected to a page where it will display every properties of the
>>> result.
>>>
>>> Models
>>>
>>>   class Meek(models.Model):
>>>  user=models.ForeignKey(User)
>>>  title=models.CharField(max_length=250, unique=True)
>>>  address=models.CharField(max_length=200)
>>>  city=models.CharField(max_length=200)
>>>  state=models.CharField(max_length=200)
>>>
>>> main_view=models.ImageField(upload_to="photos",blank=True, null=True)
>>>
>>> side_view=models.ImageField(upload_to="photos",blank=True, null=True)
>>>  pub_date=models.DateTimeField()
>>>
>>>  def __unicode__(self):
>>>  return self.title
>>>
>>>
>>>  @models.permalink
>>>  def get_absolute_url(self):
>>>  return ('findme', (), {
>>> 'main_view': self.main_view,
>>> 'side_view': self.side_view,
>>> 'address': self.address,
>>> 'city': self.city,
>>> 'state': self.state})
>>>
>>> Search/search.html
>>>
>>>{% block content %}
>>>
>>>  Search
>>>
>>>
>>>
>>>
>>> 
>>>   {{ form.as_table }}
>>> 
>>> 
>>>  
>>> 
>>> 
>>>  
>>>{% if query %}
>>>  Results
>>>   {% for result in page.object_list %}
>>>
>>> >>> {{ result.object.title }}
>>>
>>>  {% empty %}
>>> No results found.
>>>  {% endfor %}
>>>
>>>{% if page.has_previous or page.has_next %}
>>>  
>>>{% if page.has_previous %}{% endif %}
>>>  Previous{% if page.has_previous %}
>>>{% endif%}
>>>
>>>{% if page.has_next %}{% endif %}Next {% if
>>> page.has_next %}{% endif %}
>>>{% endif %}
>>>
>>>  {% else %}
>>>
>>> {# Show some example queries to run, maybe
>>> query syntax, something else? #}
>>>
>>> {% endif %}
>>>  
>>>
>>>{% endblock %}
>>>
>>>
>>> Urlconf
>>>
>>>   #url where the objects are posted.
>>>   (r'^find/$', findme),
>>>
>>>  #haystack url where you can search
>>>  (r'^search/', include('haystack.urls')),
>>>
>>> Views:
>>>
>>>def findme(request):
>>>extra_data_context={}
>>>#if there's nothing in the field do nothing.
>>>if request.method=="POST":
>>>   form=MeekForm(request.POST, request.FILES)
>>>   if form.is_valid():
>>>  data=form.cleaned_data
>>>  newmeeks=Meek(
>>>  user=request.user,
>>>  pub_date=datetime.datetime.now(),
>>>  title=data['title'],
>>>  main_view=request.FILES['main_view'],
>>>  side_view=request.FILES['side_view'],
>>>  address=data['address'],
>>>  

Re: Haystack with Whoosh Not Redirecting.

2012-06-25 Thread coded kid
(r'^find/$', findme),

So how will i input the arguments? any example? thanks.

Nikolas Stevenson-Molnar wrote:
> Take another look at your get_absolute_url method. As written, it
> specifies several keyword arguments to the view, but the "findme" view
> does not take any arguments. Also, what does your urls.py file look like?
>
> _Nik
>
> On 6/25/2012 10:14 AM, coded kid wrote:
> > I successfully installed whoosh and made it work with Haystack. Things
> > are working fine but I'm facing one problem which is; after searching
> > for a keyword and it print out the results, when I click on the
> > result(title), It won't redirect me to the page of the keyword I
> > clicked on, it's just static. I tried adding a get_absolute_url
> > method. Yet it's not working.
> >
> > What I want is this: when a user search for a keyword and it return
> > the result, so if the user click on the result, the user should be
> > redirected to a page where it will display every properties of the
> > result.
> >
> > Models
> >
> >   class Meek(models.Model):
> >  user=models.ForeignKey(User)
> >  title=models.CharField(max_length=250, unique=True)
> >  address=models.CharField(max_length=200)
> >  city=models.CharField(max_length=200)
> >  state=models.CharField(max_length=200)
> >
> > main_view=models.ImageField(upload_to="photos",blank=True, null=True)
> >
> > side_view=models.ImageField(upload_to="photos",blank=True, null=True)
> >  pub_date=models.DateTimeField()
> >
> >  def __unicode__(self):
> >  return self.title
> >
> >
> >  @models.permalink
> >  def get_absolute_url(self):
> >  return ('findme', (), {
> > 'main_view': self.main_view,
> > 'side_view': self.side_view,
> > 'address': self.address,
> > 'city': self.city,
> > 'state': self.state})
> >
> > Search/search.html
> >
> >{% block content %}
> >
> >  Search
> >
> >
> >
> >
> > 
> >   {{ form.as_table }}
> > 
> > 
> >  
> > 
> > 
> >  
> >{% if query %}
> >  Results
> >   {% for result in page.object_list %}
> >
> >  >> {{ result.object.title }}
> >
> >  {% empty %}
> > No results found.
> >  {% endfor %}
> >
> >{% if page.has_previous or page.has_next %}
> >  
> >{% if page.has_previous %}{% endif %}
> >  Previous{% if page.has_previous %}
> >{% endif%}
> >
> >{% if page.has_next %}{% endif %}Next {% if
> > page.has_next %}{% endif %}
> >{% endif %}
> >
> >  {% else %}
> >
> > {# Show some example queries to run, maybe
> > query syntax, something else? #}
> >
> > {% endif %}
> >  
> >
> >{% endblock %}
> >
> >
> > Urlconf
> >
> >   #url where the objects are posted.
> >   (r'^find/$', findme),
> >
> >  #haystack url where you can search
> >  (r'^search/', include('haystack.urls')),
> >
> > Views:
> >
> >def findme(request):
> >extra_data_context={}
> >#if there's nothing in the field do nothing.
> >if request.method=="POST":
> >   form=MeekForm(request.POST, request.FILES)
> >   if form.is_valid():
> >  data=form.cleaned_data
> >  newmeeks=Meek(
> >  user=request.user,
> >  pub_date=datetime.datetime.now(),
> >  title=data['title'],
> >  main_view=request.FILES['main_view'],
> >  side_view=request.FILES['side_view'],
> >  address=data['address'],
> >  city=data['city'],
> >  state=data['state'])
> > newmeeks.save()
> > extra_data_context.update({'MeekForm':form})
> >  else:
> >  form = MeekForm()
> >  extra_data_context.update({'MeekForm':form})
> >
> > extra_data_context.update({'Meeks':Meek.objects.filter(user=request.user)})
> >  return
> > render_to_response('postme.html',extra_data_context,context_instance=RequestContext(request))
> >

-- 
You 

Re: Haystack with Whoosh Not Redirecting.

2012-06-25 Thread Nikolas Stevenson-Molnar
Take another look at your get_absolute_url method. As written, it
specifies several keyword arguments to the view, but the "findme" view
does not take any arguments. Also, what does your urls.py file look like?

_Nik

On 6/25/2012 10:14 AM, coded kid wrote:
> I successfully installed whoosh and made it work with Haystack. Things
> are working fine but I'm facing one problem which is; after searching
> for a keyword and it print out the results, when I click on the
> result(title), It won't redirect me to the page of the keyword I
> clicked on, it's just static. I tried adding a get_absolute_url
> method. Yet it's not working.
>
> What I want is this: when a user search for a keyword and it return
> the result, so if the user click on the result, the user should be
> redirected to a page where it will display every properties of the
> result.
>
> Models
>
>   class Meek(models.Model):
>  user=models.ForeignKey(User)
>  title=models.CharField(max_length=250, unique=True)
>  address=models.CharField(max_length=200)
>  city=models.CharField(max_length=200)
>  state=models.CharField(max_length=200)
>  
> main_view=models.ImageField(upload_to="photos",blank=True, null=True)
>  
> side_view=models.ImageField(upload_to="photos",blank=True, null=True)
>  pub_date=models.DateTimeField()
>
>  def __unicode__(self):
>  return self.title
>
>
>  @models.permalink
>  def get_absolute_url(self):
>  return ('findme', (), {
> 'main_view': self.main_view,
> 'side_view': self.side_view,
> 'address': self.address,
> 'city': self.city,
> 'state': self.state})
>
> Search/search.html
>
>{% block content %}
>
>  Search
>
>
>
>
> 
>   {{ form.as_table }}
> 
> 
>  
> 
> 
>  
>{% if query %}
>  Results
>   {% for result in page.object_list %}
>
> > {{ result.object.title }}
>
>  {% empty %}
> No results found.
>  {% endfor %}
>
>{% if page.has_previous or page.has_next %}
>  
>{% if page.has_previous %}{% endif %}
>  Previous{% if page.has_previous %}
>{% endif%}
>
>{% if page.has_next %}{% endif %}Next {% if
> page.has_next %}{% endif %}
>{% endif %}
>
>  {% else %}
>
> {# Show some example queries to run, maybe
> query syntax, something else? #}
>
> {% endif %}
>  
>
>{% endblock %}
>
>
> Urlconf
>
>   #url where the objects are posted.
>   (r'^find/$', findme),
>
>  #haystack url where you can search
>  (r'^search/', include('haystack.urls')),
>
> Views:
>
>def findme(request):
>extra_data_context={}
>#if there's nothing in the field do nothing.
>if request.method=="POST":
>   form=MeekForm(request.POST, request.FILES)
>   if form.is_valid():
>  data=form.cleaned_data
>  newmeeks=Meek(
>  user=request.user,
>  pub_date=datetime.datetime.now(),
>  title=data['title'],
>  main_view=request.FILES['main_view'],
>  side_view=request.FILES['side_view'],
>  address=data['address'],
>  city=data['city'],
>  state=data['state'])
> newmeeks.save()
> extra_data_context.update({'MeekForm':form})
>  else:
>  form = MeekForm()
>  extra_data_context.update({'MeekForm':form})
>  
> extra_data_context.update({'Meeks':Meek.objects.filter(user=request.user)})
>  return
> render_to_response('postme.html',extra_data_context,context_instance=RequestContext(request))
>


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



Haystack with Whoosh Not Redirecting.

2012-06-25 Thread coded kid
I successfully installed whoosh and made it work with Haystack. Things
are working fine but I'm facing one problem which is; after searching
for a keyword and it print out the results, when I click on the
result(title), It won't redirect me to the page of the keyword I
clicked on, it's just static. I tried adding a get_absolute_url
method. Yet it's not working.

What I want is this: when a user search for a keyword and it return
the result, so if the user click on the result, the user should be
redirected to a page where it will display every properties of the
result.

Models

  class Meek(models.Model):
 user=models.ForeignKey(User)
 title=models.CharField(max_length=250, unique=True)
 address=models.CharField(max_length=200)
 city=models.CharField(max_length=200)
 state=models.CharField(max_length=200)
 
main_view=models.ImageField(upload_to="photos",blank=True, null=True)
 
side_view=models.ImageField(upload_to="photos",blank=True, null=True)
 pub_date=models.DateTimeField()

 def __unicode__(self):
 return self.title


 @models.permalink
 def get_absolute_url(self):
 return ('findme', (), {
'main_view': self.main_view,
'side_view': self.side_view,
'address': self.address,
'city': self.city,
'state': self.state})

Search/search.html

   {% block content %}

 Search


   


  {{ form.as_table }}


 


 
   {% if query %}
 Results
  {% for result in page.object_list %}
   
{{ result.object.title }}
   
 {% empty %}
No results found.
 {% endfor %}

   {% if page.has_previous or page.has_next %}
 
   {% if page.has_previous %}{% endif %}
 Previous{% if page.has_previous %}
   {% endif%}

   {% if page.has_next %}{% endif %}Next {% if
page.has_next %}{% endif %}
   {% endif %}

 {% else %}

{# Show some example queries to run, maybe
query syntax, something else? #}

{% endif %}
 

   {% endblock %}


Urlconf

  #url where the objects are posted.
  (r'^find/$', findme),

 #haystack url where you can search
 (r'^search/', include('haystack.urls')),

Views:

   def findme(request):
   extra_data_context={}
   #if there's nothing in the field do nothing.
   if request.method=="POST":
  form=MeekForm(request.POST, request.FILES)
  if form.is_valid():
 data=form.cleaned_data
 newmeeks=Meek(
 user=request.user,
 pub_date=datetime.datetime.now(),
 title=data['title'],
 main_view=request.FILES['main_view'],
 side_view=request.FILES['side_view'],
 address=data['address'],
 city=data['city'],
 state=data['state'])
newmeeks.save()
extra_data_context.update({'MeekForm':form})
 else:
 form = MeekForm()
 extra_data_context.update({'MeekForm':form})
 
extra_data_context.update({'Meeks':Meek.objects.filter(user=request.user)})
 return
render_to_response('postme.html',extra_data_context,context_instance=RequestContext(request))

-- 
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: ForeignKey problem

2012-06-25 Thread Thomas Lockhart

On 12-06-25 10:02 AM, Adrian Bool wrote:

On 25 Jun 2012, at 17:53, Soviet wrote:


Thank you kind sir for your fast response, that worked brilliantly.
Can I be cheeky and ask why does it work? :)

Magic! ;-)

The mechanism must involve deferred resolution of the second model by 
passing the model class name in as a string. Without string syntax 
python insists on knowing what that class is at the time it sees the 
reference. Don't know more than that though ;)


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



Re: ForeignKey problem

2012-06-25 Thread Adrian Bool

On 25 Jun 2012, at 17:53, Soviet wrote:

> Thank you kind sir for your fast response, that worked brilliantly.
> Can I be cheeky and ask why does it work? :)

Magic! ;-)

Although seriously, Django obviously has some code in there to handle just the 
situation you have come across.  Sorry, I don't have a deeper answer than that!

Cheers,

aid


-- 
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: ForeignKey problem

2012-06-25 Thread Kurtis Mullins
>
> [...]
> > Let's say I have two models and in each I have field with ForeignKey
> > relating to field in other model (hope it's clear). [...]
>

Actually, I'm pretty confused about this part :) A ForeignKey is used to
relate to another Model -- not just a Model Field -- in Django's ORM.

So for example, if you have a Team Model and a Player Model, you'd want to
include "team = models.ForeignKey(Team)" in your Player Model. If you want
to back-reference this from your Team, this is also possible (just look
through the docs). You don't need to declare the ForeignKey relationship
twice. Finally, when you want a specific field from the other Model (for
example, maybe a team's name) then you'd just query accordingly:
my_player.team.name

-- 
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: ForeignKey problem

2012-06-25 Thread Soviet
Thank you kind sir for your fast response, that worked brilliantly.
Can I be cheeky and ask why does it work? :)

On 25 Cze, 18:43, Adrian Bool  wrote:
> On 25 Jun 2012, at 17:41, Soviet wrote:
>
> > I'm new to this Django thing and I run into first problem :).
>
> > Let's say I have two models and in each I have field with ForeignKey
> > relating to field in other model (hope it's clear). Now that I want to
> > run migrate with South, I'm getting "NameError: name 'ModelName' is
> > not defined". This is clearly (?) an issue with the fact that one
> > model is on top of the other one and second Model hasn't been defined
> > yet. Changing position of the models is, obviously, not helping. How
> > do I approach this?
>
> In the first of the two models, use a string containing the second model's 
> name as the first argument to the ForeignKey method.
>
> Regards,
>
> aid

-- 
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: ForeignKey problem

2012-06-25 Thread Adrian Bool


On 25 Jun 2012, at 17:41, Soviet wrote:
> I'm new to this Django thing and I run into first problem :).
> 
> Let's say I have two models and in each I have field with ForeignKey
> relating to field in other model (hope it's clear). Now that I want to
> run migrate with South, I'm getting "NameError: name 'ModelName' is
> not defined". This is clearly (?) an issue with the fact that one
> model is on top of the other one and second Model hasn't been defined
> yet. Changing position of the models is, obviously, not helping. How
> do I approach this?

In the first of the two models, use a string containing the second model's name 
as the first argument to the ForeignKey method.

Regards,

aid

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



ForeignKey problem

2012-06-25 Thread Soviet
Hey
I'm new to this Django thing and I run into first problem :).

Let's say I have two models and in each I have field with ForeignKey
relating to field in other model (hope it's clear). Now that I want to
run migrate with South, I'm getting "NameError: name 'ModelName' is
not defined". This is clearly (?) an issue with the fact that one
model is on top of the other one and second Model hasn't been defined
yet. Changing position of the models is, obviously, not helping. How
do I approach this?

Thanks up front for all the help!

-- 
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: [tutorial] why doesn't my admin template overrule?

2012-06-25 Thread bunski
Thanks!

Op maandag 25 juni 2012 15:30:40 UTC+2 schreef Melvyn Sopacua het volgende:
>
> On 24-6-2012 22:26, bunski wrote: 
>
> > But cant figure out why my admin header is not changing. Can you see 
> > instantly with my attached screenshot? 
>
> "Don't forget to use absolute paths" 
> And absolute paths start with forward slashes. Yours doesn't in 
> TEMPLATE_DIRS. 
>
> -- 
> Melvyn Sopacua 
>
>
>

-- 
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/-/iDwOuVDeIfEJ.
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: base_url() in django

2012-06-25 Thread Raitucarp
@Melvyn

That's not simple way. I have to write every views to pass it on to 
template? It's not elegant by the way. uhm Should I create custom template 
tags to do it in beautiful way?

Because base_url() in codeigniter is a helper. And I don't need write it on 
to controllers(views in django), and pass it to view (template in django)

Anyone?

-- 
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/-/XHqOjVujIzAJ.
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: convert str to datetime

2012-06-25 Thread Jim Thaxton
The parseutil module is very handy when converting a formatted string into 
a datetime object.

Here's the module:
http://labix.org/python-dateutil

And here is a stackoverflow post with a number of examples:
http://stackoverflow.com/questions/127803/how-to-parse-iso-formatted-date-in-python

On Monday, June 25, 2012 3:42:27 AM UTC-5, armagan wrote:
>
> Hi,
>
> I'm trying to convert to str to datetime. "date object" must be datetime 
> object. Can you help me?
>
>  def item_pubdate(self, item): # Yayinlanma Tarihi
>
> if item.delivery_date:
>
> date = item.delivery_date
>
> dt = datetime.combine(date, time())
>
> return dt
>
> else:
>
> return ' '
>

-- 
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/-/TwagqVTzU-0J.
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: Custom SQL for creating django tables

2012-06-25 Thread Thomas Lockhart

On 12-06-25 1:35 AM, Mina Farid wrote:

Hello guys,
I am connection from django to Apache Derby. I am using IBM DB2 driver 
backend.
Django tables are created in DB2 syntax, which is not very compatible 
with Derby.


Is there any way that I can force django to customize the creation of 
SQL to a certain (say SQL standard) syntax?



That is what the database backends do.

If you are looking for "SQL standard" syntax, try using the Postgres 
backend. The standards documents were used to implement the Postgres 
parser (most other DBs did their own thing in some areas or have legacy 
syntax to support).


hth

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



Re: Creating permalink for blog tags that have the Post class as foreign key

2012-06-25 Thread Thomas Lockhart

On 12-06-24 7:18 PM, Matthew Meyer wrote:
After making some changes debugging in the shell revealed, I have 
gotten it to work, thanks!!!

So what was the solution??!!!

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



Re: Using now in an if

2012-06-25 Thread Larry Martell
On Mon, Jun 25, 2012 at 6:26 AM, Daniel Roseman  wrote:
>
> On Monday, 25 June 2012 13:05:24 UTC+1, larry@gmail.com wrote:
>>
>> I'm trying to use now in an if like this:
>>
>> {% if value|date:"Ymd" ==  now "Ymd" %}
>>
>> This is failing with: 'Unused '"Ymd"' at end of if expression.'
>>
>> If I quote it:
>>
>> {% if value|date:"Ymd" ==  'now "Ymd"' %}
>>
>> I don't get the syntax error, but the if does not evaluate to true
>> when the dates match.
>>
>> I need to see if the date in {{ value }} is `today' - how can I do that?
>>
>> -larry
>
>
> Write a custom "is_today" filter. Two lines of code.

Thanks for the reply. I ended up doing what I needed in python on the sever.

So I guess there is no way to use now in an if?

-- 
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: 403 error when POSTing to a view with csrf protection

2012-06-25 Thread Melvyn Sopacua
On 25-6-2012 15:20, Mike wrote:
> 
> 
> On Monday, June 25, 2012 3:06:28 PM UTC+2, Melvyn Sopacua wrote:
>>
>> On 25-6-2012 13:11, Mike wrote: 
>>
>>> POST:>> [u'']}>, 
>>
>> Wait a second... 
>> Where's your csrfmiddlewaretoken from the {% csrf_token %} field that 
>> you put in your form? 
>>
>> This is the process: 
>> - the cookie token is basically a lock 
>> - the POST request resembles trying to open the door with that lock 
>> - the formfield token is a key 
>>
>> No key, no open door. 
>> Wrong key, no open door. 
>> -- 
>> Melvyn Sopacua 
>>
>> Well, thats the thing, there *is* no {% csrf_token %} field in my form 
> because I have no form.

Then you can't protect the form either, which is what CSRF is for. The
token in the form is different each time and behind the scenes
associated with your cookie token. So that form token is only valid for
that cookie and only valid once.
-- 
Melvyn Sopacua


-- 
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: [tutorial] why doesn't my admin template overrule?

2012-06-25 Thread Melvyn Sopacua
On 24-6-2012 22:26, bunski wrote:

> But cant figure out why my admin header is not changing. Can you see 
> instantly with my attached screenshot?

"Don't forget to use absolute paths"
And absolute paths start with forward slashes. Yours doesn't in
TEMPLATE_DIRS.

-- 
Melvyn Sopacua


-- 
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: 403 error when POSTing to a view with csrf protection

2012-06-25 Thread Mike


On Monday, June 25, 2012 3:12:44 PM UTC+2, Kurtis wrote:
>
> > POST:> > [u'']}>,
>>
>> Wait a second...
>> Where's your csrfmiddlewaretoken from the {% csrf_token %} field that
>> you put in your form?
>>
>> This is the process:
>> - the cookie token is basically a lock
>> - the POST request resembles trying to open the door with that lock
>> - the formfield token is a key
>>
>> No key, no open door.
>> Wrong key, no open door.
>
>
> +1
> Looks like your CSRF Token is missing from the POST data. 
>

The csrf token is supposed to be part of the POST data (i.e. the message 
body)?  I thought it only needed to be in the header. Aha!  I will check 
the django docs on this.

-- 
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/-/exrdEKHy98IJ.
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: 403 error when POSTing to a view with csrf protection

2012-06-25 Thread Mike


On Monday, June 25, 2012 3:06:28 PM UTC+2, Melvyn Sopacua wrote:
>
> On 25-6-2012 13:11, Mike wrote: 
>
> > POST: > [u'']}>, 
>
> Wait a second... 
> Where's your csrfmiddlewaretoken from the {% csrf_token %} field that 
> you put in your form? 
>
> This is the process: 
> - the cookie token is basically a lock 
> - the POST request resembles trying to open the door with that lock 
> - the formfield token is a key 
>
> No key, no open door. 
> Wrong key, no open door. 
> -- 
> Melvyn Sopacua 
>
> Well, thats the thing, there *is* no {% csrf_token %} field in my form 
because I have no form.  The initial GET request is processed with this 
block of code:
else:
c = {}
c.update(csrf(request))
return render_to_response('empty.html', c)

empty.html is an empty text file. Also, the view function is decorated 
with @ensure_csrf_cookie to make sure that the response contains the csrf 
cookie even though I'm not using  {% csrf_token %} 

In writing all this I just noticed that I have two lines of code aimed at 
making sure the response contains the csrf token:
@ensure_csrf_cookie
and 
c.update(csrf(request))

It seems like I shouldn't need both, so maybe having both is breaking 
something.  I'll check on that.
Mike


On Monday, June 25, 2012 3:06:28 PM UTC+2, Melvyn Sopacua wrote:
>
> On 25-6-2012 13:11, Mike wrote: 
>
> > POST: > [u'']}>, 
>
> Wait a second... 
> Where's your csrfmiddlewaretoken from the {% csrf_token %} field that 
> you put in your form? 
>
> This is the process: 
> - the cookie token is basically a lock 
> - the POST request resembles trying to open the door with that lock 
> - the formfield token is a key 
>
> No key, no open door. 
> Wrong key, no open door. 
> -- 
> Melvyn Sopacua 
>
>
>

-- 
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/-/P77ojG6cfnIJ.
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: base_url() in django

2012-06-25 Thread Melvyn Sopacua
On 25-6-2012 3:10, Raitucarp wrote:

> http://example.com
> or
> https://example.com

You also do this in your view functions, using the Site framework:

Then pass it on to template.
-- 
Melvyn Sopacua


-- 
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: 403 error when POSTing to a view with csrf protection

2012-06-25 Thread Kurtis Mullins
>
> > POST: > [u'']}>,
>
> Wait a second...
> Where's your csrfmiddlewaretoken from the {% csrf_token %} field that
> you put in your form?
>
> This is the process:
> - the cookie token is basically a lock
> - the POST request resembles trying to open the door with that lock
> - the formfield token is a key
>
> No key, no open door.
> Wrong key, no open door.


+1
Looks like your CSRF Token is missing from the POST data.

-- 
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: WSGI help required. Getting a 'No module named myFirstProject.wsgi' error.

2012-06-25 Thread Harvey
Hi 

My code looks like this...see below.  fails on last line. 
i.e. runfastcgi(method="threaded", daemonize="false")

Python Code is run from this 
path /home1/harveywe/www/dj/testProject/mySite.fcgi

environments 
PYTHONPATH=/home1/harveywe/.local/lib/python2.6/site-packages:/home1/harveywe/
PATH=/home1/harveywe/.local/bin:/home1/harveywe/.local/usr/bin:/usr/local/jdk/ 
 bin:/home1/harveywe/perl5/bin:/usr/lib64/qt-3.3/bin:/home1/harveywe/perl5/bin: 
 /ramdisk/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr 
 

This code being run on a ISP host (bluehost.com). 

Does any of this help?

Harevy


### MY CODE ##
harve...@harveywest.co.uk [~/www/dj/testProject]# cat mySite.fcgi
#!/usr/bin/python2.6
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/home1/harveywe/.local/lib/python2.6")
sys.path.insert(13, "/home1/harveywe/django_projects/myFirstProject")


sys.path.insert(0, "/home1/harveywe/.local/lib/python2.6/flup-1.0.2")


# Switch to the directory of your project. (Optional.)
# os.chdir("/home/DJANGONOOB/django_projects/myFirstProject")

#from django.conf import settings

#settings.DEBUG = True




# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
 MY CODE END ###




On Tuesday, 29 May 2012 22:12:27 UTC+1, Harvey wrote:
>
> Setting up django for the first time 
>
> Any ideas what i need to look at to get this error to go away. Not 
> used "wsgi" before? 
>
>
> ~/www/django/mySite.fcgi 
>
> Traceback (most recent call last): 
>   File "./mySite.fcgi", line 19, in  
> runfastcgi(method="threaded", daemonize="false") 
>   File "/home1/harveywe/.local/lib/python2.6/site-packages/django/core/ 
> servers/fastcgi.py", line 182, in runfastcgi 
> WSGIServer(get_internal_wsgi_application(), **wsgi_opts).run() 
>   File "/home1/harveywe/.local/lib/python2.6/site-packages/django/core/ 
> servers/basehttp.py", line 60, in get_internal_wsgi_application 
> "could not import module '%s': %s" % (app_path, module_name, e)) 
> django.core.exceptions.ImproperlyConfigured: WSGI application 
> 'myFirstProject.wsgi.application' could not be loaded; could not 
> import module 'myFirstProject.wsgi': No module named 
> myFirstProject.wsgi 
>
> I'm assume this explains why i'm getting "HTTP Error 500 Internal 
> server error"

-- 
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/-/8emacSN1V_EJ.
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: 403 error when POSTing to a view with csrf protection

2012-06-25 Thread Melvyn Sopacua
On 25-6-2012 13:11, Mike wrote:

> POST: [u'']}>,

Wait a second...
Where's your csrfmiddlewaretoken from the {% csrf_token %} field that
you put in your form?

This is the process:
- the cookie token is basically a lock
- the POST request resembles trying to open the door with that lock
- the formfield token is a key

No key, no open door.
Wrong key, no open door.
-- 
Melvyn Sopacua


-- 
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: Affordable Django hosting solution in India/around?

2012-06-25 Thread Phang Mulianto
Hi,

some thing people search... reliable and cheap / affordable.

Afforadble / cheap is relative variable there in my opinion. you mention 8$
/ month stil expensive and unaffordable for you.
in other country it is cheap (us).

even the cheap one in amazon aws around 8 -10 $ / month with standart
package.

but you know amazon have free account for 1 years you can try. but if you
need permanent you need to pay.

better way you lease a vps and join with other fellow there to share the
resource and split the payment.

Regards,

Mulianto

On Mon, Jun 25, 2012 at 8:52 PM, Kartik Singhal wrote:

> Hi
>
> We are a small non-profit all-students organization conducting a 
> TEDxevent in our college soon. We have built a basic 
> django-based web app for
> speaker nomination, participant registration, blog, etc. and other mostly
> static content.
>
> Regarding this I am looking for a reliable and affordable web hosting
> solution (preferably in India). Since our requirement is pretty small,
> hosting on a VPS on upwards of 8$/month or more seems expensive and
> unaffordable for us. Are there any web hosts catering to requirements of
> small organizations like us?
>
> I should also add - our previous website was based off Drupal (PHP based
> CMS) and we would like to maintain an archive of that too, if possible, on
> this new hosting solution, but this is not a primary requirement.
>
> --
> Kartik
> http://k4rtik.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.
>

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



Affordable Django hosting solution in India/around?

2012-06-25 Thread Kartik Singhal
Hi

We are a small non-profit all-students organization conducting a
TEDxevent in our college soon. We have built
a basic django-based web app for
speaker nomination, participant registration, blog, etc. and other mostly
static content.

Regarding this I am looking for a reliable and affordable web hosting
solution (preferably in India). Since our requirement is pretty small,
hosting on a VPS on upwards of 8$/month or more seems expensive and
unaffordable for us. Are there any web hosts catering to requirements of
small organizations like us?

I should also add - our previous website was based off Drupal (PHP based
CMS) and we would like to maintain an archive of that too, if possible, on
this new hosting solution, but this is not a primary requirement.

-- 
Kartik
http://k4rtik.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.



Re: Render time

2012-06-25 Thread Melvyn Sopacua
On 25-6-2012 14:00, Larry Martell wrote:
> On Mon, Jun 25, 2012 at 5:56 AM, bruno desthuilliers
>  wrote:
>> On Monday, June 25, 2012 1:34:08 PM UTC+2, larry@gmail.com wrote:
>>>
>>>  Now they want me to add to that how long
>>> the browser takes to render the page
>>
>>
>> How would server code ever know this ?
> 
> My assumption is that it would be collected or calculated on the
> client side and sent back to the server. But I have no clue how that
> could be done (or even if it could be done).
> 

The issue is what your client's definitions are.
A browser starts rendering as soon it receives data. Is that your
starting point?
If your definition is that "as soon as all data is received" and until
browser has fully displayed things, this is a bit more difficult. First,
there's no event for this. The closest approximation is
"DOMContentLoaded", which is used by JQuery's documentready. The
difference between "all data received" and "DOM parsing done" is the cpu
cycles it takes to parse the main DOM tree. Since your clients already
are asking for fractions of seconds in the common case, this is significant.

Secondly, window.onload is your stoptime event, but this doesn't fire
until /everything/ is loaded. This means any networking problems with
content have to time out, but for the end user, everything displays
correctly. In fact, a user can click on to the next page before this
even fires.

So, reliably, you can't really do this and your best approximation is
the event firing times for window.onload minus DOMContentLoaded, or
JQuery's $(document).ready [1].
You can embed the row id for your statistics as a JavaScript variable in
your template.
And finally, you'd send the calculation back using Ajax requests,
something you'll find plenty of howto's for on the web.

[1]


-- 
Melvyn Sopacua


-- 
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: Render time

2012-06-25 Thread Deepak Kumar
I am no django expert ... but I guess you can do following ...

Get the timestamp when request first reaches your server
It does some processing
returns output to browser
use javascript to check if DOM loaded and get the timestamp
calculate time diff and send to the server again to save it.

Don't know if that ll help.

-deepak

On Mon, Jun 25, 2012 at 5:04 PM, Larry Martell wrote:

> This is not strictly a django question, but I'm hoping someone here
> has solved this and can help me. I have a client that has a django app
> that collects a bunch of server side statistics on the users
> activities - e.g. what reports they run, the number of rows returned,
> how long the query took, etc. Now they want me to add to that how long
> the browser takes to render the page after it gets the data. So I have
> 3 issues here:
>
> 1) How  can I even calculate that?
> 2) How I can return it back to the server?
> 3) Since the database table is updated with the other statistics
> before the data is sent to the browser, assuming I could calculate the
> render time and send it back, how could I find the row and update with
> that info?
>
> If anyone has already done something like this, or anyone has any
> advise on how I could do it (especially item #1), I'd really
> appreciate them sharing it with me.
>
> TIA!
> -larry
>
> --
> 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: convert str to datetime

2012-06-25 Thread Daniel Roseman
On Monday, 25 June 2012 13:07:19 UTC+1, armagan wrote:
>
> I don't know where does string come from. In shell date is a date object 
> and combine time dt is a datetime objects. It's ok. But I run the code I 
> have an errror. can't compare datetime.datetime to str. 
>
> item = Project.objects.order_by('-create_date')[:20] 
>
> delivery_date = models.DateField(_(u'Teslim Tarihi'), blank=True, null=
> True)
>

At a guess, the string is coming from the string that you return if 
delivery_date is empty.
--
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/-/TKobVVKOHbUJ.
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: Using now in an if

2012-06-25 Thread Daniel Roseman

On Monday, 25 June 2012 13:05:24 UTC+1, larry@gmail.com wrote:
>
> I'm trying to use now in an if like this: 
>
> {% if value|date:"Ymd" ==  now "Ymd" %} 
>
> This is failing with: 'Unused '"Ymd"' at end of if expression.' 
>
> If I quote it: 
>
> {% if value|date:"Ymd" ==  'now "Ymd"' %} 
>
> I don't get the syntax error, but the if does not evaluate to true 
> when the dates match. 
>
> I need to see if the date in {{ value }} is `today' - how can I do that? 
>
> -larry 
>

Write a custom "is_today" filter. Two lines of code.
--
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/-/hf5GL6_DOsUJ.
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: acces cleaned data from a dynamic form

2012-06-25 Thread het.oosten
The answer to question 1:
***
1. in the template i can only get a form with {{formset}} .
{{formset.dish}} doesn't work
***
Was as easy as {{formset.form.dish}}  (...sighs...)

>So hmm, you're re-presenting the form on the same url? I guess for
>debugging that works, but generally you'd redirect here.

This is only to get a basic prototype working. When it works i want to
redirect to another page with a confirmation.

When i enter in my form "Pancakes" and "Steak" this is the result:

[{}, {'dish': u'Steak'}]

-- 
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: convert str to datetime

2012-06-25 Thread armagan
I don't know where does string come from. In shell date is a date object 
and combine time dt is a datetime objects. It's ok. But I run the code I 
have an errror. can't compare datetime.datetime to str. 

item = Project.objects.order_by('-create_date')[:20] 

delivery_date = models.DateField(_(u'Teslim Tarihi'), blank=True, null=True)

On Monday, June 25, 2012 2:27:13 PM UTC+3, Melvyn Sopacua wrote:
>
> On 25-6-2012 10:42, armagan wrote: 
> > Hi, 
> > 
> > I'm trying to convert to str to datetime. "date object" must be datetime 
> > object. Can you help me? 
> > 
> >  def item_pubdate(self, item): # Yayinlanma Tarihi 
> > 
> > if item.delivery_date: 
> > 
> > date = item.delivery_date 
> So, that's a string and you need it to be a date object. Where does the 
> string come from and what does it look like? 
> -- 
> Melvyn Sopacua 
>
>
>

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



Using now in an if

2012-06-25 Thread Larry Martell
I'm trying to use now in an if like this:

{% if value|date:"Ymd" ==  now "Ymd" %}

This is failing with: 'Unused '"Ymd"' at end of if expression.'

If I quote it:

{% if value|date:"Ymd" ==  'now "Ymd"' %}

I don't get the syntax error, but the if does not evaluate to true
when the dates match.

I need to see if the date in {{ value }} is `today' - how can I do that?

-larry

-- 
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: Hey

2012-06-25 Thread bruno desthuilliers
On Monday, June 25, 2012 8:05:13 AM UTC+2, Pervez Mulla wrote:
>
> HI,
>
> How can I extract data from DB so that I can take that data n send it to 
> templates to display graphs according to DataBase values .
> How can I write view function for that?
>


Everything you need to know is here : https://docs.djangoproject.com


-- 
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/-/KZxMgro5DnkJ.
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: Render time

2012-06-25 Thread Larry Martell
On Mon, Jun 25, 2012 at 5:56 AM, bruno desthuilliers
 wrote:
> On Monday, June 25, 2012 1:34:08 PM UTC+2, larry@gmail.com wrote:
>>
>>  Now they want me to add to that how long
>> the browser takes to render the page
>
>
> How would server code ever know this ?

My assumption is that it would be collected or calculated on the
client side and sent back to the server. But I have no clue how that
could be done (or even if it could be done).

-- 
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: Render time

2012-06-25 Thread bruno desthuilliers
On Monday, June 25, 2012 1:34:08 PM UTC+2, larry@gmail.com wrote:
>
>  Now they want me to add to that how long 
> the browser takes to render the page
>

How would server code ever know this ? 

-- 
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/-/fWnI-Ri1WGQJ.
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: 403 error when POSTing to a view with csrf protection

2012-06-25 Thread Melvyn Sopacua
Hi Mike,

> POST: [u'']}>,
> COOKIES:{'csrftoken': 'qsl91ZDqVL5wirXlUwIYmu8ytTVES3nt'},
>  'CSRF_COOKIE': 'qsl91ZDqVL5wirXlUwIYmu8ytTVES3nt',
>  'CSRF_COOKIE_USED': True,
>  'HTTP_COOKIE': 'csrftoken=qsl91ZDqVL5wirXlUwIYmu8ytTVES3nt',
>  'HTTP_HOST': '127.0.0.1:8000',

Since this all looks sane, what's the different with a 'real browser'
(no disrespect to your desktop app :) )? I'm not seeing anything wrong
here, so it must be something subtle. Or is a 'real browser' rejected as
well?
-- 
Melvyn Sopacua


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



Render time

2012-06-25 Thread Larry Martell
This is not strictly a django question, but I'm hoping someone here
has solved this and can help me. I have a client that has a django app
that collects a bunch of server side statistics on the users
activities - e.g. what reports they run, the number of rows returned,
how long the query took, etc. Now they want me to add to that how long
the browser takes to render the page after it gets the data. So I have
3 issues here:

1) How  can I even calculate that?
2) How I can return it back to the server?
3) Since the database table is updated with the other statistics
before the data is sent to the browser, assuming I could calculate the
render time and send it back, how could I find the row and update with
that info?

If anyone has already done something like this, or anyone has any
advise on how I could do it (especially item #1), I'd really
appreciate them sharing it with me.

TIA!
-larry

-- 
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: convert str to datetime

2012-06-25 Thread Melvyn Sopacua
On 25-6-2012 10:42, armagan wrote:
> Hi,
> 
> I'm trying to convert to str to datetime. "date object" must be datetime 
> object. Can you help me?
> 
>  def item_pubdate(self, item): # Yayinlanma Tarihi
> 
> if item.delivery_date:
> 
> date = item.delivery_date
So, that's a string and you need it to be a date object. Where does the
string come from and what does it look like?
-- 
Melvyn Sopacua


-- 
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: 403 error when POSTing to a view with csrf protection

2012-06-25 Thread Mike
Hi Kurtis - 

The problem is that the client is not a web browser.  Its desktop 
application that I'm developing for Mac OS using the Cocoa frameworks.  The 
Django server will process user's data and return it to the user's desktop 
application.  The desktop app will communicate with the django server via 
https using JSON.  Right now I'm trying to set up authentication. I have 
set up authentication for Django before , in a traditional web app (in 
another project) and it all works as expected.  Now I'm trying to do it 
again using my desktop app as the client and I can't get authentication to 
work.  As Cal said, I'm probably not providing enough information for 
anyone to help me here, but I'll try again.

Here are the steps I'm trying to accomplish:

1) desktop app sends a GET request to a Django view.  the purpose of this 
is to get the csrf token that will be used for the rest of the session. 
 This django view function has the @ensure_csrf_cookie decorator to ensure 
that it will send the csrf token even though I'm not using a template and 
the template tag.

2) Desktop app sends a POST request with JSON in the body to log the user 
into the django app.  The json contains the user's userid and password. The 
request also contains the csrf cookie.

Steps 1 and 2 are using the same view function (below).  When the desktop 
app sends the POST request in step 2, I get the 403 error that I described 
previously, and the function is never called.  If I add the @csrf_exempt 
decorator, then I can get the view function to execute the if 
request.method == 'POST': block shown below.  It seems like the csrf cookie 
isn't being sent with the POST request, which is why I added the 
@csrf_exempt decorator and the print request statement in the code below. 
 that enables me to see the request object that is sent to the Django view. 
 the request does indeed contain the csrf cookie.  See the block of text ad 
the end of this message.

@ensure_csrf_cookie
@csrf_exempt
def login(request):
print 'received login request using method ' + request.method
if request.method == 'POST':
# todo: login user
print request

else: # must be a GET.  return the csrf token
c = {}
c.update(csrf(request))
return render_to_response('empty.html', c)


When client app performs the two steps described above, it calls this 
function twice, once with a GET and once with a POST.  in the POST, the 
request object is printed to stdout.  Here are the first few lines of the 
output showing that the csrf cookie is included with the request:

 GET:,
POST:,
COOKIES:{'csrftoken': 'qsl91ZDqVL5wirXlUwIYmu8ytTVES3nt'},
META:{'Apple_PubSub_Socket_Render': '/tmp/launch-ZubgcP/Render',
 'Apple_Ubiquity_Message': '/tmp/launch-BfYBfH/Apple_Ubiquity_Message',
 'COMMAND_MODE': 'unix2003',
 'CONTENT_LENGTH': '47',
 'CONTENT_TYPE': 'application/json',
 'CSRF_COOKIE': 'qsl91ZDqVL5wirXlUwIYmu8ytTVES3nt',
 'CSRF_COOKIE_USED': True,
 'DISPLAY': '/tmp/launch-EruXcM/org.x:0',
 'DJANGO_SETTINGS_MODULE': 'nsserver.settings',
 'EDITOR': 'nano',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HOME': '/Users/mike',
 'HTTP_ACCEPT': 'application/json',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-us',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_COOKIE': 'csrftoken=qsl91ZDqVL5wirXlUwIYmu8ytTVES3nt',
 'HTTP_HOST': '127.0.0.1:8000',


As I mentioned earlier, the purpose of the initial GET request is only to 
get the csrf cookie that will be used in the rest of the session.  Now I'm 
wondering I'm setting up the csrf token correctly in that block of code.



>

-- 
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/-/54ivyoW39DMJ.
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: DISTINCT ON fields is not supported by this database backend

2012-06-25 Thread Mário Neto
What's your database backend?
https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.distinct


Note

This ability to specify field names is only available in PostgreSQL.


[]s

2012/6/24 Marcin Tustin 

> DISTINCT ON fields is not supported by this database backend
>
> What more is there to say? Either stop using the distinct method, or switch 
> to another database backend.
>
>
> On Sun, Jun 24, 2012 at 11:24 AM, upmauro  wrote:
>
>> Please help,
>>
>> http://dpaste.com/762942/
>>
>> Thanks alot !
>>
>> --
>> 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/-/v5qIbmtR5ZwJ.
>> 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.
>>
>
>
>
> --
> Marcin Tustin
> Tel: 07773 787 105
>
>
>  --
> 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.
>



-- 
Att. *Mário Araújo Chaves Neto*
*Programmer, Designer and U.I. Engineer*
*
*
*MBA in Design Digital* - 2008 - FIC
*Analysis and Systems Development* - 2011 - Estácio
*D**esign and Implementation of Internet Environments* - 2003 - FIC

-- 
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: acces cleaned data from a dynamic form

2012-06-25 Thread Melvyn Sopacua
On 25-6-2012 12:52, het.oosten wrote:
> Thank you for your help!
> 
>> I don't understand your questions.
> 
> I am sorry about that, I probably ask my question the wrong way
> because of my lack of experience
> 
>> A formset is a set of forms. What would {{ formset.dish }} even refer to?
>> Only the forms inside the formset have a `dish` field.
> 
> When I try {% for form in formset %}{{form.dish}}
> 
> I get a "non iterable" error
The error doesn't apply to form.dish. Iterable errors refer to trying to
walk a variable that can't be walked, so the issue here is that formset
is not walkable. The code here irks me, cause you're using names that
may apply to django code. So just to be sure that's not the case, in
your view pass the DishesFormset() to the template as 'dishes_ordered'
or just 'borden' (using non-english language for variable names is a
good way to duck name clashes, allthough it makes it less readable for
people not familiar with the language).


> def testform(request):
> if request.method == 'POST':
>   form = AddressForm(request.POST)
> formset = DishesFormset(request.POST)
> if formset.is_valid():
> return render_to_response('test', {
> 'form_data': formset.cleaned_data,
> })

So hmm, you're re-presenting the form on the same url? I guess for
debugging that works, but generally you'd redirect here.
-- 
Melvyn Sopacua


-- 
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: acces cleaned data from a dynamic form

2012-06-25 Thread het.oosten
Thank you for your help!

> I don't understand your questions.

I am sorry about that, I probably ask my question the wrong way
because of my lack of experience

> A formset is a set of forms. What would {{ formset.dish }} even refer to?
> Only the forms inside the formset have a `dish` field.

When I try {% for form in formset %}{{form.dish}}

I get a "non iterable" error

In order to style the form right I need to call the seperate
formfields.

>
> Question 2 is impossible to answer without seeing your view code.
> --
> DR.

My views.py is very basic so not much to show (see below). When I view
the POST info all information is posted right. One address, Dish1,
Dish2 The only thing i want is validate the form and show/mail the
results. When i try "for form in formset.cleaned_data" i get that "non
iterable" error again.

Till now i only managed to validate and show Dish1. I probably oversee
something very basic.

def testform(request):
if request.method == 'POST':
form = AddressForm(request.POST)
formset = DishesFormset(request.POST)
if formset.is_valid():
return render_to_response('test', {
'form_data': formset.cleaned_data,
})
else:
form = AddressForm()
formset = DishesFormset()
return render_to_response('testform', {
'form': form,
'formset': formset,
}, context_instance = RequestContext(request))

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



Custom SQL for creating django tables

2012-06-25 Thread Mina Farid
Hello guys,
I am connection from django to Apache Derby. I am using IBM DB2 driver 
backend.
Django tables are created in DB2 syntax, which is not very compatible with 
Derby.

Is there any way that I can force django to customize the creation of SQL 
to a certain (say SQL standard) syntax?

Thanks a lot
Mina

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



Hey

2012-06-25 Thread Pervez Mulla
HI,

How can I extract data from DB so that I can take that data n send it to
templates to display graphs according to DataBase values .
How can I write view function for that?


Thank You
Pervez

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



ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

2012-06-25 Thread totechess
Tengo el siguiente problema. Con la última actualización de django 1.5
supongamos estoy en un directorio x y al hacer django-admin
startproject miProyecto me genera la carpeta miProyecto con la
siguiente estructura

manage.py
miProyecto/
   __init__.py  settings.py  urls.py  wsgi.py

al posicionarme en el directorio raiz del proyecto me lanza el
siguiente error
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

Anterior a esta version no me generaba esta estructura de archivos.
¿Como puedo corregir el problema?

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



how to ues render_comment_form correctly

2012-06-25 Thread dragonfly
HI, everyone.
Some questions about the render_comment_form tag and the
get_comment_form tag make me confused.
Here is my code:
#blog_detail.html

{% extends "base.html" %}
{% block content %}
{{ post.title }}
{{ post.timestamp }}
{{ post.body }}
{% load comments %}
{% render_comment_form for post  %}
{% endblock %}

When I submit the form, "CSRF verification failed. Request aborted."
appears.
I have installed the comments app as the document said.
I don't write a view, because I think there is a default view to do
this.
Thank you for helping me.

yours

-- 
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: change default date format to dd-mm-YYYY

2012-06-25 Thread Harjot Mann
just write d=models.DateField() in yor models.py file

On Mon, Jun 25, 2012 at 2:38 PM, ledzgio  wrote:

> Very useful, thanks.
> But how can I change the date format also in the admin interface when
> using DateField?
>
> Il giorno lunedì 25 giugno 2012 11:05:38 UTC+2, Mike Dewhirst ha scritto:
>
>> On 25/06/2012 6:51pm, ledzgio wrote:
>> > How can I change default project/app date format to dd-mm-?
>>
>> This is straight from the Python 2.7 docs.
>>
>> >>>import datetime
>> >>>d = datetime.datetime(2010, 7, 4, 12, 15, 58)
>>  >>> '{:%Y-%m-%d%H:%M:%S}'.format(**d)
>> '2010-07-04 12:15:58'
>>
>> or in a template ...
>> https://docs.djangoproject.**com/en/dev/ref/templates/**builtins/#date
>>
>> hth
>>
>> Mike
>>
>> >
>> > thanks
>> > --
>> > 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/-/**Z3fcdtqKpvYJ.
>>
>> > 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.
>>
>>
>>
>>
> Il giorno lunedì 25 giugno 2012 11:05:38 UTC+2, Mike Dewhirst ha scritto:
>
>> On 25/06/2012 6:51pm, ledzgio wrote:
>> > How can I change default project/app date format to dd-mm-?
>>
>> This is straight from the Python 2.7 docs.
>>
>> >>>import datetime
>> >>>d = datetime.datetime(2010, 7, 4, 12, 15, 58)
>>  >>> '{:%Y-%m-%d%H:%M:%S}'.format(**d)
>> '2010-07-04 12:15:58'
>>
>> or in a template ...
>> https://docs.djangoproject.**com/en/dev/ref/templates/**builtins/#date
>>
>> hth
>>
>> Mike
>>
>> >
>> > thanks
>> > --
>> > 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/-/**Z3fcdtqKpvYJ.
>>
>> > 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.
>>
>>
>>
>>
> Il giorno lunedì 25 giugno 2012 11:05:38 UTC+2, Mike Dewhirst ha scritto:
>
>> On 25/06/2012 6:51pm, ledzgio wrote:
>> > How can I change default project/app date format to dd-mm-?
>>
>> This is straight from the Python 2.7 docs.
>>
>> >>>import datetime
>> >>>d = datetime.datetime(2010, 7, 4, 12, 15, 58)
>>  >>> '{:%Y-%m-%d%H:%M:%S}'.format(**d)
>> '2010-07-04 12:15:58'
>>
>> or in a template ...
>> https://docs.djangoproject.**com/en/dev/ref/templates/**builtins/#date
>>
>> hth
>>
>> Mike
>>
>> >
>> > thanks
>> > --
>> > 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/-/**Z3fcdtqKpvYJ.
>>
>> > 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.
>>
>>
>>
>>
> Il giorno lunedì 25 giugno 2012 11:05:38 UTC+2, Mike Dewhirst ha scritto:
>
>> On 25/06/2012 6:51pm, ledzgio wrote:
>> > How can I change default project/app date format to dd-mm-?
>>
>> This is straight from the Python 2.7 docs.
>>
>> >>>import datetime
>> >>>d = datetime.datetime(2010, 7, 4, 12, 15, 58)
>>  >>> '{:%Y-%m-%d%H:%M:%S}'.format(**d)
>> '2010-07-04 12:15:58'
>>
>> or in a template ...
>> https://docs.djangoproject.**com/en/dev/ref/templates/**builtins/#date
>>
>> hth
>>
>> Mike
>>
>> >
>> > thanks
>> > --
>> > 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/-/**Z3fcdtqKpvYJ.
>>
>> > To post to this group, send email to 

Re: change default date format to dd-mm-YYYY

2012-06-25 Thread ledzgio
Very useful, thanks. 
But how can I change the date format also in the admin interface when using 
DateField?

Il giorno lunedì 25 giugno 2012 11:05:38 UTC+2, Mike Dewhirst ha scritto:
>
> On 25/06/2012 6:51pm, ledzgio wrote: 
> > How can I change default project/app date format to dd-mm-? 
>
> This is straight from the Python 2.7 docs. 
>
> >>>import datetime 
> >>>d = datetime.datetime(2010, 7, 4, 12, 15, 58) 
>  >>> '{:%Y-%m-%d%H:%M:%S}'.format(d) 
> '2010-07-04 12:15:58' 
>
> or in a template ... 
> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date 
>
> hth 
>
> Mike 
>
> > 
> > thanks 
> > -- 
> > 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/-/Z3fcdtqKpvYJ. 
> > 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. 
>
>
>
Il giorno lunedì 25 giugno 2012 11:05:38 UTC+2, Mike Dewhirst ha scritto:
>
> On 25/06/2012 6:51pm, ledzgio wrote: 
> > How can I change default project/app date format to dd-mm-? 
>
> This is straight from the Python 2.7 docs. 
>
> >>>import datetime 
> >>>d = datetime.datetime(2010, 7, 4, 12, 15, 58) 
>  >>> '{:%Y-%m-%d%H:%M:%S}'.format(d) 
> '2010-07-04 12:15:58' 
>
> or in a template ... 
> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date 
>
> hth 
>
> Mike 
>
> > 
> > thanks 
> > -- 
> > 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/-/Z3fcdtqKpvYJ. 
> > 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. 
>
>
>
Il giorno lunedì 25 giugno 2012 11:05:38 UTC+2, Mike Dewhirst ha scritto:
>
> On 25/06/2012 6:51pm, ledzgio wrote: 
> > How can I change default project/app date format to dd-mm-? 
>
> This is straight from the Python 2.7 docs. 
>
> >>>import datetime 
> >>>d = datetime.datetime(2010, 7, 4, 12, 15, 58) 
>  >>> '{:%Y-%m-%d%H:%M:%S}'.format(d) 
> '2010-07-04 12:15:58' 
>
> or in a template ... 
> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date 
>
> hth 
>
> Mike 
>
> > 
> > thanks 
> > -- 
> > 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/-/Z3fcdtqKpvYJ. 
> > 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. 
>
>
>
Il giorno lunedì 25 giugno 2012 11:05:38 UTC+2, Mike Dewhirst ha scritto:
>
> On 25/06/2012 6:51pm, ledzgio wrote: 
> > How can I change default project/app date format to dd-mm-? 
>
> This is straight from the Python 2.7 docs. 
>
> >>>import datetime 
> >>>d = datetime.datetime(2010, 7, 4, 12, 15, 58) 
>  >>> '{:%Y-%m-%d%H:%M:%S}'.format(d) 
> '2010-07-04 12:15:58' 
>
> or in a template ... 
> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date 
>
> hth 
>
> Mike 
>
> > 
> > thanks 
> > -- 
> > 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/-/Z3fcdtqKpvYJ. 
> > 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. 
>
>
>
Il giorno lunedì 25 giugno 2012 11:05:38 UTC+2, Mike Dewhirst ha scritto:
>
> On 25/06/2012 6:51pm, ledzgio wrote: 
> > How can I change default project/app date format to dd-mm-? 
>
> This is straight from the Python 2.7 docs. 
>
> >>>import datetime 
> >>>d = datetime.datetime(2010, 7, 4, 12, 15, 58) 
>  >>> '{:%Y-%m-%d%H:%M:%S}'.format(d) 
> '2010-07-04 12:15:58' 
>
> or in a template ... 
> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date 
>
> hth 
>
> Mike 
>
> > 
> > thanks 
> > -- 
> > 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/-/Z3fcdtqKpvYJ. 
> > To post to this group, send email to django-users@googlegroups.com. 
> > To unsubscribe from this group, 

Re: change default date format to dd-mm-YYYY

2012-06-25 Thread ledzgio


Il giorno lunedì 25 giugno 2012 10:51:43 UTC+2, ledzgio ha scritto:
>
> How can I change default project/app date format to dd-mm-? 
>
> thanks
>

-- 
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/-/kUwDFYvf_nkJ.
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: change default date format to dd-mm-YYYY

2012-06-25 Thread Mike Dewhirst

On 25/06/2012 6:51pm, ledzgio wrote:

How can I change default project/app date format to dd-mm-?


This is straight from the Python 2.7 docs.


import datetime
d = datetime.datetime(2010, 7, 4, 12, 15, 58)

>>> '{:%Y-%m-%d%H:%M:%S}'.format(d)
'2010-07-04 12:15:58'

or in a template ... 
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date


hth

Mike



thanks
--
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/-/Z3fcdtqKpvYJ.

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: convert str to datetime

2012-06-25 Thread Daniel Roseman
On Monday, 25 June 2012 09:42:27 UTC+1, armagan wrote:
>
> Hi,
>
> I'm trying to convert to str to datetime. "date object" must be datetime 
> object. Can you help me?
>
>  def item_pubdate(self, item): # Yayinlanma Tarihi
>
> if item.delivery_date:
>
> date = item.delivery_date
>
> dt = datetime.combine(date, time())
>
> return dt
>
> else:
>
> return ' '
>

No, we can't help you. What is `item.delivery_date`? What does `str` have 
to do with anything? What is the relevance of '"date object" must be 
datetime object' - is that an error message you are getting? If so, why 
don't you post the actual traceback, which is full of useful debugging 
information?
--
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/-/SL3qDuQ7N5MJ.
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.



change default date format to dd-mm-YYYY

2012-06-25 Thread ledzgio
How can I change default project/app date format to dd-mm-? 

thanks

-- 
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/-/Z3fcdtqKpvYJ.
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: acces cleaned data from a dynamic form

2012-06-25 Thread Daniel Roseman
On Sunday, 24 June 2012 15:36:27 UTC+1, het.oosten wrote:
>
> Django 1.2.3 
>
> For a restaurant i want to make a form, were the user can add their 
> address, and their order. The order part is dynamic (users can add 
> extra fields). I used jquery.formset for this. 
>
> To accomplish this i have an address form and a dishes formset: 
>
> class Address(models.Model): 
> name = models.CharField(max_length=20) 
>
> class AddressForm(ModelForm): 
> class Meta: 
> model = Address 
>
> class DishesForm(forms.Form): 
> dish = forms.CharField(max_length=200) 
>
> DishesFormset = formsets.formset_factory(DishesForm) 
>
> In the view i call these forms with: form = AddressForm()  formset = 
> DishesFormset() 
>
> I have two problems with the formset: 
>
> 1. in the template i can only get a form with {{formset}} . 
> {{formset.dish}} doesn't work 
> 2. how do i access the cleaned_data from the formset? When I test I 
> see in the POST that multiple dishes are posted, but I can only get 
> the first one in the cleaned_data 
>
> Rob


I don't understand your questions.

A formset is a set of forms. What would {{ formset.dish }} even refer to? 
Only the forms inside the formset have a `dish` field.

Question 2 is impossible to answer without seeing your view code. 
--
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/-/JgpB81vHKwoJ.
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.



convert str to datetime

2012-06-25 Thread armagan
Hi,

I'm trying to convert to str to datetime. "date object" must be datetime 
object. Can you help me?

 def item_pubdate(self, item): # Yayinlanma Tarihi

if item.delivery_date:

date = item.delivery_date

dt = datetime.combine(date, time())

return dt

else:

return ' '

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

2012-06-25 Thread Derek
Emily

If you are starting a new topic, please start a new thread - and again, as 
per the guidelines for using the mailing list that Cal referred to, the 
more specific your question, the more chance of getting a reply. :)

On Friday, 22 June 2012 17:14:34 UTC+2, Emily N wrote:
>
> Kurtis, Adrian and Daniel,
>
> thank you so much for your help, it actually worked
> I have programmed in java 70% of my life
>
> Now I want to send sms to my users when they sign up
> in the website. There is some package I have seen which looks 
> like it is from an email to the phone. Does it work with messages
> from a website to a phone...
>
> Emily
>
>

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



django and jquery data grids

2012-06-25 Thread rafiee.nima
Hi 
I want to know what is the most compatible and straight forward  jquery 
data grid plugin for django
and also how I can integrated jqgrid with django 

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