Re: What is the best way to manually create an HTML form from a ModelForm

2010-08-23 Thread orokusaki
Ahh, thanks Scott. That's very helpful.

On Aug 23, 6:18 am, Scott Gould  wrote:
> You can refer to individual fields by name, for example:
>
> > 
> >     {% form.first_name %}
> > 
>
> Looping through them works fine for simple forms but as you say, if
> you want something more elaborate in your template, you sometimes need
> to go field-by-field.
>
> What I do is write an inclusion tag with all the markup I want for my
> fields, automatic outputting of css classes matching the widget type
> so I can style them, etc. and then pass the field as the argument:
>
> {% my_inclusion_tag form.first_name %}
>
> On Aug 22, 10:47 pm, orokusaki  wrote:
>
> > Normally, I would do something like this:
>
> > {% for field in form.fields %}
> > 
> >     {% field %}
> > 
> > {% endfor %}
>
> > What if I need:
>
> > 
> >     {% one field %}
> > 
>
> > 
> >     Some Title
> >     
> >     {% another field %}
> >     
> > 
>
> > I want to be able to still use model forms and I don't want to hard
> > code {% if field == "email" %}Custom Stuff{% endif %}. Is there a good
> > way to do this, or a convention that I can use to ensure that my HTML
> > won't stop working when I update Django (I know that there is the
> > id_field_name convention, but I'm looking for a little more insight if
> > anyone out there does this alot.

-- 
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: the structure of a registration app

2010-08-23 Thread Kenneth Gonsalves
On Mon, 2010-08-23 at 18:29 -0700, John Yeukhon Wong wrote:
> I want to understand something...
> Let say I want to do a low-level registration handling myself, using
> the User class that comes with Django.
> 
> I started an app called accounts in my project
> 
> So what should I put in model? Some examples would create an
> additional file called forms.py to put the registration class
> 
> 
> How do I determine what I put in the model? I know model is what we
> generate in the DB...
> But in this case, what would I put
> 
> 

address, phone number and personal details depending on what your site
is for
-- 
regards
Kenneth Gonsalves

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



the structure of a registration app

2010-08-23 Thread John Yeukhon Wong
I want to understand something...
Let say I want to do a low-level registration handling myself, using
the User class that comes with Django.

I started an app called accounts in my project

So what should I put in model? Some examples would create an
additional file called forms.py to put the registration class


How do I determine what I put in the model? I know model is what we
generate in the DB...
But in this case, what would I put

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-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: stream (large) files from the back-end via Django to the user?

2010-08-23 Thread Eric Chamberlain

On Aug 23, 2010, at 4:25 PM, Markus wrote:

> 
> Surely the whole point of a content delivery network is to act as a
> proxy for the data source. Buffering it through Django means it's no
> longer a CDN, it's just a data store.
> 
> Yes. The problem is that currently our CDN is based on Hadoop which serves us 
> really well for internal purpose. We can't make it accessible from the 
> outside because at the moment Hadoop is missing some crucial security 
> features. Still we want to serve some data from our internal CDN to the 
> outside even if for this part of the story our CDN would be just a data 
> store. The question is if this could be done efficiently? If "yes", how can 
> it be done?
> 

Does django need to be in the loop for file download?  Is there some reason why 
the web server can't mount and serve the files like any other static file 
structure?

--
Eric Chamberlain,




-- 
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: stream (large) files from the back-end via Django to the user?

2010-08-23 Thread Markus
> Surely the whole point of a content delivery network is to act as a
> proxy for the data source. Buffering it through Django means it's no
> longer a CDN, it's just a data store.
>

Yes. The problem is that currently our CDN is based on Hadoop which serves
us really well for internal purpose. We can't make it accessible from the
outside because at the moment Hadoop is missing some crucial security
features. Still we want to serve some data from our internal CDN to the
outside even if for this part of the story our CDN would be just a data
store. The question is if this could be done efficiently? If "yes", how can
it be done?

Thanks!
Markus

-- 
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: stream (large) files from the back-end via Django to the user?

2010-08-23 Thread Steve Holden
On 8/23/2010 6:44 PM, Markus wrote:
> Hi,
> 
> sorry for the delay of my answer.
> 
> On Thu, Aug 12, 2010 at 5:21 PM, vjimw  > wrote:
> 
> When we upload files to the CDN, we store that path with the object.
> Then we override the widget for the file so we can server the file
> directly from the CDN using that field. Would that work for you?
> 
> 
> If I understand it correctly for this solution the CDN has to be
> accessible from the internet, right?
> 
> My problem is, that the CDN is only local available and the only
> connection to the rest of the world goes through the Django app. So as
> far as I understand it I would need something like a "pipe". On the one
> end my local CDN in the middle Django and on the other end the internet
> user who wants to download/upload a file. Django than reads from the CDN
> and forward it directly to the user.
> 
> Is this possible? Is this what your solution does, maybe I have not
> understand it correctly? In this case maybe you can elaborate a little bit?
> 
> best wishes & Thanks,
> Markus
> 
Surely the whole point of a content delivery network is to act as a
proxy for the data source. Buffering it through Django means it's no
longer a CDN, it's just a data store.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
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: stream (large) files from the back-end via Django to the user?

2010-08-23 Thread Markus
Hi,

sorry for the delay of my answer.

On Thu, Aug 12, 2010 at 5:21 PM, vjimw  wrote:

