let the users download files

2011-06-28 Thread pankaj sharma
hello friends ,
i have a database in which i have some files say photos...
{i am uploading photos from django admin.}
i want to make a template so that the users of my website can download
these photos ..
so can anyone provide me some useful information or any link

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



Comparing ManyToManyFields

2011-06-28 Thread Josh Lothian
So I'm working on my first Django application, and I've run into a
stumbling block.  In simplest terms, I've got two objects:

def Package(models.Model):
name=models.CharField(max_length=255)
version=models.CharField(max_length=128)

def Machine(models.Model):
hostname=models.CharField(max_length=255)
installed_packages=models.ManyToManyField(Package)

I'm reading in information from some file, and need to compare against
objects already in the database.  Ideally, I could just create these
objects in my code, compare to the existing Django objects, and add a
new entry if it's different from anything that exists already.

However, I've got that dang ManyToManyField in there, meaning I need
to first commit a Machine to the DB, and then add Packages to it.
Otherwise, of course I get:

ValueError: 'Machine' instance needs to have a primary key value before a 
many-to-many relationship can be used.

This seems non-ideal, since there's a pretty good chance I'll just
need to delete it from the database as a dupe of an existing Machine.

I see a couple of ways around this:

- Instantiate a Machine and a list of Packages, and compare them
separately.  This isn't ideal, as my real objects likely have more
than 1 many-to-many relationship.

- Do database queries and whatnot directly.  Yuck!

- Punt and just add/remove things from the database.  This would
probably work fine now, but later on could definitely lead to scaling
issues.

Am I missing an obvious solution here?  I've scoured the docs and
can't seem to come up with anything that doesn't make me feel icky.

-josh

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



forms and form processing

2011-06-28 Thread jay K.

Hello,

I need to add a form on my django website

so far this is what i have:

in my models.py:

 import statements not shown here

