Re: Proto-newbie needs Django for running an app, not for dev work

2010-09-17 Thread Brett Thomas
Thanks for the thorough email. Hopefully somebody else can tell you more
about what you did bc I'm not that familiar with the Django internals, but
shared hosting is just hard to navigate. (I assume you are using a shared
hosting account, thus the sudo command - run as administrator - doesn't
work.) I don't think it's possible to give comprehensive instructions on how
to install Django on a shared hosting account. In my experience, they all
work pretty differently. I'd open a support ticket with your hosting
provider, and see if they have advice on how to install Django.

That said, I agree that somebody with your experience should be able to go
to djangoproject.com and learn how to install a dependent app.

On Fri, Sep 17, 2010 at 1:51 PM, Thomas  wrote:

> My first post on this list. I wish to try out a blogging app developed
> in Django, called Mango, and according to its instructions I just need
> to get Django installed. I'm looking for a little guidance with this.
> Also, I'd like to determine just what kind of mess I've created with
> my attempts at installation so far.
>
> I'm essentially a non-programmer, though I don't mind using the
> Terminal in OS X now and then, and I've learned a little PHP. I heard
> Mango mentioned on the Markdown discussion list.
>
> Steps taken so far:
>
> 1. Per instructions at mango.io/docs/, I downloaded
> Django-1.2.3.tar.gz (to my desktop, since no destination was
> mentioned).
>
> 2. Uploaded it to my domain via FTP. Again, since the docs mention no
> destination, I put it in the same directory as my home page. I know
> this is probably not the location the developers intended, but,
> finding no mention of what they DO intend, I figured this location
> would either cause the subsequent steps to work or harmlessly fail.
>
> 3. Consulted my host's instructions on how to open an SSH connection,
> and, using Terminal, navigated to the Django file I'd uploaded.
>
> 4. Per instructions at djangoproject.com for "Installing an official
> release", I ran "tar xzvf Django-1.2.3.tar.gz", changed to the new
> Django directory, and ran "sudo python setup.py install". When
> authentication failed (and for what reason, I have no idea, as I used
> the same password), I ran "python setup.py install" instead.
>
> 5. A lot of stuff went by on the screen, and I saw that one of the
> last lines said that the command to modify "python/site-packages" (OR
> SOMETHING LIKE THAT, SO PLEASE DON'T QUOTE ME) had failed due to
> denial of permission.
>
> Well, my home page still is up, and I haven't received any calls or
> emails from my ISP (the always-excellent Tiger Technologies, at
> tigertech.net). So even though the install command made SOMETHING
> happen, it appears harmless for now. But I'd really like to know what
> I just did to my server and its files, not to mention my bits of MySQL
> database left over from playing with WordPress and Sphider.
>
> If nothing else comes of this, I'd like to at least point out that the
> Django documentation assumes a lot of prior knowledge about these
> things. It may be common knowledge for programmers, but not for
> everyone who might wish to try out a Django-dependent app.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Should CSRF Middleware return 403 or 500 error from AJAX call?

2010-11-15 Thread Brett Thomas
Hi there,

Ran into some unexpected CSRF behavior - not sure if it's desired or a bug.
An AJAX request that includes the "X-Requested-With: XMLHttpRequest" header
but does not include csrf token will bypass CSRF middleware. If you hit
server error (mine was a TypeError), response has error code 500,  as
expected. But, if Debug=True, the content of the error message is 403
Forbidden content - thus no information about where the error originated -
and response code is still 500.

I couldn't find any documentation or discussion about why this would be
desired. Is it a bug?

Thanks,
Brett

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



Re: Django timestamp to Javascript timestamp

2010-11-29 Thread Brett Thomas
I found it easiest to use the javascript date constructor with a date
string. Just have Django output the date in whatever time zone you want it
displayed to the user:

var d=new Date("November 29, 2010 9:22:00");

Unfortunately Django's default Date display, the ISO standard, prints a
string that cannot be read by javascript, so:

var d=new Date("{{ mymodel.date }}");

will not work out of the box.

If you change the DATETIME_FORMAT setting to "r", some other standard, the
above will work.

Also...you are using a DateTimeField, not a DateField, right?




On Mon, Nov 29, 2010 at 8:47 PM, Bill Freeman  wrote:

> Unix (and python) timestamps are also from the beginning of Jan 1, 1970,
> but are
> in seconds, so you might think that multiplying by 1000 would be enough.
>  But
> unix timestamps (and, presumably, their emulation on Windows) are in GMT,
> while
> JavaScript, if memory serves, uses the browser's local machine's timezone.
>  JS
> data/time manipulations have enough stuff to fix this, but you have to
> work a bit,
> including considering whether you are in daylight savings time, etc..
>
> Bill
>
> On Mon, Nov 29, 2010 at 1:16 PM, Matt  Thompson 
> wrote:
> > Hello guys and girls,
> >
> > I'm looking to use Flot to graph some data I have in my Django app.
> > I'd like to graph a time based query and need to get the time is
> > Javascript format (milliseconds since 01/01/1970).
> >
> > I can get it into seconds\unix format, this is seconds since
> > 01/01/1970, but not milliseconds.
> >
> > Can anyone help?
> >
> > Thanks,
> > Matt
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: django to php

2010-11-30 Thread Brett Thomas
Time better spent learning django :)
On Nov 30, 2010 9:24 AM, "Tom Evans"  wrote:
> On Tue, Nov 30, 2010 at 7:26 AM, Akash Mukherjee 
wrote:
>> Hello,
>>
>> I have a webapp created in django. Now I want to convert the entire
>> code into PHP. Is it possible?? If yes, how?
>>
>> Thanks
>>
>> Akash
>>
>
> Anything is possible given enough resource. I am not aware of any
> tools that would automatically convert from django to PHP - I would
> doubt they exist, given the architectural differences between django
> and PHP.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: Django, Python, AJAX position