> When we upload files to the CDN, we store that path with the object.
> Then we override the widget for the file so we can server the file
> directly from the CDN using that field. Would that work for you?
>

If I understand it correctly for this solution the CDN has to be accessible
from the internet, right?

My problem is, that the CDN is only local available and the only connection
to the rest of the world goes through the Django app. So as far as I
understand it I would need something like a "pipe". On the one end my local
CDN in the middle Django and on the other end the internet user who wants to
download/upload a file. Django than reads from the CDN and forward it
directly to the user.

Is this possible? Is this what your solution does, maybe I have not
understand it correctly? In this case maybe you can elaborate a little bit?

best wishes & Thanks,
Markus

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



Start up company is looking for an experianced Django web developer .

2010-08-23 Thread empwanted
Hi Everyone,

Our company is looking for an experienced full time Django programmer to work 
with our development team on a contract basis. We are a start up that is 
developing a large web application with extensive database interfaces.  We are 
based in the US so living in the US is a plus. The existing application is 
partially completed using Django, Centos 5, Postgresql 8.4, SVN, and Jquery.

This contract position could lead to a full time position with our new company. 
If you’ve got expert skills in Django, HTML, Jquery, CSS and overall web 
development and design, we’d like to hear from you. If you are interested 
please send your resume or work experience to empwan...@cox.net
Please include your expected hourly or weekly rate.

Accepted applicants will be required to sign a non-disclosure agreement.

-- 
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: virtualenv and standalone scripts

2010-08-23 Thread Oivvio Polite
On Mon, Aug 23, 2010 at 10:54:21PM +0200, Oivvio Polite wrote:
> 
> What's the right way to go about it?
> 

Ok, just did some more googling and found out about custom management
commands, that clearly are the django way of solving my problem.

oivvio


-- 
http://pipedreams.polite.se/about/


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



virtualenv and standalone scripts

2010-08-23 Thread Oivvio Polite
Following advice on this list I've moved to virtualenv+pip to manage my
django stack, which so far is working out nicely. 

But what should I do about standalone scripts? Say I have a project
called mysite. If I'm in a virtualenv and execute a standalone script,
mysite won't be on my pythonpath and the script won't be able to import
it.

For now I've solved this by symlinking mysite from my virtualenv
site-packages folder, but that sort of defeats the purpose of having
using virtualenv.

What's the right way to go about it?

Oivvio



-- 
http://pipedreams.polite.se/about/


-- 
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: Please wait page

2010-08-23 Thread Gerard Flanagan

Bradley Hintze wrote:

Hi all,

My webpage has a process that takes about 10-15 seconds. Is there a
way I can have an intermediate 'Please wait' page, preferably with
blinking shapes (dots) so that the user knows that the process is
still working.  As an example try finding a flight at orbitz.com,
there is an intermediate page that says something to the effect of
'finding flights.' I'm not sure what term to google for this query. If
you can point me in the right direction I'd appreciate it.

Thanks
Bradley


google ajax throbber

Regards


--
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 + Google App Engine, Getting Started Tutorial

2010-08-23 Thread rafael.nu...@gmail.com
http://www.42topics.com/dumps/django/docs.html

On Mon, Aug 23, 2010 at 9:53 AM, Subhranath Chunder wrote:

> You should try django non-rel project.
>
> Thanks,
> Subhranath Chunder.
>
> On Aug 23, 2010 3:08 PM, "nobosh"  wrote:
>
> I'm very interested in finding a up-to-date tutorial that shows steps
> for getting DJANGO running on Google App Engine, anyone know of any
> such tutorials?
>
> Surprisingly, Google's App Engine DJANGO docs are almost a year old.
> What gives?
>
> 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-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.



'QuerySet' object has no attribute 'get_payload'

2010-08-23 Thread Cole743
"AttributeError at _

'QuerySet' object has no attribute 'get_payload'

Request Method: POST
Request URL:
Exception Type: AttributeError
Exception Value:

'QuerySet' object has no attribute 'get_payload'

Exception Location: /usr/lib/python2.5/email/encoders.py in
encode_base64, line 44
Python Executable:  /usr/bin/python
Python Version: 2.5.2"

I recently got this error while testing out an interface page. I had
added the ability to send emails with attatchments as part of a
program. When I had tried it on IE, everything worked fine. When I
tried it on firefox, however, I got that error. I haven't been able to
find any mention of a similar error yet and I'm not sure what would
cause it to only happen in firefox.

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



Please wait page

2010-08-23 Thread Bradley Hintze
Hi all,

My webpage has a process that takes about 10-15 seconds. Is there a
way I can have an intermediate 'Please wait' page, preferably with
blinking shapes (dots) so that the user knows that the process is
still working.  As an example try finding a flight at orbitz.com,
there is an intermediate page that says something to the effect of
'finding flights.' I'm not sure what term to google for this query. If
you can point me in the right direction I'd appreciate it.

Thanks
Bradley
-- 
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine

-- 
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: How to troubleshoot path and permission problems?

2010-08-23 Thread ringemup
Your server's error logs can also be informative.