CONTACT_OPTIONS = (
 ('skype video anruf','Skype Video-
Anruf'),
 ('skype anruf ','Skype Anruf'),
 ('telefon','Telefon')
)

class ContactForm(forms.Form):

#wann
date_input = forms.CharField(max_length=30, required=True) #,
initial="MO-FR"
time_input = forms.CharField(max_length=30, required=True) # 14:00
- 22:00

#wie
choice_options = forms.ChoiceField(widget=RadioSelect,
choices=CONTACT_OPTIONS, required=True)

#contact
email = forms.EmailField(max_length=30, required=True)
telephone = forms.CharField(max_length=30, required=False)
skype = forms.CharField(max_length=30, required=False)

#comment
comment_text = forms.CharField(widget=forms.Textarea,
required=False)


my views.py


from website.contact.models import ContactForm
from django.shortcuts import render_to_response
from django.template.context import RequestContext
from django.http import HttpResponseRedirect, HttpResponse
from django.core.mail import send_mail

def contact(request):

if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST
data

if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data

subject = form.cleaned_data['subject']
message = form.cleaned_data['message']
sender = form.cleaned_data['sender']
cc_myself = form.cleaned_data['cc']

date_input = form.cleaned_data['date input']
time_input = form.cleaned_data['time input']
choice_options = form.cleaned_data['contact options']

telephone = form.cleaned_data['telefone']
email = form.cleaned_data['email'] # this is the sender's
email
skype = form.cleaned_data['skype']

comment_text = form.cleaned_data['comment text']

"""
recipients = ['joung.k...@lingua-group.org']
if cc_myself:
recipients.append(sender)
"""
   #subject
send_mail('subject', 'message', 'myem...@myemail.com',
['myem...@myemail.com', email], fail_silently=False)

return HttpResponseRedirect('/danke/')

else:
form = ContactForm() # An unbound form

return render_to_response('beratungstermin.html', {'form': form},
context_instance=RequestContext(request))


And on the website I have all the fields inside the form tag

{{ forms.as_p }}


What I want to do basically is to add the fields for name, email, tel,
some of them being compulsory, so the form should not be processed if
there is some info. missing.

I also want to receive a confirmation email whenever a user sends
information through the page, to my "myem...@myemail.com" (this is not
working on my code either), and a "CC" button if the user wants a copy
of his/her own message.

Thanks

Let me know if you need any details


PS: i copied most of the code from the official django tutorial at
https://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs , but
somehow I do not receive any emails after hitting the submit button.
Also, even if I declared in my views.py that some fields are
"required=True", I can still hit the send button with no error
messages for those unfilled textfields.

-- 
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: widgets js

2011-06-28 Thread Andres Pardini
Hi

Can you can access to the javascript calendar code from browser??

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



Global generic files? Best practice(s)?

2011-06-28 Thread Micky Hulse
Hello,

I was going to start a "global" app for a generic "helpers.py" file; I
plan on using this code in multiple apps.

Question: Is creating a generic app a standard approach to storing
"global" code?

...

If the answer to the above question is "yes":

What's your preferred approach to handling generic/global code?

When using a "global" app how do you package apps that have files that
are not inside app structure? Would you change re-factor/re-arrange
your code/files or would you include the "global" app in your
package/packaging?

TIA!

Cheers,
Micky

-- 
Micky Hulse
Web Content Editor
The Register-Guard
3500 Chad Drive
Eugene, OR 97408
Phone: (541) 338-2621
Fax: (541) 683-7631
Web: 

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



Re: django 1.3 timing out on empty POST request

2011-06-28 Thread mehdi ait oufkir
Hello Roberto,

it looks like upgrading to uWSGI 0.9.8.1 solved the issue.
Thanks for your help!


On Jun 27, 9:18 pm, Roberto De Ioris  wrote:
> Il giorno 27/giu/2011, alle ore 22.07, mehdi ait oufkir ha scritto:
>
> > Roberto, I'm actually using uWSGI 0.9.6.5.
>
> > Can you tell me what is the issue with the previous version. I can
> > stop by on uwsgi IRC if you want to take the conversation off google's
> > groups.
>
> > -mehdi
>
> Versions < 0.9.8 expect a fully compliant (read: very simple) WSGI behaviour.
>
> Actually the world is a bit more complex than this so in 0.9.8 i added a more 
> "tolerant"
> wsgi.input object. (pratically it is the same technic of mod_wsgi for apache 
> with some addition)
>
> Upgrading to 0.9.8.1 can bypass the issue or eventually throw an error 
> pointing to what it is wrong
> in django code.
>
>
>
>
>
>
>
> > On Jun 26, 9:47 pm, "Roberto De Ioris"  wrote:
> >>> Roberto,
>
> >>> it is uWSGI, but can you explain a bit more what the post-buffering
> >>> would help me do?
> >>> Would it help me debug with pdb?
> >>> -mehdi
>
> >> Before starting a pretty long and boring explanation, can you double check
> >> if you are using the 0.9.8.1 version of uWSGI ? It should manage POST data
> >> in a safer way avoiding blocking calls.
>
> >> --
> >> Roberto De Iorishttp://unbit.it
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Roberto De Iorishttp://unbit.it

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



Re: admin search - lookup following GenericForeignKey

2011-06-28 Thread Michal Petrucha
> I have a model X with Y field which is GenericForeignKey field. In the
> model admin for model X I want to have something like:
> search_fields('Y__fieldname'). I get the error 'Cannot resolve keyword
> "X" into field' which makes sense since it's a virtual field and
> doesn't go to fields in X._meta
> 
> Any ideas? Thanks...

Following GFKs forwards in lookups isn't supported at all.
The reason is pretty simple: you don't have any guarantees about the
object on the other side of the relation. You wouldn't even know
against which table you want to join.

There is a note in the docs [1], see the last paragraph of this
section.

To make this work, we'd have to add some kind of mechanism to specify
the content type against which the join should happen but there's no
such thing at the moment. If you have any idea on what this should
look like, I'd gladly look into this. (-;

Michal

[1] 
https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#django.contrib.contenttypes.generic.GenericForeignKey


signature.asc
Description: Digital signature


Re: Custom site model uses the wrong manager

2011-06-28 Thread bruno desthuilliers
On Jun 28, 7:04 pm, bruno desthuilliers
 wrote:

> Not enough info to be sure but looks like some sys.path order issue to
> me.

Forgot to mention that ./manage.py and (or ?) the dev server sometimes
behave a bit strangely wrt/ imports, so depending on your code layout
and how you declare your apps in your settings.INSTALLED_APPS (ie
"myproject.myapp" or just "myapp"), you might end up with 1/ same
modules imported twice under different names (ie "sites" and
"myapp.sites") and 2/ a different sys.path than when deploying using
mod_wsgi or mod_python.

You may want to have a read at Graham Dumpleton's post about this:
http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

HTH

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



Re: Django views

2011-06-28 Thread Jagdeep Singh Malhi


On Jun 28, 1:17 pm, sandeep kaur  wrote:
> Hello all,
> I want to include background images and gallery images to my django project
> and I am unable to  do so.Images do not get displayed. please help me out

You mean use image in Django templates ?

-- 
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: Custom site model uses the wrong manager

2011-06-28 Thread bruno desthuilliers
On Jun 28, 2:26 pm, briehan  wrote:
> We have a custom 'sites framework' implementation that basically
> consists of a Site model and SiteManager. For some reason, when
> running the app, the Site model uses the SiteManager from
> django.contrib.sites instead of our own.
>
> I did the following from within the app:
>
> from myapp.sites.models import Site
> print type(Site.objects)
>
> 
>
> When doing the same from the management shell (./manage.py shell), I
> get the expected output:
>
> >>> from myapp.sites.models import Site
> >>> type(Site.objects)
>
> 


Not enough info to be sure but looks like some sys.path order issue to
me.

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

2011-06-28 Thread Venkatraman S
Can be used chunks along with this approach. I would wait to see your
template tag.

On Tue, Jun 28, 2011 at 8:51 PM, Hutch  wrote:

> isn't this what block tags are for? or custom template tags?
>
> On Jun 28, 10:48 am, garagefan  wrote:
> > This sounds like too much work, every time you want a new option in
> > the sidebar you're adding another if, right?
> >
> > I'm planning on building a template tag to handle side content like
> > that. I am using mezzanine as my base so i have the luxury of having
> > every url resolve to their Page model. So i'm going to be using a
> > onetomany field (i think) to assign content to pages as well as a
> > section (sidebar_left , sidebar_right, etc)
> >
> > In the main template all i'm going to have to do is
> >
> > {% sidebar_left page.id %}
> >
> > pass page.id through to the function and return all of the content
> > that has a key to that page.id.
> >
> > there will be more to it, such as figuring out which model the content
> > belongs to in order to send the data to the correct template to render
> > it with
> >
> > On Jun 27, 7:54 am, "Cal Leeming [Simplicity Media Ltd]"
> >
> >
> >
> >
> >
> >
> >
> >  wrote:
> > > Can I just clarify what you mean by sidebar?
> >
> > > I assume you are talking about a html element with some options inside
> it,
> > > to allow you to navigate through the site?
> >
> > > This is (personally) how I'd do it, although others may prefer a
> different
> > > style (you could probably go as far to make this whole thing "classy").
> >
> > > (hand typed code, may need re-writing)
> >
> > > --- views.py ---
> > > page = "dashboard/help/users"
> >
> > > RequestContext(request, {
> > > 'section' : page.split("/")
> >
> > > }
> >
> > > --- layout.html ---
> > > {% if section.0 = 'dashboard' %}
> > > display stuff relating to dashboard only
> > > {% if section.1 = 'help' %}
> > > display stuff relating to dashboard/help only
> > > {% endif %}
> > > {% endif %}
> >
> > > On Mon, Jun 27, 2011 at 6:27 AM, Venkatraman S 
> wrote:
> > > > Hi,
> >
> > > > I was looking for possible suggestions in implementing sidebars - i
> have a
> > > > truck load of screens and need the sidebar to change dynamically base
> don
> > > > the view. Most of the siderbar-conten is just links.
> >
> > > > I was thiking of including the various sidebar options in the
> base.html and
> > > > then include a flag to check whether it has to be rendered or not;
> and in
> > > > the view pass the relevant flag.
> >
> > > > Any other ideas?
> >
> > > > -venkat
> >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



admin search - lookup following GenericForeignKey

2011-06-28 Thread virtuallight
I have a model X with Y field which is GenericForeignKey field. In the
model admin for model X I want to have something like:
search_fields('Y__fieldname'). I get the error 'Cannot resolve keyword
"X" into field' which makes sense since it's a virtual field and
doesn't go to fields in X._meta

Any ideas? Thanks...

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



Re: Django-utils @async decorator and gunicorn

2011-06-28 Thread Anton Pirker

Hi!

On 06/28/2011 02:45 PM, Javier Guerra Giraldez wrote:

another thing I don't know about is gunicorn; but the 'g' in the name
comes from 'green threads'.  do you (or anybody else) know if that
means that it patches the python thread implementation?  if so, that
could be interfering with the @async thread.
"g" stands for green unicorn. and we use gevent with gunicorn. so it 
could be that there is a problem with the threading implementation..

OTOH, now that you have the daemon running, maybe it would be easier
to use the djutils task queue.  try changing the @async with
@queue_command (found in djutils.queue.decorators)


i have tried this, but it resulted in an strange error.

i think i will skip the asynchronous stuff from djutils. tomorrow i will 
install celery [1] and try my luck with that. :)


thanks for your help,
Anton

[1] http://celeryproject.org/




--
DI(FH) Anton Pirker

-
IGNAZ Softwaremanufaktur
mobile . web . usability . project management

kranzgasse 2/15
a-1150 wien
tel: +43 699 1234 0 456
skype: antonpirker

http://ignaz.at


--
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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-06-28 Thread Cal Leeming [Simplicity Media Ltd]
Second call for anyone who wants to attend this webcast, 3 days left to
place your vote.

Cal

On Fri, Jun 24, 2011 at 7:34 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Really glad to see there has been so much interest in this!
>
> If possible, can everyone please use the following form to indicate what
> week day / timeslot they are available, along with their screen resolution.
> This will be open until 1st July.
>
>
> https://spreadsheets0.google.com/spreadsheet/viewform?formkey=dENyOVFSSkhSYnhBLVZGTktiN1Z3Y2c6MQ
>
> Whichever week day / timeslot / screen resolution has 100% of the votes,
> will be the chosen one :) If it's split, we'll look at doing the webcast on
> two separate occasions. Hopefully this should give everyone a fair chance.
>
> Thanks
>
> Cal
>
> On Fri, Jun 24, 2011 at 4:14 PM, Nolan Brubaker 
> wrote:
>
>> Yes, very interested.  +1
>>
>>
>> On Fri, Jun 24, 2011 at 9:04 AM, bruno desthuilliers <
>> bruno.desthuilli...@gmail.com> wrote:
>>
>>> +1
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

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



