handle runtime exceptions in django view functions

2011-02-06 Thread km
Hi all,
How do I log exceptions to a file from view functions at runtime ?
I am using nginx (0.8.54) + uwsgi (0.9.6.7) + django(1.2.4) setup with
python 2.7
the uwsgi doesnt seem to log any errors from the django views even when I
use --logto option for uwsgi

pls let me know
thanks,
KM

-- 
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 on adding CSS to django project

2011-02-06 Thread h@ck5t0ck
Ronghui Yu,
Can you please tell me which middleware you're talking about here?
I've still not been able to get my css to work.

On Feb 5, 11:29 am, Ronghui Yu  wrote:
> It seems that you need to setup your web server to support static contents,
> django has a middleware to do the job, but it is not recommended to use it
> in product environment. I had this similar problem when I started to learn
> django.
>
>
>
>
>
>
>
> On Sat, Feb 5, 2011 at 6:15 AM, Chris Hannam  wrote:
> > Apologies for that premature send:
>
> >> Hi,
> >> The way I have approached this is to have a static dir set in my urls.py:
>
> > (r'^static/(?P.*)$', 'django.views.static.serve', {
> >             'document_root': settings.MEDIA_ROOT }
> >          )
>
> > settings.py has the following
> > MEDIA_ROOT = os.path.join(PATH_SITE_ROOT, 'static')
> > PATH_SITE_ROOT = os.path.normpath(os.path.dirname(__file__))
>
> > I reference the css files in the html as /static/css/style.css etc
>
> > The urls.py maps the url to the location on disk of the css files.
>
> > Can you supply the error messages and some of your config if you are still
> > having issues?
>
> > CH
>
> > --
> > 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.
>
> --
> ===
> Regards
> Ronghui Yu

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



How to define each model in its own file

2011-02-06 Thread h@ck5t0ck
Hi Guys,
Am very new to django and am working on a relatively large web
application which includes over 15 models.
Now I want to define each model in its own file and store them in a
folder called models, so I first created the folder "models" and
created a file "__init__.py" in that folder and defined each model in
a separate file but its not working.
Any help on this?

-- 
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: Amazing work

2011-02-06 Thread Mike Seidle
On Thursday, February 03, 2011 08:02:43 pm Cal Leeming [Simplicity Media Ltd] 
wrote:
> May I ask, how well did you get along with Zope? From what I can tell,
> Django is suited for SME, where as Zope is the kinda thing that banks would
> be using etc.

Cal - 

I just used Django to write a credit card processing application (as in 
internet gateway w/API for third party sites).  Zope would have simply been 
way to heavy to handle the transaction load, and frankly, most financial 
applications fit the RDBMS model much better than the object database model.  

On the SME/Enterprise statement: Just because a software package is not 
complicated does not mean that it does not fit in the enterprise space.  I've 
found that often the more simple a tool is the *better it fits* in large 
organizations.

Mike

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



Upgrading to 1.2.4

2011-02-06 Thread vanderkerkoff
Hi Guys

I've gone a long way to upgrade an application we wrote in ages ago in
really old django to new django, I've got stuck some way into it
though.  Front end all sorted, I can fire up the app so the admin.py
stuff is all working, but when I click on anything inside the admin,
for this example we'll use Groups, I get an error.

Caught ImportError while rendering: No module named urls

referring to

In template /Library/Python/2.6/site-packages/django/contrib/admin/
templates/admin/change_list.html, error at line 11

The line is

{% url admin:jsi18n as jsi18nurl %}


I'm using django1.2.4

I've got all this in my urlsCONF

from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^admin/(.*)', admin.site.root),

If I try clicking on any of the other applications in this project
they all give the same error.  It's like I'm not passing the url stuff
over to the templates, but only the admin templates.

I'm obviously doing something stupid, any help, greatly appreciated.

-- 
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: How to know if is a update or insert??

2011-02-06 Thread andmart
In a insert or in a update, the pk is already filled in
ModelAdmin.save_model.

The creation of object in database is in ModelForm.save.

So, I think it's not the way to handle it.

I notivced googling there is a boolean parameter named change and I'm
using it.

On 4 fev, 21:09, Marc Aymerich  wrote:
> On Fri, Feb 4, 2011 at 10:13 PM, andmart  wrote:
> > Hi,
>
> > I overrided the save_model of ModelAdmin of model Client that is
> > associated a one User so I can create a user when a client is created.
>
> > Well, how to know if the save_model was called to do a update or a
> > insert if the object already exists in database?
>
> > Trying to see if model.pk exists fail.
>
> Hi, I've never had problemas with:
>
> def save(self, *args):
>     if self.pk:
>         #update
>     else:
>         #insert
>
> this is how you check if model.pk exists?
>
> --
> 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: Having trouble creating instances of another model in the __init__ of one model

2011-02-06 Thread Aryeh Leib Taurog
On Feb 5, 5:09 pm, Daniel Klein  wrote:
> So I need to create the two teams for a new game instance when I
> create the game instance? That just feels so clumsy.