On Aug 23, 2:02 pm, Antoni Aloy  wrote:
> 2010/8/23 vishy :
>
> > Hi,
>
> > I am having issues with production server.Everything is running fine
> > on my local development server.On production site(using apache), CSS
> > files related to admin section are not being loaded.I have a feature
> > where admin can add products and upload images for the
> > product.But,when admin hits save,I get permission denied message.How
> > can I figure out what path problems are existing and how to fix them?
> > Thanks
>
> on linux ls -l will givve you the perisions of each file and folder.
> You can check what each letter means 
> onhttp://www.comptechdoc.org/os/linux/usersguide/linux_ugfilesp.html.
>
> To server files the Apache server has to have read permisions. To
> create files it has to have write permisions.
>
> Best regards,
>
> --
> Antoni Aloy López
> Blog:http://trespams.com
> Site:http://apsl.net

-- 
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: How to troubleshoot path and permission problems?

2010-08-23 Thread Antoni Aloy
2010/8/23 vishy :
> Hi,
>
> I am having issues with production server.Everything is running fine
> on my local development server.On production site(using apache), CSS
> files related to admin section are not being loaded.I have a feature
> where admin can add products and upload images for the
> product.But,when admin hits save,I get permission denied message.How
> can I figure out what path problems are existing and how to fix them?
> Thanks
>

on linux ls -l will givve you the perisions of each file and folder.
You can check what each letter means on
http://www.comptechdoc.org/os/linux/usersguide/linux_ugfilesp.html.

To server files the Apache server has to have read permisions. To
create files it has to have write permisions.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



How to troubleshoot path and permission problems?

2010-08-23 Thread vishy
Hi,

I am having issues with production server.Everything is running fine
on my local development server.On production site(using apache), CSS
files related to admin section are not being loaded.I have a feature
where admin can add products and upload images for the
product.But,when admin hits save,I get permission denied message.How
can I figure out what path problems are existing and how to fix them?
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-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.



Connecting a django-registration signal to a function

2010-08-23 Thread Kai Timmer
Hello,
this may sound stupid, but all I want to do is to connect the
user_activated signal from django-registration to a simple function.
And I think that I missed an important part.

I have a signals.py file in my django app with a function create_db
which is defined like this:

def create_db(sender, user, request ):
[...]

and a line:
user_activated.send(create_db)

The last line gets called with no error, so I think that the signal is
connected, but when a user is activated (by clicking on the activation
link), the function is not called.

Whats the problem here?

-- 
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: Loop over a form's choices (radio button) and render it

2010-08-23 Thread Bill Freeman
Andreas,

I'll give it a try, but it won't be soon.  Other projects are hot.

Bill

On Sun, Aug 22, 2010 at 9:07 AM, Andreas Pfrengle  wrote:
> Hello Bill,
>
> thanks for the code. It took half the weekend, but finally I built
> upon this to get a radiobutton-iterator. This was a bit more
> complicated, since the RadioInput widget has no own render-method, so
> I needed to introduce a helper class that derives from RadioInput.
> I've put the code here:
> 
>
> Would you mind testing it in your app to see if it also still behaves
> like it should (the filter that should return the same as your
> original version is called "checkboxiterator_named")?
> Btw: Your version seems also to work fine on Django 1.2.1.
>
> Andreas
>
> --
> 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 + Google App Engine, Getting Started Tutorial

2010-08-23 Thread Subhranath Chunder
You should try django non-rel project.

Thanks,
Subhranath Chunder.

On Aug 23, 2010 3:08 PM, "nobosh"  wrote:

I'm very interested in finding a up-to-date tutorial that shows steps
for getting DJANGO running on Google App Engine, anyone know of any
such tutorials?

Surprisingly, Google's App Engine DJANGO docs are almost a year old.
What gives?

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-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: How does Django handle auto-increment PK when a model is sharded horizontally into multiple databases?

2010-08-23 Thread Steve Holden
On 8/23/2010 8:08 AM, Russell Keith-Magee wrote:
> On Mon, Aug 23, 2010 at 7:53 PM, Steve Holden  wrote:
>> On 8/23/2010 7:48 AM, Russell Keith-Magee wrote:
>>> On Mon, Aug 23, 2010 at 7:32 PM, Andy  wrote:
>> [...]
 Also how random is random - would I get a uniform distribution of
 records among the shards?
>>>
>>> Depending on your level of mathematical rigor, that's not a simple
>>> question. To a simple approximation, yes, you'll get a uniform
>>> distribution. However, the patterns and underlying distribution of
>>> random number generators is the subject of continued research and
>>> improvement
>>>
>> I'll go further and say that the principal authors of the random module
>> have a degree of numerical and mathematical sophistication that will
>> tend to guarantee results better than most regular programmers could
>> provide with their own attempts.
>>
>> The random number generation functions are based on the Mersenne twister
>> algorithm. I certainly wouldn't try to do better myself.
> 
> Oh - I certainly agree with that. Just like amateur cryptography,
> amateur random number generators risk doing more harm than good.
> 
> I was just trying to make the distinction between "uniform for
> practical purposes" and "genuinely uniform in the pure sense of the
> word". Python's random number generator isn't perfect in he
> mathematical sense -- no programatic random number generator will meet
> that criterion. However, Python's random will certainly meet the
> "practical purposes" criterion for most practical purposes, including
> tasks like shard allocation.
> 
Sure: my remarks were intended to add weight to your in discouraging the
OP from trying to do better.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
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: ANN: nosedjango 0.8.1