Re: Sidebars

2011-06-28 Thread Hutch
isn't this what block tags are for? or custom template tags?

On Jun 28, 10:48 am, garagefan  wrote:
> This sounds like too much work, every time you want a new option in
> the sidebar you're adding another if, right?
>
> I'm planning on building a template tag to handle side content like
> that. I am using mezzanine as my base so i have the luxury of having
> every url resolve to their Page model. So i'm going to be using a
> onetomany field (i think) to assign content to pages as well as a
> section (sidebar_left , sidebar_right, etc)
>
> In the main template all i'm going to have to do is
>
> {% sidebar_left page.id %}
>
> pass page.id through to the function and return all of the content
> that has a key to that page.id.
>
> there will be more to it, such as figuring out which model the content
> belongs to in order to send the data to the correct template to render
> it with
>
> On Jun 27, 7:54 am, "Cal Leeming [Simplicity Media Ltd]"
>
>
>
>
>
>
>
>  wrote:
> > Can I just clarify what you mean by sidebar?
>
> > I assume you are talking about a html element with some options inside it,
> > to allow you to navigate through the site?
>
> > This is (personally) how I'd do it, although others may prefer a different
> > style (you could probably go as far to make this whole thing "classy").
>
> > (hand typed code, may need re-writing)
>
> > --- views.py ---
> > page = "dashboard/help/users"
>
> > RequestContext(request, {
> >     'section' : page.split("/")
>
> > }
>
> > --- layout.html ---
> > {% if section.0 = 'dashboard' %}
> >     display stuff relating to dashboard only
> >     {% if section.1 = 'help' %}
> >         display stuff relating to dashboard/help only
> >     {% endif %}
> > {% endif %}
>
> > On Mon, Jun 27, 2011 at 6:27 AM, Venkatraman S  wrote:
> > > Hi,
>
> > > I was looking for possible suggestions in implementing sidebars - i have a
> > > truck load of screens and need the sidebar to change dynamically base don
> > > the view. Most of the siderbar-conten is just links.
>
> > > I was thiking of including the various sidebar options in the base.html 
> > > and
> > > then include a flag to check whether it has to be rendered or not; and in
> > > the view pass the relevant flag.
>
> > > Any other ideas?
>
> > > -venkat
>
> > > --
> > > 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: Sidebars

2011-06-28 Thread garagefan
This sounds like too much work, every time you want a new option in
the sidebar you're adding another if, right?

I'm planning on building a template tag to handle side content like
that. I am using mezzanine as my base so i have the luxury of having
every url resolve to their Page model. So i'm going to be using a
onetomany field (i think) to assign content to pages as well as a
section (sidebar_left , sidebar_right, etc)

In the main template all i'm going to have to do is

{% sidebar_left page.id %}

pass page.id through to the function and return all of the content
that has a key to that page.id.

there will be more to it, such as figuring out which model the content
belongs to in order to send the data to the correct template to render
it with


On Jun 27, 7:54 am, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
> Can I just clarify what you mean by sidebar?
>
> I assume you are talking about a html element with some options inside it,
> to allow you to navigate through the site?
>
> This is (personally) how I'd do it, although others may prefer a different
> style (you could probably go as far to make this whole thing "classy").
>
> (hand typed code, may need re-writing)
>
> --- views.py ---
> page = "dashboard/help/users"
>
> RequestContext(request, {
>     'section' : page.split("/")
>
> }
>
> --- layout.html ---
> {% if section.0 = 'dashboard' %}
>     display stuff relating to dashboard only
>     {% if section.1 = 'help' %}
>         display stuff relating to dashboard/help only
>     {% endif %}
> {% endif %}
>
>
>
>
>
>
>
> On Mon, Jun 27, 2011 at 6:27 AM, Venkatraman S  wrote:
> > Hi,
>
> > I was looking for possible suggestions in implementing sidebars - i have a
> > truck load of screens and need the sidebar to change dynamically base don
> > the view. Most of the siderbar-conten is just links.
>
> > I was thiking of including the various sidebar options in the base.html and
> > then include a flag to check whether it has to be rendered or not; and in
> > the view pass the relevant flag.
>
> > Any other ideas?
>
> > -venkat
>
> > --
> > 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: Importing file to Models - Temporary store to allow confirming?

2011-06-28 Thread Shawn Milochik

On 06/28/2011 02:43 AM, Victor Hooi wrote:


Shawn,

Thanks for the quick reply =).

If we go with the third approach, what advantages are there to 
persisting the models in MongoDB (or something similar like Redid.or 
Cassandra), as opposed to a traditional RDBMS? (I just want to get a 
good handle on the issues).



The schema-less nature will give you the ability to "just work."

Furthermore, is there a particular reason you picked MongoDB over the 
other NoSQL solutions?


No. I heard about it on FLOSS Weekly, checked out, and I love it. Also, 
pymongo is great and I'm a Python guy. I've read some comparisons among 
the other "NoSQL" databases and some are better for some uses but 
MongoDB is great for me.


Also, in terms of actually persisting the temporary models to MongoDB, 
I can just use PyMongo and store the dicts themselves - and just user 
a nested dict to represent all the model instances from a given import 
file. Any issues with that approach?




No issues that I can see. If you're using pymongo then you can just 
treat everything as a Python dictionary and MongoDB will consume it no 
problem (assuming you stick to certain data types).


Thanks for the tip about using asynchronous processing for the import 
file - I didn't think the file would be that big/complex to process, 
but I suppose it's probably the better approach to do it all 
asynchronously, instead of just hoping it won't grow larger I the 
future. In this case, I suppose I can just use Ajax on the page itself 
to check on the status of the queue?


Sure, although Comet would be better for this use-case. You could also 
just e-mail the user from the background process after it's done with a 
link to the URL for the next step. AJAX is easier than Comet (no service 
to install or set up), and it probably wouldn't generate enough extra 
bandwidth to really bother you.



Cheers,
Victor

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

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: REMOTE_USER authentication to 'Admin'?

2011-06-28 Thread Jeff Blaine
It's all right here:

https://docs.djangoproject.com/en/1.3/howto/auth-remote-user/

and other details in the mailing list thread you are reading/posting to 
(this one!)

-- 
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/-/C9RWSjahsY4J.
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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread william ratcliff
I've been trying django-money for this reason...
On Jun 28, 2011 9:50 AM, "Cal Leeming [Simplicity Media Ltd]" <
cal.leem...@simplicitymedialtd.co.uk> wrote:
> On Tue, Jun 28, 2011 at 2:47 PM, Tom Evans 
wrote:
>
>> On Tue, Jun 28, 2011 at 2:41 PM, Cal Leeming [Simplicity Media Ltd]
>>  wrote:
>> > Yeah I have come up against horrible problems before when forcibly
>> > re-casting all int's to float's.. (especially when it's in the monetary
>> > sense). I had assumed that it would be a on a "per case" basis, but
just
>> > wanted to make sure.
>> >
>>
>> Eeek - having said hard and fast rules are bad, I'm going to give one
>> of my own - never ever ever use floating point calculations for
>> financial/monetary calculations. Use Decimal (which is in fact backed
>> by two integers), which avoids rounding issues.
>>
>> When the auditors want to know what happened to the missing 4p* before
>> they sign off your books, you don't want to have to go through every
>> block of code retro-fitting Decimal :)
>>
>
> Lmao, I know *exactly* what you mean. I'll look at using Decimal next
time!
>
>
>>
>> Cheers
>>
>> Tom
>>
>>
>> * This happened to me.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

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