Doesn't seem so terrible to me, but if you're likely to do it in
several places you could use a custom ModelManager [1] with a
create_game_and_teams() function to set everything up correctly.

[1] http://docs.djangoproject.com/en/1.2/topics/db/managers/

BTW, when using super, it isn't necessary to pass 'self' explicitly;
it will be prepended to the argument list automatically as with any
other method call [2].

[2] http://docs.python.org/library/functions.html#super

-- 
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: How to define each model in its own file

2011-02-06 Thread Mark (Nosrednakram)
If there isn't anything in your models/__init__.py nothing will get
loaded.  You might try somthing like the following in your models/
__init__.py:

from app.models import modelname
from app.models import anothermodelname

Where modlenames are actually individual files with model definitions.

Sorry not in a position to test but believe this should work.

Mark

On Feb 6, 5:39 am, "h@ck5t0ck"  wrote:
> Hi Guys,
> Am very new to django and am working on a relatively large web
> application which includes over 15 models.
> Now I want to define each model in its own file and store them in a
> folder called models, so I first created the folder "models" and
> created a file "__init__.py" in that folder and defined each model in
> a separate file but its not working.
> Any help on this?

-- 
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: how to make a datatime filed model without timestamp?

2011-02-06 Thread Aryeh Leib Taurog
On Feb 5, 1:04 pm, Nima Gaemi  wrote:
> hello,
> i am using Djano 1.3 rev.15387 and i made a field
> 'last_updated=models.DateTimeField(auto_now=True)'
> when i wanted to get the data out of the database i wanted to get a
> delta with datetime module of python but i was warned that my
> datetime.datetime.now() object was not timezone aware.so i though
> about turning off timezone in postgres too.with pgadmin i was able to
> turn it off and my results was ok.but i don't know if i can do similar
> at the time of model creation in django model.is that possible? [sth
> like  last_updated=models.DateTimeField(timestamp_timezoneaware=False)]

I use my own now() function which generates a tz-aware datetime object.

-- 
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: different length queries

2011-02-06 Thread gintare
Thanks a lot for the answers!
I did not found that it is possible to use dictionaries and lists in
query.
In the end i used raw function to form string according form input.
Lists and Dictionaries is much better way, since i am not tied to
certain database.

regards,
gintare

On Feb 3, 12:08 pm, Tom Evans  wrote:
> On Thu, Feb 3, 2011 at 9:51 AM,gintare wrote:
>
> > answer to my previous question about different length queries
> >http://docs.djangoproject.com/en/dev/topics/db/sql/
> > #for p in Person.objects.raw('SELECT * FROM myapp_person')
>
> > Is it possible to post all the question which i send immediately?
> > Sometimes i find answer by myself.
>
> > I also soon would like to be able to delete all my posts and put
> > instead one summary post with main issues i met during self learning
> > from manuals.
>
> Typically people look for the answer first, before asking for help, so
> as to avoid that kind of situation. Once you've sent an email to a
> mailing list, and it is delivered, there is no recalling - that sucker
> will be archived in thousands of places for eternity - so try not to
> look like a fool!
>
> 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: Upgrading to 1.2.4

2011-02-06 Thread vanderkerkoff
Aha

I had the old admin line still in the urls file beneath the new one,
it was twistin the melons :-)

I've deleted the old line and all is well.