2010-08-23 Thread Jyrki Pulliainen
On Aug 23, 2:26 pm, Reinout van Rees  wrote:
> On 08/23/2010 08:54 AM, Jyrki Pulliainen wrote:
>
> > Hi there,
>
> > I'm pleased to announce new version of Django testing plugin for nose:
> > nosedjango version 0.8.1.
>
> What are the differences withhttp://pypi.python.org/pypi/django-nose?
> I just got my test + hudson setup more or less working, so I'm
> interested in alternatives :-)

The biggest difference with django-nose is the test isolation. In
nosedjango, by default, every single test nose finds is wrapped inside
a transaction when run. This guarantees that every test has a vanilla
database (as created by syncdb) at the start of the test and that
after any test, successful or not, the database is rollbacked back to
the vanilla condition.

Another key difference is how the tests are run: django-nose requires
the TEST_RUNNER to be set and the application added to INSTALLED_APPS
in settings.py. Nosedjango can just be run on commandline using
"nosetests --with-django", no additional setup is needed. One of pros
is that you can put your tests outside your main project tree so that
they don't get accidentally included if you happen to package your app
with distutils or setuptools/distribute. Con side is that the ./
manage.py test -machinery no longer works. So this one is more or less
a matter of taste.

- Jyrki

-- 
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: What's the best way to custom the add page (in django admin site)

2010-08-23 Thread Yangmin Li
sorry for the previous incomplete message.
Here is what I want to ask, thanks in advanced.

I have a model called request, after registered in admin backend, user can
add new request object in admin pages.
I want to modify the request-add page to this: only some of the model fields
will be shown to user, others are hidden and will be given default values
before being saved to database.

I've already custom the change_form template to hide the fields that I do
not want to show them to users.
what else should I do ?


On Mon, Aug 23, 2010 at 8:31 PM, Yangmin Li  wrote:

> Hi All ,
>
>

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



What's the best way to custom the add page (in django admin site)

2010-08-23 Thread Yangmin Li
Hi All ,

-- 
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: Prepopulate some fields in a admin add form

2010-08-23 Thread Scott Gould
First, just to make absolutely clear you understand, the "user's name"
isn't the foreign key itself -- that would be the user's ID. The
user's name is what would be displayed to help you *select* the
correct ID, under the hood.

To the question at hand, it's quite simple to add a method to your
ModelAdmin class that will act on the foreign key field for your user:

http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey

On Aug 21, 2:59 am, gondor  wrote:
> I have a simple admin model for inputting a note with a date into the
> database.  In addition to that I want to prepopulate with the users
> name when the add new entry button is clicked.  The users name is a
> foreign key to the user table.
>
> Does anyone know how to do that?
>
> Any help is appreciated.
>
> Thank you

-- 
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: What is the best way to manually create an HTML form from a ModelForm

2010-08-23 Thread Scott Gould
You can refer to individual fields by name, for example:

> 
>     {% form.first_name %}
> 

Looping through them works fine for simple forms but as you say, if
you want something more elaborate in your template, you sometimes need
to go field-by-field.

What I do is write an inclusion tag with all the markup I want for my
fields, automatic outputting of css classes matching the widget type
so I can style them, etc. and then pass the field as the argument:

{% my_inclusion_tag form.first_name %}

On Aug 22, 10:47 pm, orokusaki  wrote:
> Normally, I would do something like this:
>
> {% for field in form.fields %}
> 
>     {% field %}
> 
> {% endfor %}
>
> What if I need:
>
> 
>     {% one field %}
> 
>
> 
>     Some Title
>     
>     {% another field %}
>     
> 
>
> I want to be able to still use model forms and I don't want to hard
> code {% if field == "email" %}Custom Stuff{% endif %}. Is there a good
> way to do this, or a convention that I can use to ensure that my HTML
> won't stop working when I update Django (I know that there is the
> id_field_name convention, but I'm looking for a little more insight if
> anyone out there does this alot.

-- 
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: How does Django handle auto-increment PK when a model is sharded horizontally into multiple databases?

2010-08-23 Thread Russell Keith-Magee
On Mon, Aug 23, 2010 at 7:53 PM, Steve Holden  wrote:
> On 8/23/2010 7:48 AM, Russell Keith-Magee wrote:
>> On Mon, Aug 23, 2010 at 7:32 PM, Andy  wrote:
> [...]
>>> Also how random is random - would I get a uniform distribution of
>>> records among the shards?
>>
>> Depending on your level of mathematical rigor, that's not a simple
>> question. To a simple approximation, yes, you'll get a uniform
>> distribution. However, the patterns and underlying distribution of
>> random number generators is the subject of continued research and
>> improvement
>>
> I'll go further and say that the principal authors of the random module
> have a degree of numerical and mathematical sophistication that will
> tend to guarantee results better than most regular programmers could
> provide with their own attempts.
>
> The random number generation functions are based on the Mersenne twister
> algorithm. I certainly wouldn't try to do better myself.

Oh - I certainly agree with that. Just like amateur cryptography,
amateur random number generators risk doing more harm than good.

I was just trying to make the distinction between "uniform for
practical purposes" and "genuinely uniform in the pure sense of the
word". Python's random number generator isn't perfect in he
mathematical sense -- no programatic random number generator will meet
that criterion. However, Python's random will certainly meet the
"practical purposes" criterion for most practical purposes, including
tasks like shard allocation.

Yours,
Russ Magee %-)

-- 
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: How does Django handle auto-increment PK when a model is sharded horizontally into multiple databases?