Re: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Cal Leeming [Simplicity Media Ltd]
On Tue, Jun 28, 2011 at 2:47 PM, Tom Evans  wrote:

> On Tue, Jun 28, 2011 at 2:41 PM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
> > Yeah I have come up against horrible problems before when forcibly
> > re-casting all int's to float's.. (especially when it's in the monetary
> > sense). I had assumed that it would be a on a "per case" basis, but just
> > wanted to make sure.
> >
>
> Eeek - having said hard and fast rules are bad, I'm going to give one
> of my own - never ever ever use floating point calculations for
> financial/monetary calculations. Use Decimal (which is in fact backed
> by two integers), which avoids rounding issues.
>
> When the auditors want to know what happened to the missing 4p* before
> they sign off your books, you don't want to have to go through every
> block of code retro-fitting Decimal :)
>

Lmao, I know *exactly* what you mean. I'll look at using Decimal next time!


>
> Cheers
>
> Tom
>
>
> * This happened to me.
>
> --
> 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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Tom Evans
On Tue, Jun 28, 2011 at 2:41 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Yeah I have come up against horrible problems before when forcibly
> re-casting all int's to float's.. (especially when it's in the monetary
> sense). I had assumed that it would be a on a "per case" basis, but just
> wanted to make sure.
>

Eeek - having said hard and fast rules are bad, I'm going to give one
of my own - never ever ever use floating point calculations for
financial/monetary calculations. Use Decimal (which is in fact backed
by two integers), which avoids rounding issues.

When the auditors want to know what happened to the missing 4p* before
they sign off your books, you don't want to have to go through every
block of code retro-fitting Decimal :)

Cheers

Tom


* This happened to me.

-- 
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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Masklinn

On 2011-06-28, at 15:39 , Tom Evans wrote:

> On Tue, Jun 28, 2011 at 2:36 PM, Masklinn  wrote:
>> On 2011-06-28, at 15:31 , Tom Evans wrote:
>>> 
>>> Bit OT, but I'll bite (doesn't really relate to Django). Dividing two
>>> ints ALWAYS returns an int.
>> Unless you've switched to Python 3, or imported division from __future__ in 
>> which case true division is the default, and integer division is bumped to 
>> '//'.
>> 
>>> Calling math.ceil() ALWAYS returns a
>>> float. I think you were expecting that python would automagically
>>> store the remainder somewhere so that math.ceil() has something to
>>> operate on. It doesn't do that!
>> Or he was expecting that Python uses true division always (a default the 
>> core team seems to agree with since they changed it in 3.0)
>> 
> 
> Seeing as this is django-users@, and not c.l.python, this applies:
> 
> https://docs.djangoproject.com/en/dev/faq/install/#can-i-use-django-with-python-3
No, it does not.