On Feb 6, 1:38 pm, vanderkerkoff  wrote:
> Hi Guys
>
> I've gone a long way to upgrade an application we wrote in ages ago in
> really old django to new django, I've got stuck some way into it
> though.  Front end all sorted, I can fire up the app so the admin.py
> stuff is all working, but when I click on anything inside the admin,
> for this example we'll use Groups, I get an error.
>
> Caught ImportError while rendering: No module named urls
>
> referring to
>
> In template /Library/Python/2.6/site-packages/django/contrib/admin/
> templates/admin/change_list.html, error at line 11
>
> The line is
>
> {% url admin:jsi18n as jsi18nurl %}
>
> I'm using django1.2.4
>
> I've got all this in my urlsCONF
>
> from django.conf.urls.defaults import *
> from django.contrib import admin
> admin.autodiscover()
> urlpatterns = patterns('',
>         (r'^admin/(.*)', admin.site.root),
>
> If I try clicking on any of the other applications in this project
> they all give the same error.  It's like I'm not passing the url stuff
> over to the templates, but only the admin templates.
>
> I'm obviously doing something stupid, any help, greatly appreciated.

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



File Upload

2011-02-06 Thread vanderkerkoff
Hello everyone

I'm trying to upload a file in a project, the app is called Documents,
here's the admin.py

from django.contrib import admin
from governors.documents.models import Document
import datetime

class DocumentAdmin(admin.ModelAdmin):
fields = ('title','slug','the_file','lang_code')
list_display = ('title',)
search_fields = ('title',)
prepopulated_fields = { 'slug': ('title',) }
ordering = ('title',)

admin.site.register(Document, DocumentAdmin)

I keep getting an error I don't understand

Exception Type: AttributeError at /admin/documents/document/add/
Exception Value: 'tuple' object has no attribute 'startswith'

Here's the stack trace

http://dpaste.com/391662/

Anyone got any ideas?

Again, it's more than likely my idiocy shining through again :-)

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



CheckboxSelectMultiple widget not ticked correctly according to loaded CharField value

2011-02-06 Thread Haisheng HU
So I have a form:
class ProjectUpdateForm(ModelForm):
products = MultipleChoiceField(label = u'Products', 
widget=CheckboxSelectMultiple)
def __init__(self, *args, **kwargs):
self.fields['products'].choices = [(x.code, x.name) for x in 
Product.objects.order_by('code')]


which was referenced from a view:
class ProjectUpdateView(UpdateView):
model = Project
form_class = ProjectUpdateForm


The products field can be created from a similar form successfully and saved 
to database CharField as a list of values. Eg. [u'A01', u'A02']. But for 
this update view, the corresponding checkboxs always keep unchecked, 
neglecting the field value of the model object.

What did I miss? Thanks in ad!

~hanson

-- 
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: File Upload

2011-02-06 Thread Karen Tracey
On Sun, Feb 6, 2011 at 9:50 AM, vanderkerkoff  wrote:

> I'm trying to upload a file in a project, the app is called Documents,
> here's the admin.py
>
> [snipped]
More interesting than the admin.py for this model would have been the model
definition itself.


>
> I keep getting an error I don't understand
>
> Exception Type: AttributeError at /admin/documents/document/add/
> Exception Value: 'tuple' object has no attribute 'startswith'
>
> Here's the stack trace
>
> http://dpaste.com/391662/
>
> Anyone got any ideas?
>

Stack trace seems to be indicating a problem with your file field's
upload_to value. Doc for that value is here:
http://docs.djangoproject.com/en/1.2/ref/models/fields/#filefield. Traceback
seems to be saying you've got it defined as a tuple rather than a string or
callable.

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-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: How to know if is a update or insert??

2011-02-06 Thread Marc Aymerich
On Sun, Feb 6, 2011 at 2:53 PM, andmart  wrote:
> In a insert or in a update, the pk is already filled in
> ModelAdmin.save_model.
>
> The creation of object in database is in ModelForm.save.
>
> So, I think it's not the way to handle it.
>
> I notivced googling there is a boolean parameter named change and I'm
> using it.

Hi andmart,
Do you have more information about this boolean parameter? do you have
the link to the website where you find it?
what you comment seems quite useful :)



-- 
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: File Upload

2011-02-06 Thread Chris Hannam
Hi,
startswith is usually a string method. Looks like something is calling
.startwith() on a tuple rather than the expected string.

When you instantiate your model are you certain all the values are correct?
Try logging all the values before creating the model and look for a tuple
where there should be a string.

CH

-- 
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: File Upload

2011-02-06 Thread vanderkerkoff
Hi Karen

Thanks for getting back

Here's the model def

http://dpaste.com/391872/



On Feb 6, 3:33 pm, Karen Tracey  wrote:
> On Sun, Feb 6, 2011 at 9:50 AM, vanderkerkoff  wrote:
> > I'm trying to upload a file in a project, the app is called Documents,
> > here's the admin.py
>
> > [snipped]
>
> More interesting than the admin.py for this model would have been the model
> definition itself.
>
>
>
> > I keep getting an error I don't understand
>
> > Exception Type: AttributeError at /admin/documents/document/add/
> > Exception Value: 'tuple' object has no attribute 'startswith'
>
> > Here's the stack trace
>
> >http://dpaste.com/391662/
>
> > Anyone got any ideas?
>
> Stack trace seems to be indicating a problem with your file field's
> upload_to value. Doc for that value is 
> here:http://docs.djangoproject.com/en/1.2/ref/models/fields/#filefield. 
> Traceback
> seems to be saying you've got it defined as a tuple rather than a string or
> callable.
>
> 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-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.



model names

2011-02-06 Thread Bobby Roberts
if i have a model name "Facility", django adds an "s" to it in /admin
and it shows up as Facilitys.  How can I make it show up as
"Facilities" in /admin?

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



population of *.html fields from Django

2011-02-06 Thread gintare
I would like to use only plain html field names
Reading them is not a problem with request in views.
How to populate html document back ?


I have *.html with lines:


 
 
 