2010-08-23 Thread Steve Holden
On 8/23/2010 7:48 AM, Russell Keith-Magee wrote:
> On Mon, Aug 23, 2010 at 7:32 PM, Andy  wrote:
[...]
>> Also how random is random - would I get a uniform distribution of
>> records among the shards?
> 
> Depending on your level of mathematical rigor, that's not a simple
> question. To a simple approximation, yes, you'll get a uniform
> distribution. However, the patterns and underlying distribution of
> random number generators is the subject of continued research and
> improvement
> 
I'll go further and say that the principal authors of the random module
have a degree of numerical and mathematical sophistication that will
tend to guarantee results better than most regular programmers could
provide with their own attempts.

The random number generation functions are based on the Mersenne twister
algorithm. I certainly wouldn't try to do better myself.

  http://en.wikipedia.org/wiki/Mersenne_twister

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
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: How does Django handle auto-increment PK when a model is sharded horizontally into multiple databases?

2010-08-23 Thread Russell Keith-Magee
On Mon, Aug 23, 2010 at 7:32 PM, Andy  wrote:
> On Aug 20, 10:04 pm, Russell Keith-Magee 
> wrote:
>
>>Of course, given that you know your sharding scheme, you could use the
>>router directly.
>>
>>Tweet.objects.using(router.db_for_read(Tweet, author=a)).filter(author_id=a)
>
> Ah Thanks. This is what I need.
>
>
>> You won't get any argument from me. What's missing is a clear
>> suggestion on how we can encompass this problem in the general case.
>> Suggestions are welcome.
>
> One suggestion I have is that any arguments in filter() should also be
> passed as part of the hints dictionary to the database router. The
> arguments in filter() should be enough information to determine which
> shard to select in most cases.
>
> So in the above example:
>
> Tweet.objects.filter(author_id=a)
>
> The keyword:value pair {'author_id': a} should be added to the hints
> that got passed to the database router.
>
> This achieves basically the same results as doing
> Tweet.objects.using(router.db_for_read(Tweet,
> author_id=a)).filter(author_id=a)
> But it doesn't require going through the entire codebase and modifying
> every single queryset so it's less prone to error and more DRY.

Ok, so how are the following queries processed?

Tweet.objects.filter(author_id=a, other=b)

Tweet.objects.filter(author_id=a).filter(other=b)

Tweet.objects.filter(author_id=a).exclude(other=b)

Like I keep saying - we've given this some thought, and it's easy to
solve this for the simple case. It's the general case that poses a
problem.

This also steps around the fact that we don't actually store the
contents of filter() clauses once they're applied; they're converted
into query-specific representations as soon as they're added to a
queryset.

> I have another use case where I want to shard by primary pk which is
> an auto-increment. I have this model:
>
> class Auction(models.Model):
>    seller_id = models.IntegerField()
>    text = models.TextField()
>    price = models.DecimalField()
>
> The PK of Auction is the auto-increment "id" field.
>
> Say I divide Auction into 3 shards and set up each shard so that the
> auto-increment id's don't collide.
>
> When I first create and save a new auction, it doesn't have an "id",
> so I just want to randomly pick a shard to save to:
>
>    def db_for_write(self, model, **hints):
>        if model.__name__ == "Auction" and 'instance' not in hints:
>            return random.choice(['shard1','shard2', 'shard3'])
>
> Would the above work?

Well, it will certainly work in the sense that you will write the
instance to a random shard. The issue is whether you will be able to
reliably retrieve the objects afterwards. That comes down to exactly
how your auto-increment scheme allocates primary keys. If you can
guarantee that the primary keys are allocated in a programatic way,
then it will probably work.

> Also how random is random - would I get a uniform distribution of
> records among the shards?

Depending on your level of mathematical rigor, that's not a simple
question. To a simple approximation, yes, you'll get a uniform
distribution. However, the patterns and underlying distribution of
random number generators is the subject of continued research and
improvement

Yours,
Russ Magee %-)

-- 
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: Best practice for auth.User/UserProfile division?

2010-08-23 Thread Steve Holden
On 8/23/2010 1:52 AM, adambossy wrote:
> I'm helping build a social networking site which makes heavy use of
> django built-in User model and its relationship to other Users on the
> site. We created a UserProfile per the django documentation [http://
> docs.djangoproject.com/en/dev/topics/auth/#storing-additional-
> information-about-users] that links to a single User object. Hence,
> each time we make a database call involving a user, we retrieve the
> UserProfile model via request.user.get_profile(), which occurs quite
> frequently.
> 
> This seems rather odd, considering the user is passed to our views by
> default, yet has no useful information. I'm no django expert, but my
> assumption is that this design decision was made to allow decoupled
> apps to work together. Since we're basically writing everything in-
> house (generic apps always have *just enough* discrepancies to what we
> want to do that we end up rewriting them), perhaps we're not reaping
> this benefit. My intuition tells me that we should have ignore
> django.contrib.auth.models.User and created our own to which
> everything else on our site relates. Thoughts?
> 

The usual practice is that described in the documentation, as far as I
can tell. By retaining the User model you also retain the ability to use
the standard authentication mechanism. If you decide you can do without
that then knock yourself out, but (for example) the admin subsite
expects that mechanism to be available by default.

You can build your own authentication backend as described in