-- 
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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Cal Leeming [Simplicity Media Ltd]
On Tue, Jun 28, 2011 at 2:37 PM, Tom Evans  wrote:

> On Tue, Jun 28, 2011 at 2:23 PM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
> > I'm wondering if it's better practise to always cast a number as a
> > float/decimal, rather than an int.
> > Any thoughts guys?
> > Cal
> >
>
> Damn, this was the bit I meant to comment upon - hard and fast rules
> are dangerous. Integral types are distinctly different to floating
> point types, and you should be aware of which one you are using and
> why. You definitely should not be using floats when you require
> integral mathematics, or reliable accounting since 1.0 is only an
> approximation to 1.
>

Yeah I have come up against horrible problems before when forcibly
re-casting all int's to float's.. (especially when it's in the monetary
sense). I had assumed that it would be a on a "per case" basis, but just
wanted to make sure.


>
> Cheers
>
> Tom
>
>
> >>> 1.0 * 1
> 9.9996e+27
>
> --
> 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: E-store

2011-06-28 Thread Anoop Thomas Mathew
You can find many django based store modules.
The one i liked using was satchmo.
Check out http://www.satchmoproject.com/
and more help about it here.
https://bitbucket.org/chris1610/satchmo/wiki/Home

 regards,
Anoop
atm
___
Life is short, Live it hard.




On 28 June 2011 19:04, lillian cauldwell wrote:

> How does one set up an e-store on their d'jango website?
>
> Thanks,
> LSCauldwell
>
> --
> "Creator" Cauldwell
> CEO, Passionate World Radio, Inc.
> Distinguish Yourself From the Ordinary! (c) 2010-2011 PWR
> http://www.internetvoicesradio.com
> http://www.amazingworldsoflscauldwell.com
> http://pwrwebtv.intuitwebsites.com
> 734-827-9407
>
>  --
> 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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Cal Leeming [Simplicity Media Ltd]
Ah, I didn't know about importing division from __future__, so I may use
this, thanks for letting me know!

On Tue, Jun 28, 2011 at 2:36 PM, Masklinn  wrote:

> On 2011-06-28, at 15:31 , Tom Evans wrote:
> >
> > Bit OT, but I'll bite (doesn't really relate to Django). Dividing two
> > ints ALWAYS returns an int.
> Unless you've switched to Python 3, or imported division from __future__ in
> which case true division is the default, and integer division is bumped to
> '//'.
>
> > Calling math.ceil() ALWAYS returns a
> > float. I think you were expecting that python would automagically
> > store the remainder somewhere so that math.ceil() has something to
> > operate on. It doesn't do that!
> Or he was expecting that Python uses true division always (a default the
> core team seems to agree with since they changed it in 3.0)



> --
> 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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Tom Evans
On Tue, Jun 28, 2011 at 2:36 PM, Masklinn  wrote:
> On 2011-06-28, at 15:31 , Tom Evans wrote:
>>
>> Bit OT, but I'll bite (doesn't really relate to Django). Dividing two
>> ints ALWAYS returns an int.
> Unless you've switched to Python 3, or imported division from __future__ in 
> which case true division is the default, and integer division is bumped to 
> '//'.
>
>> Calling math.ceil() ALWAYS returns a
>> float. I think you were expecting that python would automagically
>> store the remainder somewhere so that math.ceil() has something to
>> operate on. It doesn't do that!
> Or he was expecting that Python uses true division always (a default the core 
> team seems to agree with since they changed it in 3.0)
>

Seeing as this is django-users@, and not c.l.python, this applies:

https://docs.djangoproject.com/en/dev/faq/install/#can-i-use-django-with-python-3

Cheers

Tom

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



Re: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Cal Leeming [Simplicity Media Ltd]
Yeah I'm aware of this now, but it was more of a "oh, didn't ever notice
this before" rather than a "why is this happening" thread :)

I was expecting that dividing two ints would return a float, but it doesn't.
It does make sense, just a bit of a gotcha, you know?

Cal

On Tue, Jun 28, 2011 at 2:31 PM, Tom Evans  wrote:

> On Tue, Jun 28, 2011 at 2:23 PM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
> > So, today I was confused why on earth dividing two ints (which leaves a
> > remainder), didn't return back an int.
> > In the end, I re-casted the ints as floats, performed the division, and
> this
> > worked fine.
> > Looked through the docs, and found this:
> > http://docs.python.org/library/stdtypes.html
> > "For (plain or long) integer division, the result is an integer. The
> result
> > is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2)
> is
> > -1, and (-1)/(-2) is 0. Note that the result is a long integer if either
> > operand is a long integer, regardless of the numeric value."
> > Has anyone else come up against this gotcha before? I'm wondering if it's
> > better practise to always cast a number as a float/decimal, rather than
> an
> > int.
> > Any thoughts guys?
> > Cal
>
> Bit OT, but I'll bite (doesn't really relate to Django). Dividing two
> ints ALWAYS returns an int. Calling math.ceil() ALWAYS returns a
> float. I think you were expecting that python would automagically
> store the remainder somewhere so that math.ceil() has something to
> operate on. It doesn't do that!
>
> If you wish to do rounding, convert either operand to a float. The
> 'Note that the result is a long integer if either operand is a long
> integer' is referring to dividing two integral types - if either is a
> long, the result will be a long. It doesn't apply if either operand is
> a float, eg if you divide a float by a long, the result is a float,
> not a long.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Tom Evans
On Tue, Jun 28, 2011 at 2:23 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> I'm wondering if it's better practise to always cast a number as a
> float/decimal, rather than an int.
> Any thoughts guys?
> Cal
>

Damn, this was the bit I meant to comment upon - hard and fast rules
are dangerous. Integral types are distinctly different to floating
point types, and you should be aware of which one you are using and
why. You definitely should not be using floats when you require
integral mathematics, or reliable accounting since 1.0 is only an
approximation to 1.

Cheers

Tom


>>> 1.0 * 1
9.9996e+27

-- 
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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Masklinn
On 2011-06-28, at 15:31 , Tom Evans wrote:
> 
> Bit OT, but I'll bite (doesn't really relate to Django). Dividing two
> ints ALWAYS returns an int.
Unless you've switched to Python 3, or imported division from __future__ in 
which case true division is the default, and integer division is bumped to '//'.