#in views.py
item = request.POST.get('cbnWw','')
#do smth with item
#now i would like to return item back to html.
#Normally i should use {{ }} for variable output.
#IS IT POSSIBLE TO USE HTML SYNTAX  and populate textarea and
checkboxes

 return render_to_response('x.html',{ 'LangFROMt', 'EN'}, 


?
regards,
gintare

-- 
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: handle runtime exceptions in django view functions

2011-02-06 Thread Shawn Milochik

Use Python's logging.

http://docs.python.org/library/logging

If you're using the 1.3 beta, logging config is built into settings.py.

Then, in your try/except blocks, you can log anything you want; pass the 
exception message and the traceback into your call to the logger, and 
it'll all be there when you want it.


You'll probably want to add multiple logging handlers. We use a file 
handler and an e-mail handler. Anything log.error and above is e-mailed 
in addition to being written to log files. Everything else is just 
written to log files.


Shawn


--
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: File Upload

2011-02-06 Thread vanderkerkoff
Hiya both

I'm outputting all the data types I'm saving now in a save in the
admin.py, they're all strings :-(

I'm going to kick myself when I find it




On Feb 6, 4:11 pm, vanderkerkoff  wrote:
> Hi Karen
>
> Thanks for getting back
>
> Here's the model def
>
> http://dpaste.com/391872/
>
> On Feb 6, 3:33 pm, Karen Tracey  wrote:
>
>
>
> > On Sun, Feb 6, 2011 at 9:50 AM, vanderkerkoff  wrote:
> > > I'm trying to upload a file in a project, the app is called Documents,
> > > here's the admin.py
>
> > > [snipped]
>
> > More interesting than the admin.py for this model would have been the model
> > definition itself.
>
> > > I keep getting an error I don't understand
>
> > > Exception Type: AttributeError at /admin/documents/document/add/
> > > Exception Value: 'tuple' object has no attribute 'startswith'
>
> > > Here's the stack trace
>
> > >http://dpaste.com/391662/
>
> > > Anyone got any ideas?
>
> > Stack trace seems to be indicating a problem with your file field's
> > upload_to value. Doc for that value is 
> > here:http://docs.djangoproject.com/en/1.2/ref/models/fields/#filefield. 
> > Traceback
> > seems to be saying you've got it defined as a tuple rather than a string or
> > callable.
>
> > 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-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: model names

2011-02-06 Thread Joel Goldstick
On Sun, Feb 6, 2011 at 11:33 AM, Bobby Roberts  wrote:

> if i have a model name "Facility", django adds an "s" to it in /admin
> and it shows up as Facilitys.  How can I make it show up as
> "Facilities" in /admin?
>
> --
> 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.
>
>
http://docs.djangoproject.com/en/dev/topics/db/models/ shows this:
Meta 
options¶

Give your model metadata by using an inner class Meta, like so:

class Ox(models.Model):
horn_length = models.IntegerField()

class Meta:
ordering = ["horn_length"]
verbose_name_plural = "oxen"



-- 
Joel Goldstick

-- 
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: File Upload

2011-02-06 Thread Karen Tracey
On Sun, Feb 6, 2011 at 11:11 AM, vanderkerkoff  wrote:

> Hi Karen
>
> Thanks for getting back
>
> Here's the model def
>
> http://dpaste.com/391872/
>
>
I cut and pasted that model definition, plus the model admin shown earlier,
into a test project, and I'm able to add Documents in the admin with no
error. It seems that somehow you are running code other than what you have
posted. In the debug page you can look at the values of local variables, so
maybe you cold get a hint of what's happening by taking a look at the actual
value of s (the tuple python is complaining  does not have a startwith
attribute).

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



Database per user

2011-02-06 Thread Giilp
Hi,

I am a starting in Django, working on the architecture of my future
application.
My application involves users creating a large amount of points. In
the old application (php), there was significant perf. issues because
of the large amout of points in the database.
I was wondering if it would be possible to have a database/user
(sqlite) using Django.

Thanks.
Gillesp

-- 
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: model names

2011-02-06 Thread Bobby Roberts
yeah i tried that already and it didn't work

On Feb 6, 11:38 am, Joel Goldstick  wrote:
> On Sun, Feb 6, 2011 at 11:33 AM, Bobby Roberts  wrote:
> > if i have a model name "Facility", django adds an "s" to it in /admin
> > and it shows up as Facilitys.  How can I make it show up as
> > "Facilities" in /admin?
>
> > --
> > 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.
>
> http://docs.djangoproject.com/en/dev/topics/db/models/shows this:
> Meta 
> options¶
>
> Give your model metadata by using an inner class Meta, like so:
>
> class Ox(models.Model):
>     horn_length = models.IntegerField()
>
>     class Meta:
>         ordering = ["horn_length"]
>         verbose_name_plural = "oxen"
>
> --
> Joel Goldstick

-- 
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: model names

2011-02-06 Thread Ivo Brodien

On 06.02.2011, at 18:01, Bobby Roberts wrote:

> yeah i tried that already and it didn't work

did you also define the meta class for the Admin class?

-- 
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: File Upload

2011-02-06 Thread vanderkerkoff
Hi Karen

I promise you I'm changing the code that I'm displaying, I've been
updating the app all day,  just tying off some loose ends now.

I've tried copying and pasting all the variables but it looks like
garbage in dpaste.

One thing that I'm not sure if right is the value of the the_file
variable in the output

VariableValue
the_file


Not sure if that is correct

I seem to remember hearing about a situation where you had to save the
file to the filesystem and the record of the file to the  database in
a certain order

hmm

will keep digging

this is a brand new mac install if that's anything to go by

thanks for helping, it is really appreciated

On Feb 6, 4:39 pm, Karen Tracey  wrote:
> On Sun, Feb 6, 2011 at 11:11 AM, vanderkerkoff  wrote:
> > Hi Karen
>
> > Thanks for getting back
>
> > Here's the model def
>
> >http://dpaste.com/391872/
>
> I cut and pasted that model definition, plus the model admin shown earlier,
> into a test project, and I'm able to add Documents in the admin with no
> error. It seems that somehow you are running code other than what you have
> posted. In the debug page you can look at the values of local variables, so
> maybe you cold get a hint of what's happening by taking a look at the actual
> value of s (the tuple python is complaining  does not have a startwith
> attribute).
>
> 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-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: File Upload

2011-02-06 Thread vanderkerkoff
I got it :-)