2010-11-30 Thread Brett Thomas
If nobody responded to you yesterday, you might want to revise the post with
some more details, rather than just re-posting it. It's not worth most good
developers' time to inquire about 2 sentence job posts that are really
ambiguous...

On Tue, Nov 30, 2010 at 10:37 AM, Bita Bita  wrote:

> My client  is in an immediate need for a front end engineer who knows
> Django, Python, AJAX, and/or html5 . This is a full time position with
> a really good pay in Palo Alto, CA. Sent me your updated resume if
> interested. The candidate should have work permit.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: is there a way to cascade foreign keys?

2010-01-26 Thread Brett Thomas
I'm fairly new to django - please correct me if this isn't a good solution.

I ran in to a similar issue recently, and found it alot easier to have the
ajax views return full html rather than json. So load the page with empty
divs for each dropdown, then displaying the second form is much easier:

show_models() {

$.post("ajax/modelsurl", function(data){
  $("#models_div").html(data);
});

}

But note that you should still use the json serializer to encode the html
string

On Tue, Jan 26, 2010 at 12:07 PM, Atamert Ölçgen  wrote:

> On Tuesday 26 January 2010 18:26:55 shofty wrote:
> > I'm trying to build an app which im calling selector. It allows a user
> > to select from a form of dropdowns their vehicle.
> >
> > the problem im facing is a design one. i just dont know how best to
> > design this and i've spent ages trying to find an example that does
> > the same thing. but i can't find one.
> >
> > so a vehicle is thus:
> > make
> > - model
> > - - year
> > - - - trim
> >
> > and my idea for the view was a simple one of four dropdowns, whose
> > content changed as you amended the others. so you'd choose make and
> > model would appear populated with all models for the make selected.
> > and so on.
> >
> > I've come to the understanding that there is no built in way to do
> > this in django/python projects due to its static nature and that im
> > going to involve an amount of javascript.
> >
> > what i'd really hoped to do, was find a way that i can create in the
> > view various querys for the dropdowns and on selection of one of the
> > dropdowns, tie the selection to the query, returning a dictionary to
> > the next dropdown, populating it with relevant data.
> >
> > if i resort to use of js (of which there is plenty of examples) i'm
> > going to struggle to tie it back to my database. aren't i?
> >
> > im not asking someone to code this for me, design clues and links to
> > examples much appreciated.
> You will either use JavaScript to populate SELECTs for remaining options or
> reload the page onChange via JavaScript. So your options are limited; it's
> JavaScript or JavaScript.
>
> I would supply AJAX views that return requested options as JSON. The rest
> is
> client-side coding (IOW not Django related). Plenty of AJAX with Django
> examples out there on intertubes.
>
>
> --
> Saygılarımla,
> Atamert Ölçgen
>
>  -+-
>  --+
>  +++
>
> www.muhuk.com
> mu...@jabber.org
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



URL design - why the trailing slash?

2010-01-27 Thread Brett Thomas
Most of the URLConf examples I run across use a trailing slash on all URLs:
www.example.com/profile/

I'm not sure why, but I don't like this. I think it looks nicer without:
www.example.com/profile

Are there any performance or security reasons to use the trailing slash in
Django? Seems like there could be some quirk with regular expressions that
I'm not thinking of...

Thanks --
Brett

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



Best practices for restricting media?

2010-02-21 Thread Brett Thomas
Hey, this is a pretty basic sysadmin question, but seems pretty critical for
django development. What's the best way to limit media on a django site to
certain users?

A typical example is a photo gallery app. Suppose you are recreating Flickr,
and a user's photos should only be viewable by his/her friends. You can
restrict other users from accessing the django view that presents the photo.
But if the image is on a static media server, the image is still publicly
accessible by its direct URL.

So, question is: can you add restrictions to a media server connected to
django to say "this image can only be served in a page that was rendered by
a django view"?

Thanks for the help --
Brett

Surprisingly (or not?) Facebook has no such permissions...here's a random
photo from one of my friend's private albums that apparently you can see
without even having a facebook account:
http://photos-f.ak.fbcdn.net/photos-ak-snc1/v2681/23/22/30008/n30008_36329813_2721261.jpg

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



Aggregating answers from different question types

2010-04-01 Thread Brett Thomas
Hey, this is a pretty basic schema question, but I'm wondering how to best
implement it in Django.

I have an app that collects user data from a few different question types:
multiple choice questions, true/false questions, numerical questions, etc.
I'll have a bunch of queries that aggregate all answers from a given user.
What's the best ways to store these answers? A few possibilities:
-- Different models for the different types: MultipleChoiceAnswer,
NumericalAnswer, BooleanAnswer classes, etc.
-- One abstract Answer class that the above inherit
-- One basic Answer class with a type field, and a generic foreignkey to one
of the other models.
-- Is there a better way?

Thanks in advance,
Brett

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