> Calling math.ceil() ALWAYS returns a
> float. I think you were expecting that python would automagically
> store the remainder somewhere so that math.ceil() has something to
> operate on. It doesn't do that!
Or he was expecting that Python uses true division always (a default the core 
team seems to agree with since they changed it in 3.0)

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



E-store

2011-06-28 Thread lillian cauldwell
How does one set up an e-store on their d'jango website?

Thanks,
LSCauldwell

-- 
"Creator" Cauldwell
CEO, Passionate World Radio, Inc.
Distinguish Yourself From the Ordinary! (c) 2010-2011 PWR
http://www.internetvoicesradio.com
http://www.amazingworldsoflscauldwell.com
http://pwrwebtv.intuitwebsites.com
734-827-9407

-- 
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: Custom site model uses the wrong manager

2011-06-28 Thread Briehan Lombaard
It seems to be using the Site model (and therefore the SiteManager) from 
django.contrib.sites even though dhango.contrib.sites is _not_ included in 
my INSTALLED_APPS setting and I'm explicitly importing 
myapp.sites.models.Site.

-- 
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/-/W4oL4JlbbYoJ.
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: Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Tom Evans
On Tue, Jun 28, 2011 at 2:23 PM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> So, today I was confused why on earth dividing two ints (which leaves a
> remainder), didn't return back an int.
> In the end, I re-casted the ints as floats, performed the division, and this
> worked fine.
> Looked through the docs, and found this:
> http://docs.python.org/library/stdtypes.html
> "For (plain or long) integer division, the result is an integer. The result
> is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is
> -1, and (-1)/(-2) is 0. Note that the result is a long integer if either
> operand is a long integer, regardless of the numeric value."
> Has anyone else come up against this gotcha before? I'm wondering if it's
> better practise to always cast a number as a float/decimal, rather than an
> int.
> Any thoughts guys?
> Cal

Bit OT, but I'll bite (doesn't really relate to Django). Dividing two
ints ALWAYS returns an int. Calling math.ceil() ALWAYS returns a
float. I think you were expecting that python would automagically
store the remainder somewhere so that math.ceil() has something to
operate on. It doesn't do that!

If you wish to do rounding, convert either operand to a float. The
'Note that the result is a long integer if either operand is a long
integer' is referring to dividing two integral types - if either is a
long, the result will be a long. It doesn't apply if either operand is
a float, eg if you divide a float by a long, the result is a float,
not a long.

Cheers

Tom

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



Curious int/float/division/math 'gotcha' in py (discussion)

2011-06-28 Thread Cal Leeming [Simplicity Media Ltd]
So, today I was confused why on earth dividing two ints (which leaves a
remainder), didn't return back an int.

In the end, I re-casted the ints as floats, performed the division, and this
worked fine.

Looked through the docs, and found this:
http://docs.python.org/library/stdtypes.html

*"For (plain or long) integer division, the result is an integer. The result
is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is
-1, and (-1)/(-2) is 0. Note that the result is a long integer if either
operand is a long integer, regardless of the numeric value."*
*
*
Has anyone else come up against this gotcha before? I'm wondering if it's
better practise to always cast a number as a float/decimal, rather than an
int.

Any thoughts guys?

Cal


--- code snip ---

>>> import math
>>> math.ceil(7672 / 50)
153.0
>>> 7672 / 50
153
>>> float(7672 / 50)
153.0
>>> 7672 / 50
153
>>> type(7672)

>>> type(50)

>>> float(7672) / float(50)
153.44
>>> math.ceil(float(7672) / float(50))
154.0
>>>

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



widgets js

2011-06-28 Thread Alex Kutsan
I am try to do litle widget

class My_widjet(forms.widgets.TextInput):
class Media:
js = (
  'js/my_calendar/cal.js',
)
def render(self, name, value, attrs=None):
to_return = u""" %s


 """ %self.media
return mark_safe(to_return)
in "My_Project/js/my_calendar/cal.js" is JavaScript of calendar
then I use My widget

class ContactForm(forms.Form):
subject = forms.CharField()
email = forms.EmailField(required=False)
Date = forms.CharField(widget = My_widjet)

In browser i see ..
But calendar is not working :(
if I just make simple html document with
"



ddd


" It works
but in django does non.

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



Re: Django views

2011-06-28 Thread Rodrigo Gomes
Hi,

Did you try to do what the docs said about static files?

https://docs.djangoproject.com/en/dev/howto/static-files/

On Tue, Jun 28, 2011 at 5:17 AM, sandeep kaur wrote:

> Hello all,
> I want to include background images and gallery images to my django project
> and I am unable to  do so.Images do not get displayed. please help me out
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Django-utils @async decorator and gunicorn

2011-06-28 Thread Javier Guerra Giraldez
On Tue, Jun 28, 2011 at 2:53 AM, Anton Pirker  wrote:
> Ah! There is a queue consumer daemon! ;)  Thank's for this hint!

just checked and the @async decorator doesn't use the queue/consumer
facility also included.  sorry for the wrong hint.

what @async does is adding to a python-standard Queue object, and also
spawining one or more threads to consume the queue (so no need for a
daemon).

another thing I don't know about is gunicorn; but the 'g' in the name
comes from 'green threads'.  do you (or anybody else) know if that
means that it patches the python thread implementation?  if so, that
could be interfering with the @async thread.

OTOH, now that you have the daemon running, maybe it would be easier
to use the djutils task queue.  try changing the @async with
@queue_command (found in djutils.queue.decorators)


-- 
Javier

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



Re: REMOTE_USER authentication to 'Admin'?

2011-06-28 Thread thiru
HI I just like to know how to login to the django admin using remote
data (wherever it may be from)

On Jun 28, 1:28 am, Jeff Blaine  wrote:
> Sorry, I have no knowledge of Oracle SSO, what it allows, how it works, etc.

-- 
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 site model uses the wrong manager

2011-06-28 Thread briehan
We have a custom 'sites framework' implementation that basically
consists of a Site model and SiteManager. For some reason, when
running the app, the Site model uses the SiteManager from
django.contrib.sites instead of our own.

I did the following from within the app:

from myapp.sites.models import Site
print type(Site.objects)