import os
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))

# MEDIA_ROOT = (
#   os.path.join(PROJECT_PATH, 'static/media/'),
# )

MEDIA_ROOT = '/Users/mjdavies/Sites/django/governors/static/media/'

statically pointing the media root works


I use the same method above to grab templates, and that works ok

at least we got it sorted

thanks again



On Feb 6, 5:16 pm, vanderkerkoff  wrote:
> Hi Karen
>
> I promise you I'm changing the code that I'm displaying, I've been
> updating the app all day,  just tying off some loose ends now.
>
> I've tried copying and pasting all the variables but it looks like
> garbage in dpaste.
>
> One thing that I'm not sure if right is the value of the the_file
> variable in the output
>
> Variable        Value
> the_file
> 
>
> Not sure if that is correct
>
> I seem to remember hearing about a situation where you had to save the
> file to the filesystem and the record of the file to the  database in
> a certain order
>
> hmm
>
> will keep digging
>
> this is a brand new mac install if that's anything to go by
>
> thanks for helping, it is really appreciated
>
> On Feb 6, 4:39 pm, Karen Tracey  wrote:
>
>
>
> > On Sun, Feb 6, 2011 at 11:11 AM, vanderkerkoff  wrote:
> > > Hi Karen
>
> > > Thanks for getting back
>
> > > Here's the model def
>
> > >http://dpaste.com/391872/
>
> > I cut and pasted that model definition, plus the model admin shown earlier,
> > into a test project, and I'm able to add Documents in the admin with no
> > error. It seems that somehow you are running code other than what you have
> > posted. In the debug page you can look at the values of local variables, so
> > maybe you cold get a hint of what's happening by taking a look at the actual
> > value of s (the tuple python is complaining  does not have a startwith
> > attribute).
>
> > 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-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: File Upload

2011-02-06 Thread Karen Tracey
On Sun, Feb 6, 2011 at 12:45 PM, vanderkerkoff  wrote:

> I got it :-)
>
> import os
> PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
>
> # MEDIA_ROOT = (
> #   os.path.join(PROJECT_PATH, 'static/media/'),
> # )
>
> MEDIA_ROOT = '/Users/mjdavies/Sites/django/governors/static/media/'
>
> statically pointing the media root works
>
>
You rather threw out the baby with the bathwater there. The problem with
your original setting was that you made MEDIA_ROOT a tuple, not a string.
Just fixing it to be the right type, but still dynamically computed based on
your project's location, would have been sufficient.


> I use the same method above to grab templates, and that works ok
>
>
Note TEMPLATE_DIRS is supposed to be a tuple:
http://docs.djangoproject.com/en/1.2/ref/settings/#template-dirs

while MEDIA_ROOT is supposed to be a string:
http://docs.djangoproject.com/en/1.2/ref/settings/#media-root

You need to adjust your method when cribbing from one setting to another and
ensure you give each setting a value of the appropriate type.

Note also this is why I suggested taking a look at (not necessarily posting
to the list) the values of the local variables on the debug page. The code
you were focused on (model and model admin defs) was correct, and the
problem was elsewhere. Seeing the actual value of s that was being used
(presumably the tuple MEDIA_ROOT had been set to) might have given you a
clue as to where the problem was.

If you have difficulty understanding all that is presented by the debug page
and how to make use of it, there is a book linked from the page in my sig
that may be helpful to you in improving your debugging skills.

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-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: Database per user

2011-02-06 Thread Chris Hannam
Hi,

http://docs.djangoproject.com/en/1.2/topics/db/multi-db/ contain
information about setting up multiple databases. I personally have no
idea how this would scale to may users.
If you are looking to store large amounts of data I would look at an
alternative to SQLite. I have found http://www.postgresql.org/ to work
very well with large datasets.

CH

-- 
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: File Upload

2011-02-06 Thread vanderkerkoff
Thanks again Karen