http://docs.djangoproject.com/en/dev/topics/auth/#specifying-authentication-

but you will see from there that the authenticate() method is expected
to return a django.contrib.auth.models.User instance.

The recommended one-to-one relationship between User and UserProfile
allows you to ensure that there is only one profile per user.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
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: How does Django handle auto-increment PK when a model is sharded horizontally into multiple databases?

2010-08-23 Thread Andy
On Aug 20, 10:04 pm, Russell Keith-Magee 
wrote:

>Of course, given that you know your sharding scheme, you could use the
>router directly.
>
>Tweet.objects.using(router.db_for_read(Tweet, author=a)).filter(author_id=a)

Ah Thanks. This is what I need.


> You won't get any argument from me. What's missing is a clear
> suggestion on how we can encompass this problem in the general case.
> Suggestions are welcome.

One suggestion I have is that any arguments in filter() should also be
passed as part of the hints dictionary to the database router. The
arguments in filter() should be enough information to determine which
shard to select in most cases.

So in the above example:

Tweet.objects.filter(author_id=a)

The keyword:value pair {'author_id': a} should be added to the hints
that got passed to the database router.

This achieves basically the same results as doing
Tweet.objects.using(router.db_for_read(Tweet,
author_id=a)).filter(author_id=a)
But it doesn't require going through the entire codebase and modifying
every single queryset so it's less prone to error and more DRY.


I have another use case where I want to shard by primary pk which is
an auto-increment. I have this model:

class Auction(models.Model):
seller_id = models.IntegerField()
text = models.TextField()
price = models.DecimalField()

The PK of Auction is the auto-increment "id" field.

Say I divide Auction into 3 shards and set up each shard so that the
auto-increment id's don't collide.

When I first create and save a new auction, it doesn't have an "id",
so I just want to randomly pick a shard to save to:

def db_for_write(self, model, **hints):
if model.__name__ == "Auction" and 'instance' not in hints:
return random.choice(['shard1','shard2', 'shard3'])

Would the above work?

Also how random is random - would I get a uniform distribution of
records among the shards?

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-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 + Google App Engine, Getting Started Tutorial

2010-08-23 Thread Steve Holden
On 8/23/2010 7:29 AM, Russell Keith-Magee wrote:
> On Mon, Aug 23, 2010 at 1:01 PM, nobosh  wrote:
>> I'm very interested in finding a up-to-date tutorial that shows steps
>> for getting DJANGO running on Google App Engine, anyone know of any
>> such tutorials?
>>
>> Surprisingly, Google's App Engine DJANGO docs are almost a year old.
>> What gives?
> 
> That's something you'll have to take up with Google. The Django
> project doesn't have any formal affiliation or support for App Engine.
> Any technical or documentation flaws you find should be reported to
> Google, not to us.
> 
And, by the way, that's "Django", not "DJANGO" - it isn't an acronym,
it's a tribute to a gypsy guitarist.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
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 + Google App Engine, Getting Started Tutorial

2010-08-23 Thread Russell Keith-Magee
On Mon, Aug 23, 2010 at 1:01 PM, nobosh  wrote:
> I'm very interested in finding a up-to-date tutorial that shows steps
> for getting DJANGO running on Google App Engine, anyone know of any
> such tutorials?
>
> Surprisingly, Google's App Engine DJANGO docs are almost a year old.
> What gives?

That's something you'll have to take up with Google. The Django
project doesn't have any formal affiliation or support for App Engine.
Any technical or documentation flaws you find should be reported to
Google, not to us.

Yours,
Russ Magee %-)

-- 
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: ANN: nosedjango 0.8.1

2010-08-23 Thread Reinout van Rees

On 08/23/2010 08:54 AM, Jyrki Pulliainen wrote:

Hi there,

I'm pleased to announce new version of Django testing plugin for nose:
nosedjango version 0.8.1.


What are the differences with http://pypi.python.org/pypi/django-nose?
I just got my test + hudson setup more or less working, so I'm 
interested in alternatives :-)



Reinout

--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
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: Come on, share your django powered sites with others.//Fwd: A tornado powered site to show any project powered sites(open source)

2010-08-23 Thread Stone Puzzle
It's official online now after two weeks beta testing.
A bunch of sites already been submitted, come on and enjoy it.

Below list some popular projects' sub-sites:

http://django.poweredsites.org Django poweredsites

http://mongodb.poweredsites.org MongoDB powered sites.

http://jquery.poweredsites.org jQuery powered sites

http://python.poweredsites.org Python powered sites

http://yii.poweredsites.org Yii framework powered sites.

http://flask.poweredsites.org Flask powered sites.

On Mon, Aug 9, 2010 at 4:03 PM, Stone Puzzle  wrote:

> Yes, but this site can show more powered by information.
>
> For example:
> A site powered by python/django/jquery/apache/memcached,
>
> the site will be listed at http://django.poweredsites.org and
> http://python.poweredsites.org and http://jquery.poweredsites.org etc,
>
> so it's more easy to share powered by information with other projects.
>
>
> On Mon, Aug 9, 2010 at 12:27 AM, shacker  wrote:
>
>> On Aug 7, 9:50 pm, Stone Puzzle  wrote:
>> > Django powered sites list  http://django.poweredsites.org
>>
>> A much more complete database is at  http://www.djangosites.org/
>>
>> ./s
>>
>> --
>> 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: FileField empty after form validation