When doing the same from the management shell (./manage.py shell), I
get the expected output:

>>> from myapp.sites.models import Site
>>> type(Site.objects)



The app used to run just fine on Django 1.0 and subsequently on 1.1
and 1.2 during my current upgrade attempt to get the app onto version
1.3. So, my question is: what exactly am I doing wrong or have I
stumbled upon a subtle bug of some sort?

Thanks in advance.

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



Re: Help

2011-06-28 Thread Anton Pirker

Hi!

On 06/28/2011 08:15 AM, Smoltok41 wrote:

Hey wats up
Im a django newbie and im working on this small project so i need help
on how to add an attachment form so that i can be uploading
attachments.
thanx


I am sure here you find everything you need:
https://docs.djangoproject.com/en/1.3/topics/http/file-uploads/


Regards,
Anton





--
DI(FH) Anton Pirker

-
IGNAZ Softwaremanufaktur
mobile . web . usability . project management

kranzgasse 2/15
a-1150 wien
tel: +43 699 1234 0 456
skype: antonpirker

http://ignaz.at


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



Checking inputs based on a specified data type

2011-06-28 Thread Django user
Hi,

I have a field in my database which contains data type as a text.
Note: these data types will be used when filling up information. How
to based my input in my specified data type as an Admin control?

For example, i have a category of payment and i choose on another
field is "numeric" as a data type. Which means the next input will
based on "numeric" data type. Another example is category of
description having a field of "textfield" and the next input should
accept only textfield.

Help, thanks :)

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



Django views

2011-06-28 Thread sandeep kaur
Hello all,
I want to include background images and gallery images to my django project
and I am unable to  do so.Images do not get displayed. please help me out

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



Help

2011-06-28 Thread Smoltok41
Hey wats up
Im a django newbie and im working on this small project so i need help
on how to add an attachment form so that i can be uploading
attachments.
thanx

-- 
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: ModelAdmin, custom field: default value?

2011-06-28 Thread momo2k
Thanks, working :)

def __init__(self, *args, **kwargs):
super(MealModelForm, self).__init__(*args, **kwargs)
try:
instance = kwargs['instance']
self.fields['price'].initial = instance.price()
except (KeyError, AttributeError):
pass

-- 
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: Social Networking basics? -Raj

2011-06-28 Thread Kenneth Gonsalves
On Mon, 2011-06-27 at 12:48 +0100, Cal Leeming [Simplicity Media Ltd]
wrote:
> I've made a few modifications, feel free to revert/modify to your
> hearts
> content. 

am travelling - will add my stuff when I reach home - but thanks, keep
it coming.
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.org/

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



Re: giving download links

2011-06-28 Thread Herman Schistad
On Tue, Jun 28, 2011 at 05:20, raj  wrote:
> I allow a user to upload a file, how do I now allow them to download
> this file? I looked at the "serving static files" thing in the
> djangoproject, but they said it causes security flaws or something.
> Can someone help me? I couldn't find good information on google. Thank
> you.

What do you mean, you just give them the link to the file they just uploaded.
Download here
Here you can use whatever template tools you have available.

Serving static files are just for debugging and to be used with
manage.py runserver, due to, as you said, security and scaling.
You should look into mod_python, mod_wsgi, fastcgi or some other
application, in order to serve your media files.

Take a look at the documentation or the djangobook:
https://docs.djangoproject.com/en/dev/howto/deployment/
http://www.djangobook.com/en/beta/chapter21/

Or am I missing something?

-- 
With regards, Herman Schistad

-- 
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: Call SQL function within Model

2011-06-28 Thread Martin J. Laubach
  You probably want to use something like

https://docs.djangoproject.com/en/1.3/ref/models/querysets/#extra

  to add custom sql expressions to your querysets.

mjl

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Gjl5V41EieAJ.
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: ModelAdmin, custom field: default value?

2011-06-28 Thread Marc Aymerich
On Tue, Jun 28, 2011 at 10:27 AM, Marc Aymerich  wrote:
> On Mon, Jun 27, 2011 at 11:03 PM, momo2k  wrote:
>> Hello,
>>
>> Is there a way to set dynamic default values for custom fields in the
>> admin?
>>
>> Description of the problem:
>>
>> # models.py
>> # there are two models
>> class Meal(models.Model):
>>    name = ...
>>
>>    def check_new_price(self, price):
>>        # checks if the price is new and creates a new price if
>> neccessary
>>
>> class Price(models.Model):
>>    meal = models.ForeignKey(Meal, )
>>    valid_to = models.DateField() # None for current price
>>    amount = CurrencyField() # nearly identical to IntegerField
>>
>> # admin.py
>> # I extended the Admin with a custom form:
>> class MealModelForm(forms.ModelForm):
>>    price = CurrencyFormField() # Nearly identical to Decimalfield
>>    class Meta:
>>        model = Meal
>>
>> class MealAdmin(admin.ModelAdmin):
>>    form = MealModelForm
>>    
>>    def save_model(self, request, obj, form, change):
>>        super(MealAdmin, self).save_model(request, obj, form, change)
>>        obj.check_new_price(form.cleaned_data['price'])
>>
>>
>> My question is: How do i tell the django admin to display the current
>> price in the form field? I already tried to add an "price"-attribute
>> in the ModelAdmin.get_object() method, but that doesn't work. If I
>> call the Admin page for a meal, the price is blank instead of
>> displaying the current price.
>>
>> So, repeating my first question: Is there a way to set dynamic default
>> values for custom fields in the admin?
>
> Yes, and it should be done on the __init__ method of your custom form.
>
>
> class MealModelForm(forms.ModelForm):
>   price = CurrencyFormField() # Nearly identical to Decimalfield
>   class Meta:
>       model = Meal
>
>   def __init__(self, *args, **kwargs):
>       super(MealModelForm).__init__(*args, **kwargs)
>       if 'instance' in kwargs.keys():
>           self.fields['price'].initial =
> Price.objects.get(meal=kwargs['instance']).amount

Ups, i forget something on this call:
  super(MealModelForm, self).__init__(*args, **kwargs)



-- 
Marc

-- 
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: ModelAdmin, custom field: default value?