On Feb 6, 6:06 pm, Karen Tracey  wrote:
> On Sun, Feb 6, 2011 at 12:45 PM, vanderkerkoff  wrote:
> > I got it :-)
>
> > import os
> > PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
>
> > # MEDIA_ROOT = (
> > #       os.path.join(PROJECT_PATH, 'static/media/'),
> > # )
>
> > MEDIA_ROOT = '/Users/mjdavies/Sites/django/governors/static/media/'
>
> > statically pointing the media root works
>
> You rather threw out the baby with the bathwater there. The problem with
> your original setting was that you made MEDIA_ROOT a tuple, not a string.
> Just fixing it to be the right type, but still dynamically computed based on
> your project's location, would have been sufficient.
>
> > I use the same method above to grab templates, and that works ok
>
> Note TEMPLATE_DIRS is supposed to be a 
> tuple:http://docs.djangoproject.com/en/1.2/ref/settings/#template-dirs
>
> while MEDIA_ROOT is supposed to be a 
> string:http://docs.djangoproject.com/en/1.2/ref/settings/#media-root
>
> You need to adjust your method when cribbing from one setting to another and
> ensure you give each setting a value of the appropriate type.
>
> Note also this is why I suggested taking a look at (not necessarily posting
> to the list) the values of the local variables on the debug page. The code
> you were focused on (model and model admin defs) was correct, and the
> problem was elsewhere. Seeing the actual value of s that was being used
> (presumably the tuple MEDIA_ROOT had been set to) might have given you a
> clue as to where the problem was.
>
> If you have difficulty understanding all that is presented by the debug page
> and how to make use of it, there is a book linked from the page in my sig
> that may be helpful to you in improving your debugging skills.
>
> 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-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: Use development server database with production server

2011-02-06 Thread Cal Leeming [Simplicity Media Ltd]
Hi,

Here is the the way that we have done it for the last 18 months, and has
proven very useful and almost human error free.

I've posted all the concept inside:
http://djangosnippets.org/snippets/2349/

This method allows you to separate the settings.py based on the local server
hostname, and/or the environment variable specified.

For example:

DJANGO_ENVIRONMENT=dev /path/to/manage.py shellDJANGO_ENVIRONMENT=prod
/path/to/manage.py runfcgi




On Sun, Feb 6, 2011 at 6:37 AM, Mike Ramirez  wrote:

>  On Saturday, February 05, 2011 01:52:43 am Amit wrote:
>
> > Hello,
>
> > First of all one should go through with below link;
>
> >
>
> >
> http://stackoverflow.com/questions/4887851/django-database-settings-for-pro
>
> > duction-server
>
> >
>
> >
>
> > Now, let come up with my hurdle. I am using a database lay out in
>
> > filesystem(windows) say;
>
> > C:/miami/data.db
>
> >
>
> > I have to use same database with production server, since I don’t have
>
> > avail corresponding database in PostGreSQL.
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > Amit.
>
> Witht his situation you might want to have a local_settings.py file. This
> file should be local to the django instance and not part of any revision or
> deployment strategy unless you're providing a templated form for others to
> modify (name the templated local_settings.py something else like
> local_settings.tmpl).
>
> In settings.py add this to the top:
>
> from local_settings import *
>
> Remove the database settings from settings.py (and anything else you've
> added to local_settings.py)
>
> in your local_settings.py you have your database settings and any other
> (path based and/or installed apps) settings that are specific to the server.
>
> I've found this approach optimal when dealing with databases, templates,
> middleware, context processors, and installed apps. I can keep my debugging
> stuff out of the production version.
>
> Google "local_settings.py" for more examples. Personally I don't use the
> try/except form shown on some of the blogs, that's because I want it to fail
> loudly and clearly when I attempt to use it with a missing/broken
> local_settings.py.
>
> As a friend once told me, if you're going to fail, fail spetacularly. I
> find this very true with programming.
>
> Mike
>
> --
>
> Detroit is Cleveland without the glitter.
>
>  --
> 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: Amazing work