2010-08-23 Thread Karen Tracey
On Mon, Aug 23, 2010 at 4:14 AM, josephi  wrote:

> Hi, I have a suspicion that my problem might not be Django specific,
> but I'm not entirely sure, and would appreciate any pointers to
> information on the subject.
>
> I have a Form with several fields, one of which is a FileField. This
> field is required. If I fill in the FileField but the form doesn't
> validate because of other field errors the FileField widget becomes
> empty once the form is redisplayed after validation. This forces the
> user to re-select their file.
>
> Can anyone tell me the reason for this? Is there a workaround?
>

The reason is because typically browsers don't allow the web server to
pre-fill a file input with a value. (Allowing this would enable malicious
servers to easily trick naive users into uploading sensitive files.)

Karen
-- 
http://tracey.org/kmt/

-- 
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: first time app - admin site importerror

2010-08-23 Thread Alexandre González
I think that you must write models, not model

On Mon, Aug 23, 2010 at 11:50, maclin kallat wrote:

> Try and check if all the imports in your models.py file are OK.
>
> --
> *From:* burnsr77 
> *To:* Django users 
> *Sent:* Mon, 23 August, 2010 5:09:02
> *Subject:* first time app - admin site importerror
>
> Hi everyone, I have begun my first Django app according to the
> instructions on the site (http://docs.djangoproject.com/en/1.2/intro/
> tutorial02/). I've followed the instructions to activate the admin
> site, but the site doesn't seem to load correctly. This is the error
> I'm getting:
> "ImportError at /admin/
> No module named model"
>
> As you can see below I've added "django.contrib.admin" to my
> Installed_Apps; afterwards I ran "python manage.py syncdb". I've also
> uncommented the 3 lines in my urls.py file. I think it's unrelated
> (and if it is please ignore this), but just so you know, when I run
> "python" and then "import django" I have to first run "from
> django.conf import settings; settings.configure()" before I can run
> "from django.db import models".
>
> Since I'm not sure how much info I need to give, I'm posting the
> Traceback error below. I'm running RHEL 5. Does anyone have any ideas
> about why it might not be working? Do you need more information than
> what I've given? Thank you all so much in advance for whatever help
> you can offer!!
>
> -Begin Traceback---
>
> Environment:
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/admin/
> Django Version: 1.2.1
> Python Version: 2.7.0
> Installed Applications:
> ['django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'mysite.polls',
> 'django.contrib.admin']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
> django/core/handlers/base.py" in get_response
>   91.  request.path_info)
> File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
> django/core/urlresolvers.py" in resolve
>   214.  for pattern in self.url_patterns:
> File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
> django/core/urlresolvers.py" in _get_url_patterns
>   243.  patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
> File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
> django/core/urlresolvers.py" in _get_urlconf_module
>   238.  self._urlconf_module = import_module(self.urlconf_name)
> File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
> django/utils/importlib.py" in import_module
>   35.  __import__(name)
> File "/home/myj02/mysite/../mysite/urls.py" in 
>   5. admin.autodiscover()
> File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
> django/contrib/admin/__init__.py" in autodiscover
>   24.  import_module('%s.admin' % app)
> File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
> django/utils/importlib.py" in import_module
>   35.__import__(name)
>
> Exception Type: ImportError at /admin/
> Exception Value: No module named model
>
> --
> 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.
>



-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx

-- 
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: first time app - admin site importerror

2010-08-23 Thread maclin kallat
Try and check if all the imports in your models.py file are OK.




From: burnsr77 
To: Django users 
Sent: Mon, 23 August, 2010 5:09:02
Subject: first time app - admin site importerror

Hi everyone, I have begun my first Django app according to the
instructions on the site (http://docs.djangoproject.com/en/1.2/intro/
tutorial02/). I've followed the instructions to activate the admin
site, but the site doesn't seem to load correctly. This is the error
I'm getting:
"ImportError at /admin/
No module named model"

As you can see below I've added "django.contrib.admin" to my
Installed_Apps; afterwards I ran "python manage.py syncdb". I've also
uncommented the 3 lines in my urls.py file. I think it's unrelated
(and if it is please ignore this), but just so you know, when I run
"python" and then "import django" I have to first run "from
django.conf import settings; settings.configure()" before I can run
"from django.db import models".

Since I'm not sure how much info I need to give, I'm posting the
Traceback error below. I'm running RHEL 5. Does anyone have any ideas
about why it might not be working? Do you need more information than
what I've given? Thank you all so much in advance for whatever help
you can offer!!

-Begin Traceback---

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.2.1
Python Version: 2.7.0
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'mysite.polls',
'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/core/handlers/base.py" in get_response
  91.  request.path_info)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/core/urlresolvers.py" in resolve
  214.  for pattern in self.url_patterns:
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/core/urlresolvers.py" in _get_url_patterns
  243.  patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/core/urlresolvers.py" in _get_urlconf_module
  238.  self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/utils/importlib.py" in import_module
  35.   __import__(name)
File "/home/myj02/mysite/../mysite/urls.py" in 
  5. admin.autodiscover()
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/contrib/admin/__init__.py" in autodiscover
  24.   import_module('%s.admin' % app)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/utils/importlib.py" in import_module
  35.__import__(name)

Exception Type: ImportError at /admin/
Exception Value: No module named model

-- 
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-admin.py cleanup large scale