2011-06-28 Thread Marc Aymerich
On Mon, Jun 27, 2011 at 11:03 PM, momo2k  wrote:
> Hello,
>
> Is there a way to set dynamic default values for custom fields in the
> admin?
>
> Description of the problem:
>
> # models.py
> # there are two models
> class Meal(models.Model):
>    name = ...
>
>    def check_new_price(self, price):
>        # checks if the price is new and creates a new price if
> neccessary
>
> class Price(models.Model):
>    meal = models.ForeignKey(Meal, )
>    valid_to = models.DateField() # None for current price
>    amount = CurrencyField() # nearly identical to IntegerField
>
> # admin.py
> # I extended the Admin with a custom form:
> class MealModelForm(forms.ModelForm):
>    price = CurrencyFormField() # Nearly identical to Decimalfield
>    class Meta:
>        model = Meal
>
> class MealAdmin(admin.ModelAdmin):
>    form = MealModelForm
>    
>    def save_model(self, request, obj, form, change):
>        super(MealAdmin, self).save_model(request, obj, form, change)
>        obj.check_new_price(form.cleaned_data['price'])
>
>
> My question is: How do i tell the django admin to display the current
> price in the form field? I already tried to add an "price"-attribute
> in the ModelAdmin.get_object() method, but that doesn't work. If I
> call the Admin page for a meal, the price is blank instead of
> displaying the current price.
>
> So, repeating my first question: Is there a way to set dynamic default
> values for custom fields in the admin?

Yes, and it should be done on the __init__ method of your custom form.


class MealModelForm(forms.ModelForm):
   price = CurrencyFormField() # Nearly identical to Decimalfield
   class Meta:
   model = Meal

   def __init__(self, *args, **kwargs):
   super(MealModelForm).__init__(*args, **kwargs)
   if 'instance' in kwargs.keys():
   self.fields['price'].initial =
Price.objects.get(meal=kwargs['instance']).amount



-- 
Marc

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



Re: admin problem

2011-06-28 Thread jaspreet kaur
@JP De Villiers Thanks, my problem has been solved :)

>
>

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



Re: Django-utils @async decorator and gunicorn

2011-06-28 Thread Anton Pirker

Hi!

On 06/27/2011 03:47 PM, Javier Guerra Giraldez wrote:

On Mon, Jun 27, 2011 at 4:50 AM, Anton Pirker  wrote:

But when i run my django app under gunicorn and i call the function with the
@async decorator nothing happens at all...

are you running the queue consumer daemon?


Ah! There is a queue consumer daemon! ;)  Thank's for this hint!

I have now the queue consumer configured in my supervisord.conf like this:

[program:preview_queue_consumer]
environment=PYTHONPATH="/home/preview/.virtualenvs/preview/source/myproject/:/home/preview/.virtualenvs/preview/lib/python2.6/site-packages/djutils/:$PYTHONPATH"
directory=/home/preview/source/myproject/
command=python manage.py queue_consumer --settings=myproject.settings -l 
logs/queue_consumer.log --verbosity=2 -t 2

user=preview
autostart=true
autorestart=true


when i start the daemon the logs says this:

delay: 0.1
backoff: 1.15
threads: 2
2011-06-28 09:18:06,329:djutils.queue.logger:INFO:Loaded classes:
djutils.commands.queuecmd_delayed_resize
djutils.queue.queue.QueueCommand
djutils.queue.queue.PeriodicQueueCommand
2011-06-28 09:18:06,329:djutils.queue.logger:INFO:Starting periodic 
command execution thread
2011-06-28 09:18:06,329:djutils.queue.logger:INFO:created thread 
"1098918224"
2011-06-28 09:18:06,329:djutils.queue.logger:INFO:created thread 
"1107310928"


so i assume the daemon is started.

but when i run my @async function nothing happens. in the log output 
above i can see that QueueCommand and PeriodicQueueCommand are loaded.
can it be, that the consumer can only consume this sort of functions and 
not functions with @async?


i tried to add the @queue_command instead of the @async to my function, 
but then i get the error:

"can't pickle StringO objects"
and i do not have a clue what this means. (maybe it's my lack of english 
skills, but what should 'pickle' in this context mean?)



anyone an idea or hint where i should look next, to get my @async 
functions running in gunicorn?


thank's in advance,
Anton



--
DI(FH) Anton Pirker

-
IGNAZ Softwaremanufaktur
mobile . web . usability . project management

kranzgasse 2/15
a-1150 wien
tel: +43 699 1234 0 456
skype: antonpirker

http://ignaz.at


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



Re: admin problem

2011-06-28 Thread Jean-Pierre De Villiers
Hi,

A quote from the django tutorial:

"If you installed Django using a Linux distribution’s package manager (e.g.
apt-get or yum) django-admin.py may have been renamed to django-admin. You
may continue through this documentation by omitting .py from each command."

So try using "django-admin startproject mysite".

Regards,

JP De Villiers

On Tue, Jun 28, 2011 at 8:48 AM, jaspreet kaur  wrote:

> I am a newbie and I am facing a problem while starting the django project.
> When I type "django-admin.py startproject mysite",it shows the error that
> "admin.py command not found".
> Please help me solving this problem.
>
> --
> 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.



admin problem

2011-06-28 Thread jaspreet kaur
I am a newbie and I am facing a problem while starting the django project.
When I type "django-admin.py startproject mysite",it shows the error that
"admin.py command not found".
Please help me solving this problem.

-- 
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: Importing file to Models - Temporary store to allow confirming?

2011-06-28 Thread Victor Hooi


Shawn,

Thanks for the quick reply =).

If we go with the third approach, what advantages are there to persisting 
the models in MongoDB (or something similar like Redid.or Cassandra), as 
opposed to a traditional RDBMS? (I just want to get a good handle on the 
issues).

Furthermore, is there a particular reason you picked MongoDB over the other 
NoSQL solutions?

Also, in terms of actually persisting the temporary models to MongoDB, I can 
just use PyMongo and store the dicts themselves - and just user a nested 
dict to represent all the model instances from a given import file. Any 
issues with that approach?

Thanks for the tip about using asynchronous processing for the import file - 
I didn't think the file would be that big/complex to process, but I suppose 
it's probably the better approach to do it all asynchronously, instead of 
just hoping it won't grow larger I the future. In this case, I suppose I can 
just use Ajax on the page itself to check on the status of the queue?

Cheers,
Victor

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