2011-02-06 Thread Cal Leeming [Simplicity Media Ltd]
Interesting. See, when I compared Zope to Django, I found Django's extensive
documentation and feature set to be perfect for prototyping, and then
optimizing bottlenecks at a later date, either via C extensions, raw SQL
replacement etc. However, as 'cliché' as this may sound, most large
enterprises tend to steer towards the most complicated, most bloated, most
difficult to use "technologies" there are around. Take Microsoft CRM, Java
and *anything* RHEL based as a clear example (others may disagree, this is
just my opinion as I'm a hard headed debian/python guy ;p)

(the above is just my

On Sun, Feb 6, 2011 at 1:21 PM, Mike Seidle  wrote:

> On Thursday, February 03, 2011 08:02:43 pm Cal Leeming [Simplicity Media
> Ltd]
> wrote:
> > May I ask, how well did you get along with Zope? From what I can tell,
> > Django is suited for SME, where as Zope is the kinda thing that banks
> would
> > be using etc.
>
> Cal -
>
> I just used Django to write a credit card processing application (as in
> internet gateway w/API for third party sites).  Zope would have simply been
> way to heavy to handle the transaction load, and frankly, most financial
> applications fit the RDBMS model much better than the object database
> model.
>
> On the SME/Enterprise statement: Just because a software package is not
> complicated does not mean that it does not fit in the enterprise space.
>  I've
> found that often the more simple a tool is the *better it fits* in large
> organizations.
>
> Mike
>
> --
> 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.



answer to question related about the *.html filling with values

2011-02-06 Thread gintare
it is incredibly easy, just difficult to guess out without example.

*.html



{{Output}}  

#

views.py

def web(request):
Out, Ww =request.GET.get('Output',''), request.GET.get('sWw','')

Out='naujas zodis'
sWw= 'off'
t = loader.get_template('c:/Python27/Scripts/Spokas/web.html')
c = Context({
'Output': Out,
})

return HttpResponse(t.render(c))

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



How can I show a list of values in a text input field?

2011-02-06 Thread Nate Reed
I posted this question on StackOverflow, too.  I have defined a Model
with a ManyToManyField, and I want the field to show the values joined
by spaces, for example:



I have defined the form to use CharField to represent the multiple values:

class MyForm(ModelForm):
foo = CharField(label='Foo')
class Meta:
model = MyModel

Instead of showing the values separated by spaces, the input field
shows this instead:

[u'val1', u'val2', u'val3']

How can I override this behavior?  My understanding is that widgets
are responsible for rendering the input.  Is there an example of a
custom widget that does something like this?

Nate

-- 
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: model names

2011-02-06 Thread Bobby Roberts
ah... i only had that on he admin model




On Feb 6, 12:07 pm, Ivo Brodien  wrote:
> On 06.02.2011, at 18:01, Bobby Roberts wrote:
>
> > yeah i tried that already and it didn't work
>
> did you also define the meta class for the Admin class?

-- 
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: Date internationalizaation

2011-02-06 Thread Lachlan Musicman
On Sat, Feb 5, 2011 at 22:38, Simon W  wrote:
> Hey,
> I have a datetime field in my models. When I format the date into letters it
> appears in english and I'd like it in another langue. How to?

Have you turned on i18n/L10n in your settings?
http://docs.djangoproject.com/en/dev/topics/i18n/deployment/
http://docs.djangoproject.com/en/dev/topics/i18n/

Have you told your templates to load i18n?
http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/#specifying-translation-strings-in-template-code

Have you set the field in question on the template to be translate-able?
http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/#specifying-translation-strings-in-template-code

Hope this helps

cheers
L.

> Thank you!
> // Simon
>
> --
> 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.
>



-- 
Crunchiness is the gustatory sensation of muffled grinding of a
foodstuff. Crunchiness differs from crispiness in that a crispy item
is quickly atomized, while a crunchy one offers sustained, granular
resistance to jaw action. While crispiness is difficult to maintain,
crunchiness is difficult to overcome.
from The Best of Wikipedia http://bestofwikipedia.tumblr.com/

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



Re: Help on adding CSS to django project

2011-02-06 Thread h@ck5t0ck
Guys,
Can anyone zipped a working django project which made use of css and
mail it to
me at hackstock...@gmail.com so that I can study how he went about
doing it?
Thanks in advance.
Best Wishes,
h@ck5t0ck

On Feb 6, 12:36 pm, "h@ck5t0ck"  wrote:
> Ronghui Yu,
> Can you please tell me which middleware you're talking about here?
> I've still not been able to get my css to work.
>
> On Feb 5, 11:29 am, Ronghui Yu  wrote:
>
> > It seems that you need to setup your web server to support static contents,
> > django has a middleware to do the job, but it is not recommended to use it
> > in product environment. I had this similar problem when I started to learn
> > django.
>
> > On Sat, Feb 5, 2011 at 6:15 AM, Chris Hannam  wrote:
> > > Apologies for that premature send:
>
> > >> Hi,
> > >> The way I have approached this is to have a static dir set in my urls.py:
>
> > > (r'^static/(?P.*)$', 'django.views.static.serve', {
> > >             'document_root': settings.MEDIA_ROOT }
> > >          )
>
> > > settings.py has the following
> > > MEDIA_ROOT = os.path.join(PATH_SITE_ROOT, 'static')
> > > PATH_SITE_ROOT = os.path.normpath(os.path.dirname(__file__))
>
> > > I reference the css files in the html as /static/css/style.css etc
>
> > > The urls.py maps the url to the location on disk of the css files.
>
> > > Can you supply the error messages and some of your config if you are still
> > > having issues?
>
> > > CH
>
> > > --
> > > 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.
>
> > --
> > ===
> > Regards
> > Ronghui Yu

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



5 GET request after one AJAX request

2011-02-06 Thread Loïc B .
Hi,

title may be confusing, I explain myself.
Using Django, I recently put in place AJAX request handling in my
views.

Before, no problem :
- one adress typing on client side <-> one GET request on server side
- one click on Submit button on a form (client-side) <-> one POST
request on server side


After :
- one adress typing on client side <-> one GET request on server side
- one click on Submit button on a form (client-side) <-> one POST
request on server side
but
- one input modification (which calls $.getJSON, what I call AJAX
REQUEST) <-> one AJAX handling by my view (GET request on specific
url) and then 5 GET request on server side ...


Here is the code preparing my AJAX request on client side :
[...]
$.getJSON('',dict)
[...]

with dict something like :
dict['foo'] = 0

which results in calling : url?foo=0

And here is how I handle this on server side :
[...]
if request.GET.keys():
return
HttpResponse(simplejson.dumps(AJAX_answer),mimetype='application/
javascript')
[...]

with AJAX_answer another dict to be read by javascript on client side.

Any clue concerning the origin of those 5 GET requests ?

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: Amazing work

2011-02-06 Thread Mike Seidle
On Sunday, February 06, 2011 02:54:23 pm Cal Leeming [Simplicity Media Ltd] 
wrote:
> Interesting. See, when I compared Zope to Django, I found Django's
> extensive documentation and feature set to be perfect for prototyping, and
> then optimizing bottlenecks at a later date, either via C extensions, raw
> SQL replacement etc. However, as 'cliché' as this may sound, most large
> enterprises tend to steer towards the most complicated, most bloated, most
> difficult to use "technologies" there are around. Take Microsoft CRM, Java
> and *anything* RHEL based as a clear example (others may disagree, this is
> just my opinion as I'm a hard headed debian/python guy ;p)


Large organizations can screw anything up. With Django, they can screw it up 
while hitting all the deadlines.

-- 
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 on adding CSS to django project

2011-02-06 Thread Martin Tiršel

Hello,

please read the documentation, everything you need to know, is described  
there.


For development:
http://docs.djangoproject.com/en/1.2/howto/static-files/

And for production:
http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/

Regards,
Martin


On Mon, 07 Feb 2011 00:47:27 +0100, h@ck5t0ck   
wrote:



Guys,
Can anyone zipped a working django project which made use of css and
mail it to
me at hackstock...@gmail.com so that I can study how he went about
doing it?
Thanks in advance.
Best Wishes,
h@ck5t0ck

On Feb 6, 12:36 pm, "h@ck5t0ck"  wrote:

Ronghui Yu,
Can you please tell me which middleware you're talking about here?
I've still not been able to get my css to work.

On Feb 5, 11:29 am, Ronghui Yu  wrote:

> It seems that you need to setup your web server to support static  
contents,
> django has a middleware to do the job, but it is not recommended to  
use it
> in product environment. I had this similar problem when I started to  
learn

> django.

> On Sat, Feb 5, 2011 at 6:15 AM, Chris Hannam   
wrote:

> > Apologies for that premature send:

> >> Hi,
> >> The way I have approached this is to have a static dir set in my  
urls.py:


> > (r'^static/(?P.*)$', 'django.views.static.serve', {
> > 'document_root': settings.MEDIA_ROOT }
> >  )

> > settings.py has the following
> > MEDIA_ROOT = os.path.join(PATH_SITE_ROOT, 'static')
> > PATH_SITE_ROOT = os.path.normpath(os.path.dirname(__file__))

> > I reference the css files in the html as /static/css/style.css etc

> > The urls.py maps the url to the location on disk of the css files.

> > Can you supply the error messages and some of your config if you  
are still

> > having issues?

> > CH

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

> --
> ===
> Regards
> Ronghui Yu


--
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: 5 GET request after one AJAX request

2011-02-06 Thread Cal Leeming [Simplicity Media Ltd]
Could you post some actual logs of this happening?


On Sun, Feb 6, 2011 at 11:37 PM, Loïc B.  wrote:

> Hi,
>
> title may be confusing, I explain myself.
> Using Django, I recently put in place AJAX request handling in my
> views.
>
> Before, no problem :
> - one adress typing on client side <-> one GET request on server side
> - one click on Submit button on a form (client-side) <-> one POST
> request on server side
>
>
> After :
> - one adress typing on client side <-> one GET request on server side
> - one click on Submit button on a form (client-side) <-> one POST
> request on server side
> but
> - one input modification (which calls $.getJSON, what I call AJAX
> REQUEST) <-> one AJAX handling by my view (GET request on specific
> url) and then 5 GET request on server side ...
>
>
> Here is the code preparing my AJAX request on client side :
> [...]
> $.getJSON('',dict)
> [...]
>
> with dict something like :
> dict['foo'] = 0
>
> which results in calling : url?foo=0
>
> And here is how I handle this on server side :
> [...]
> if request.GET.keys():
>return
> HttpResponse(simplejson.dumps(AJAX_answer),mimetype='application/
> javascript')
> [...]
>
> with AJAX_answer another dict to be read by javascript on client side.
>
> Any clue concerning the origin of those 5 GET requests ?
>
> 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.
>
>

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