2010-08-23 Thread bfrederi
It turned out that the easiest and most effective way to handle it was
to run this script at an off peak time:

http://djangosnippets.org/snippets/1273/

Not really sure how long it actually took to ran (I should have timed
it...), but it was less than 2 and a half hours on 40+ million
records.

On Aug 23, 12:17 am, bfrederi  wrote:
> When I attempt to run a normal cleanup, the cleanup eventually loses
> connection to the database and dies. I think I am going to have to
> take the manual approach.
>
> One thing that I wanted to point out is that I think you meant the SQL
> equivalent is:
>
> DELETE FROM django_session WHERE expire_date < '2010-01-01 1:23:45';
>
> It should be less than, I believe. But that is very helpful, and I
> will need to use that to clean up the session table manually.
>
> On Aug 20, 8:44 pm, Russell Keith-Magee 
> wrote:
>
> > On Fri, Aug 20, 2010 at 11:51 PM, bfrederi  wrote:
> > > I just wanted to know if anyone had an opinion or whether running a
> > > django-admin.py cleanup on 40 million session rows might slow down or
> > > lock up the database. I would like to do this cleanup ASAP, but I was
> > > concerned it might cause some issues.
>
> > It depends entirely on your database. If you're using MySQL with
> > MyISAM tables, then almost certainly yes due to the table-level
> > locking. Other databases may be affected for different reasons.
>
> > If you're trying to evaluate the risk, the cleanup command executes
> > the following:
>
> > Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
>
> > Which is the SQL equivalent of:
>
> > DELETE FROM django_session WHERE expire_date > '2010-01-01 1:23:45';
>
> > inside a the default transaction mode for your database. You'll have
> > to consult your database documentation to establish whether that will
> > pose a locking risk.
>
> > Yours,
> > Russ Magee %-)

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



FileField empty after form validation

2010-08-23 Thread josephi
Hi, I have a suspicion that my problem might not be Django specific,
but I'm not entirely sure, and would appreciate any pointers to
information on the subject.

I have a Form with several fields, one of which is a FileField. This
field is required. If I fill in the FileField but the form doesn't
validate because of other field errors the FileField widget becomes
empty once the form is redisplayed after validation. This forces the
user to re-select their file.

Can anyone tell me the reason for this? Is there a workaround?

Thankyou

Joseph

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



DJANGO + Google App Engine, Getting Started Tutorial

2010-08-23 Thread nobosh
I'm very interested in finding a up-to-date tutorial that shows steps
for getting DJANGO running on Google App Engine, anyone know of any
such tutorials?

Surprisingly, Google's App Engine DJANGO docs are almost a year old.
What gives?

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



first time app - admin site importerror

2010-08-23 Thread burnsr77
Hi everyone, I have begun my first Django app according to the
instructions on the site (http://docs.djangoproject.com/en/1.2/intro/
tutorial02/). I've followed the instructions to activate the admin
site, but the site doesn't seem to load correctly. This is the error
I'm getting:
"ImportError at /admin/
No module named model"

As you can see below I've added "django.contrib.admin" to my
Installed_Apps; afterwards I ran "python manage.py syncdb". I've also
uncommented the 3 lines in my urls.py file. I think it's unrelated
(and if it is please ignore this), but just so you know, when I run
"python" and then "import django" I have to first run "from
django.conf import settings; settings.configure()" before I can run
"from django.db import models".

Since I'm not sure how much info I need to give, I'm posting the
Traceback error below. I'm running RHEL 5. Does anyone have any ideas
about why it might not be working? Do you need more information than
what I've given? Thank you all so much in advance for whatever help
you can offer!!

-Begin Traceback---

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.2.1
Python Version: 2.7.0
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'mysite.polls',
 'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/core/handlers/base.py" in get_response
  91.  request.path_info)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/core/urlresolvers.py" in resolve
  214.  for pattern in self.url_patterns:
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/core/urlresolvers.py" in _get_url_patterns
  243.  patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/core/urlresolvers.py" in _get_urlconf_module
  238.  self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/utils/importlib.py" in import_module
  35.   __import__(name)
File "/home/myj02/mysite/../mysite/urls.py" in 
  5. admin.autodiscover()
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/contrib/admin/__init__.py" in autodiscover
  24.   import_module('%s.admin' % app)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-py2.7.egg/
django/utils/importlib.py" in import_module
  35.__import__(name)

Exception Type: ImportError at /admin/
Exception Value: No module named model

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



ANN: nosedjango 0.8.1

2010-08-23 Thread Jyrki Pulliainen
Hi there,

I'm pleased to announce new version of Django testing plugin for nose:
nosedjango version 0.8.1.

With this plugin you can write standard Nose unit tests for a Django
application. The plugin takes care of finding your applications
settings.py file and creating/tearing down test database. It also has
support for fixtures and it has experimental mechanism that wraps the
tests in transactions to speed up testing. This plugin works with
Django versions 1.0 or newer, though multi-db testing is supported
only when using django.test.TestCase.

The plugin is available in PyPI: http://pypi.python.org/pypi/NoseDjango/0.8.1

For those using Ubuntu, I've made packages available for 10.04 (Lucid
Lynx) in my PPA: https://launchpad.net/~jyrki-pulliainen/+archive/ppa

Source and issue tracker are available in Github: 
http://github.com/inoi/nosedjango

Cheers,
Jyrki

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