Re: request.method not working as expected

2011-09-20 Thread Andres Reyes
I believe that the best practice is to always use the {% url %} template tag
and not hardcoding your URL's

2011/9/20 Fabio Natali 

> On 09/20/2011 07:15 PM, dm03514 wrote:
>
>> Fabio in your dev server output is it saying the type of request is
>> get?
>> ARe you accessing "/method/" through your form or are you just
>> directing your webserver to 
>> http://192.168.0.2:8000/**method/?
>> ??
>>
>
> Hi dm03514 and thanks for your help!
>
> Thanks to your suggestion I managed to resolve my issue. I looked at my
> development server logs and noticed 2 lines:
>
> [20/Sep/2011 12:17:27] "POST /method HTTP/1.1" 301 0
> [20/Sep/2011 12:17:27] "GET /method/ HTTP/1.1" 200 3
>
> I guess the lack of a trailing slash in my url was causing some sort of
> internal redirection. That redirection eventually caused the loss of POST
> stuff.
>
> I was using this:
>
>  action="http://192.168.0.2:**8000/method
> ">
> I changed that to:
>
>  action="http://192.168.0.2:**8000/method/
> ">
> and everything was fixed.
>
> Don't you think this is too fragile and error prone? I guess I may forget
> the trailing slash again in the future and that will mean the break of
> everything... Is there any best practice for this?
>
> Thanks! Greetings, Fabio.
>
>
> --
> Fabio Natali FNstudio
>
> --
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>


-- 
Andrés Reyes Monge
armo...@gmail.com
+(505)-8873-7217

-- 
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: request.method not working as expected

2011-09-20 Thread Fabio Natali

On 09/20/2011 07:15 PM, dm03514 wrote:

Fabio in your dev server output is it saying the type of request is
get?
ARe you accessing "/method/" through your form or are you just
directing your webserver to http://192.168.0.2:8000/method/???


Hi dm03514 and thanks for your help!

Thanks to your suggestion I managed to resolve my issue. I looked at my 
development server logs and noticed 2 lines:


[20/Sep/2011 12:17:27] "POST /method HTTP/1.1" 301 0
[20/Sep/2011 12:17:27] "GET /method/ HTTP/1.1" 200 3

I guess the lack of a trailing slash in my url was causing some sort of 
internal redirection. That redirection eventually caused the loss of 
POST stuff.


I was using this:
http://192.168.0.2:8000/method;>
I changed that to:
http://192.168.0.2:8000/method/;>
and everything was fixed.

Don't you think this is too fragile and error prone? I guess I may 
forget the trailing slash again in the future and that will mean the 
break of everything... Is there any best practice for this?


Thanks! Greetings, Fabio.

--
Fabio Natali FNstudio

--
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: request.method not working as expected

2011-09-20 Thread Fabio Natali

On 09/20/2011 07:12 PM, Babatunde Akinyanmi wrote:

Correct me if I'm wrong but it seems your "method" function is
supposed to return the request method type(POST or GET) sent to the
view. If I'm correct then your syntax will always return GET. That's
because I think all the django middleware workings adjust the initial
arguments and the response such that it always ends up as a GET.
Try storing request.method in a variable first and then return that
variable with your HttpResponse like

def method(request):
 method_type = request.method
 Return HttpResponse(method_type)


Dear Babatunde, I had already tried that with no luck, that didn't work.

Thank you very much for your suggestion and your kind reply.

--
Fabio Natali FNstudio

--
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: mysql installation error

2011-09-20 Thread Ivan Ivanov
First – It's not a Django question,

and second search, read, but try:
http://www.fuyun.org/2009/12/install-mysql-for-python-on-windows/

That was the second result I found :)

I hope, it is what you need, couse I don't use windows and cannot test
the problem and its solution.

Ivan

На Tue, 20 Sep 2011 22:59:30 -0400
PremAnand Lakshmanan  написа:

> Hi,
> 
> When I try to install mysql I get the following error,
> 
> Pls provide your inputs.
> 
> C:\MYSQL\MySQL-python-1.2.3\MySQL-python-1.2.3>python setup.py install
> Traceback (most recent call last):
>   File "setup.py", line 15, in 
> metadata, options = get_config()
>   File
> "C:\MYSQL\MySQL-python-1.2.3\MySQL-python-1.2.3\setup_windows.py",
> line 7 , in get_config
> serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
> options['registry_ke
> y'])
> WindowsError: [Error 2] The system cannot find the file specified
> 

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



mysql installation error

2011-09-20 Thread PremAnand Lakshmanan
Hi,

When I try to install mysql I get the following error,

Pls provide your inputs.

C:\MYSQL\MySQL-python-1.2.3\MySQL-python-1.2.3>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 15, in 
metadata, options = get_config()
  File "C:\MYSQL\MySQL-python-1.2.3\MySQL-python-1.2.3\setup_windows.py",
line 7
, in get_config
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
options['registry_ke
y'])
WindowsError: [Error 2] The system cannot find the file specified

-- 
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: Uploading and viewing images problem

2011-09-20 Thread Rodney Topor
Thank you.  That solves my problem.  I had mistakenly assumed that as
the introduction of django.contrib.staticfiles made
django.views.static.serve unnecessary for static files, it also had
the same consequence for media files.  Thanks again.
Rodney

On Sep 20, 6:34 pm, Praveen Krishna R 
wrote:
> *Have you done something like this in your project urls.py*
> *
> *
> *
> urlpatterns += patterns('',
> *
>     (r'^site_media/(?P.*)$',
> 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}),
> )
> So that you can enable serving the media from the development server ?!
> *my MEDIA_URL = '/site_media/'*
>
> And html from the templates
> * *
>
>
>
>
>
> On Tue, Sep 20, 2011 at 7:43 AM, Rodney Topor  wrote:
> > I've written a small project to upload and view images using a recent
> > development version of Django.  In settings.py, I've defined
> > MEDIA_ROOT = join(PATH, 'media') # the full path to the media
> > subdirectory of my project directory
> > MEDIA_URL = '/media/'
> > I've created subdirectories /media/images in my project directory.
> > I've defined my model with an ImageField(upload_to='images'), defined
> > a form with enctype="multipart/form-data/", etc.
> > When I create a new object with a selected image, the image is
> > correctly uploaded to /media/images/.  The HTML page intended to
> > display the image correctly (?) uses the following HTML element:
> >  > width="100" />
> > The development server displays a message of the form:
> > [20/Sep/2011 14:35:04] "GET /media/images/foo.jpg HTTP/1.1" 404 2218
> > I.e., the image is not found and the rendered page contains only a
> > query where the image should be displayed.
> > So the images are being uploaded correctly, the generated HTML
> > contains  elements that refer to the correct locations of the
> > images, but they are not being displayed.  The image and its
> > containing directories are all world-readable.
> > So can someone please explain what else I have to do to make this
> > work?  Many thanks.
> > Rodney
>
> > --
> > 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.
>
> --
> Thanks and Regards,
> *Praveen Krishna R*

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



Re: Custom model field/form: __init__() got multiple values for keyword argument 'baz'

2011-09-20 Thread Micky Hulse
On Tue, Sep 20, 2011 at 3:36 PM, Michal Petrucha  wrote:
> Well, the problem is that your defined fields.TestField.__init__ takes
> baz as either a keyword argument, or as the first positional arg. As
> with related fields, to pass the verbose name in this case you have to
> specify it as a keyword argument as well or specify your custom
> argument first and shift all other positional arguments. So, to fix
> your issue, choose either of the two following::

Ahhh, thank you for the clarification and for providing me with a
solution!!! I really appreciate it. :)

For some reason, I never thought to re-arrange the order of the
args/kwargs in the model TestField().

Optimally, I think I would prefer to keep the verbose name in the
first position (as an arg, not kwarg) in order to keep things
consistent.

If you look at fields.py:



Line #s 13 and 16, I do this:

def __init__(self, *args, **kwargs):
self._baz = kwargs.get('baz', None)

But when I do that, I get this error:

File "/.../test/fields.py", line 19, in __init__
TypeError: __init__() got an unexpected keyword argument 'baz'

Is there a way to pass around keyword arguments (from the model
TestField()) without having to be explicit?

Sorry if noob questions. I still consider myself a Python/Django noobie :)

A billion thanks for all of your help! I really appreciate it.

Have a nice day!

Cheers
Micky

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



Re: Custom model field/form: __init__() got multiple values for keyword argument 'baz'

2011-09-20 Thread Michal Petrucha
On Tue, Sep 20, 2011 at 10:38:15AM -0700, mhulse wrote:
> Hello,
> 
> The problematic code can be found here:
> 
> 
> 
> TypeError:
> 
> __init__() got multiple values for keyword argument 'baz'
> 
> I have spent the last couple days trying to figure out how to pass a kwarg 
> from model to fields/forms (and eventually to a widget).
> 
> TBTH, I have had a heck of a time finding a contemporary example of how to 
> do this that fits the needs of my project. The docs are definitely detailed, 
> and the Django source code is helpful, but I have yet to piece this puzzle 
> together. :(
> 
> Any tips would be greatly appreciated.
> 
> Django (1, 4, 0, 'alpha', 0)

Well, the problem is that your defined fields.TestField.__init__ takes
baz as either a keyword argument, or as the first positional arg. As
with related fields, to pass the verbose name in this case you have to
specify it as a keyword argument as well or specify your custom
argument first and shift all other positional arguments. So, to fix
your issue, choose either of the two following::

foo = TestField(baz='bar', verbose_name=u'Foo field',
max_length=100, help_text='Foo baz bar?')

foo = TestField('bar', u'Foo field', max_length=100,
help_text='Foo baz bar?')

Michal


signature.asc
Description: Digital signature


Re: Where does form.is_valid() clean the form?

2011-09-20 Thread James Pyrich
My guess, for whatever it's worth, is that the debugger is evaluating 
the errors property before the form is bound, causing self._errors to be 
populated with an empty ErrorDict.  If so, the state revealed by the 
debugger is not an accurate reflection of the code as it would normally 
execute.


On 09/20/2011 04:46 PM, Jacob G wrote:

I doubt I'm familiar enough with Django to fix bugs.

I am puzzled by what I am see though with the BaseForm class in Aptana
PyDev debugger. I noticed that full_clean() was not being called via a
call to is_valid. So I stepped through the debugger, and for some
strange reason, the BaseForm constructor, although the code says
"self._errors = None" the debugger watchlist shows self._errors as set
to an empty ErrorDict, and therefore the _get_errors() method never
called full_clean().

Does this make any sense? It doesn't sound right.

On Sep 20, 4:17 pm, Shawn Milochik  wrote:

On Tue, Sep 20, 2011 at 4:14 PM, Jacob G  wrote:

Thanks, I didn't realize errors is property that calls _get_errors().

Yeah, it's non-obvious. That's one of the nice things about
open-source, though. You can go through the code and understand how
your tools work so you can better apply them.

Side-note -- now that you're browsing Django's code, I think you could
easily participate by going to the Trac instance and closing a few
easy tickets. ;o)  https://code.djangoproject.com/

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.



Is it possible to run from Django script?

2011-09-20 Thread Stone
Dear users,

I have simple question which regards with running script from view.py.
Part of my view.py looks like:
def updateSystem(request):
print request.POST
id = 20
idgrp = 0
print "ID: %d and IDGRP: %d" % (id, idgrp)
if request.is_ajax():
message = "This is AJAX part"
if request.method == 'POST':
query = request.POST
print query.items()
try:
sysid=51
output = subprocess.Popen(['/home/user/djcode/testlab/
updateSys','-sysid','%d','-id','%d','-idgrp','%d' % (sysid,id,idgrp)],
shell = False, stdou=subprocess.PIPE)
test,err = output.communicate()
print output.returncode
print err
print test
except OSError:
return HttpResponse("Wrong command")
print "CORRECT REQUEST: %s" % query.get('data','sysid=0')
message = "Content-type text/html\n\n"
return HttpResponse(message)
else:
return HttpResponse(status=400)
else:
message = "This is not AJXA"
return HttpResponse(status=400)

Is it possible to do that over subprocess command?

>From the command line script updateSys written in Python as well
should return list of directory.

Thank you
best regards
Petr

-- 
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: Where does form.is_valid() clean the form?

2011-09-20 Thread Shawn Milochik
I think this can be easily explained by pointing out a misunderstanding.

Whether or not a form's values are valid has nothing to do with
whether the values are meaningful. That is, a login form with a
present but incorrect password is in fact valid.

I'm sure that full_clean is getting called, and the default value of
None is getting replaced by an empty ErrorDict once the clean
determines that no fields are invalid.

If you look at the code that's used by the django.contrib.auth to log
users in, there are more steps after simple form validation needed to
log a user in.
https://docs.djangoproject.com/en/1.3/topics/auth/#authentication-in-web-requests

After the form is validated, the values are then used with the
authenticate method to attempt to find a matching user in the
database. If one is found, an additional step is taken to update the
request with the user.

Understanding that, plus checking out the link above should clear up
your confusion. If you read and understand it but still think your
code has a different problem, please describe it in more detail.

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: Where does form.is_valid() clean the form?

2011-09-20 Thread Jacob G
I'm doing this because there's a problem in my code. I create a
AuthenticationForm, and post a non-existing username and password, and
call is_valid(). I expect to then that the errors property will return
at least one error, but there are actually no errors. So I step
through the debugger, and see that full_clean() is not getting called,
because _errors apparently is never None, even after setting it to
None in the BaseForm constructor.

I agree with you that I'm sure such a bug doesn't exist. But I can't
understand at all why it looks like this in the debugger. How can the
code set a variable to None, and it is set to an empty ErrorDict? It
seems like a practical joke or something.

On Sep 20, 4:55 pm, Shawn Milochik  wrote:
> On Tue, Sep 20, 2011 at 4:46 PM, Jacob G  wrote:
> > I doubt I'm familiar enough with Django to fix bugs.
>
> Wait until the talks from DjangoCon US 2011 are out, then watch my
> lightning talk. I guarantee you could submit at least three patches
> today alone.
>
> > I am puzzled by what I am see though with the BaseForm class in Aptana
> > PyDev debugger. I noticed that full_clean() was not being called via a
> > call to is_valid. So I stepped through the debugger, and for some
> > strange reason, the BaseForm constructor, although the code says
> > "self._errors = None" the debugger watchlist shows self._errors as set
> > to an empty ErrorDict, and therefore the _get_errors() method never
> > called full_clean().
>
> > Does this make any sense? It doesn't sound right.
>
> I haven't dug into this particular code, so I don't know why it works
> that way. In any case, what is it that you're actually trying to
> accomplish? I ask because I'm pretty sure Django form validation isn't
> buggy or we'd know by now. If you're just trying to understand Django
> then that's awesome, and I hope you figure it out or someone helps
> out. But if you're digging into it to try to solve a problem in your
> own code, what is it?
>
> 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: Where does form.is_valid() clean the form?

2011-09-20 Thread Shawn Milochik
On Tue, Sep 20, 2011 at 4:46 PM, Jacob G  wrote:
> I doubt I'm familiar enough with Django to fix bugs.
>
Wait until the talks from DjangoCon US 2011 are out, then watch my
lightning talk. I guarantee you could submit at least three patches
today alone.

> I am puzzled by what I am see though with the BaseForm class in Aptana
> PyDev debugger. I noticed that full_clean() was not being called via a
> call to is_valid. So I stepped through the debugger, and for some
> strange reason, the BaseForm constructor, although the code says
> "self._errors = None" the debugger watchlist shows self._errors as set
> to an empty ErrorDict, and therefore the _get_errors() method never
> called full_clean().
>
> Does this make any sense? It doesn't sound right.
>

I haven't dug into this particular code, so I don't know why it works
that way. In any case, what is it that you're actually trying to
accomplish? I ask because I'm pretty sure Django form validation isn't
buggy or we'd know by now. If you're just trying to understand Django
then that's awesome, and I hope you figure it out or someone helps
out. But if you're digging into it to try to solve a problem in your
own code, what is it?

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: Where does form.is_valid() clean the form?

2011-09-20 Thread Jacob G
I doubt I'm familiar enough with Django to fix bugs.

I am puzzled by what I am see though with the BaseForm class in Aptana
PyDev debugger. I noticed that full_clean() was not being called via a
call to is_valid. So I stepped through the debugger, and for some
strange reason, the BaseForm constructor, although the code says
"self._errors = None" the debugger watchlist shows self._errors as set
to an empty ErrorDict, and therefore the _get_errors() method never
called full_clean().

Does this make any sense? It doesn't sound right.

On Sep 20, 4:17 pm, Shawn Milochik  wrote:
> On Tue, Sep 20, 2011 at 4:14 PM, Jacob G  wrote:
> > Thanks, I didn't realize errors is property that calls _get_errors().
>
> Yeah, it's non-obvious. That's one of the nice things about
> open-source, though. You can go through the code and understand how
> your tools work so you can better apply them.
>
> Side-note -- now that you're browsing Django's code, I think you could
> easily participate by going to the Trac instance and closing a few
> easy tickets. ;o)  https://code.djangoproject.com/
>
> 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: Where does form.is_valid() clean the form?

2011-09-20 Thread Shawn Milochik
On Tue, Sep 20, 2011 at 4:14 PM, Jacob G  wrote:
> Thanks, I didn't realize errors is property that calls _get_errors().
>

Yeah, it's non-obvious. That's one of the nice things about
open-source, though. You can go through the code and understand how
your tools work so you can better apply them.

Side-note -- now that you're browsing Django's code, I think you could
easily participate by going to the Trac instance and closing a few
easy tickets. ;o)  https://code.djangoproject.com/

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: Where does form.is_valid() clean the form?

2011-09-20 Thread Jacob G
Thanks, I didn't realize errors is property that calls _get_errors().

On Sep 20, 4:11 pm, Shawn Milochik  wrote:
> Take your study/research one step further:
>
> https://code.djangoproject.com/browser/django/trunk/django/forms/form...
>
> When it checks for self.errors, the _get_errors() function calls the 
> full_clean.

-- 
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: Where does form.is_valid() clean the form?

2011-09-20 Thread Shawn Milochik
Take your study/research one step further:

https://code.djangoproject.com/browser/django/trunk/django/forms/forms.py

When it checks for self.errors, the _get_errors() function calls the full_clean.

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



Where does form.is_valid() clean the form?

2011-09-20 Thread Jacob G
The Django documentation says that a form is cleaned when calling 
is_valid():

https://docs.djangoproject.com/en/dev/ref/forms/validation/ (see first 
paragraph)


However, the is_valid soure code doesn't show that is does clean, as 
follows:

def is_valid(self):

"""

Returns True if the form has no errors. Otherwise, False. If errors are

being ignored, returns False.

"""

return self.is_bound and not bool(self.errors)


And empirically in my application, I don't see any cleaning taking place 
when I call is_valid.

Am I understanding something wrong? Is an application supposed to 
full_clean() directly followed by a call to is_valid()?

Thanks.

 

 

 

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



Virtualenv and Hudson/Jenkins

2011-09-20 Thread Tim Sawyer

Has anyone any instructions for using VirtualEnv with Hudson/Jenkins?

Thanks,

Tim.

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



Custom model field/form: __init__() got multiple values for keyword argument 'baz'

2011-09-20 Thread mhulse
Hello,

The problematic code can be found here:



TypeError:

__init__() got multiple values for keyword argument 'baz'

I have spent the last couple days trying to figure out how to pass a kwarg 
from model to fields/forms (and eventually to a widget).

TBTH, I have had a heck of a time finding a contemporary example of how to 
do this that fits the needs of my project. The docs are definitely detailed, 
and the Django source code is helpful, but I have yet to piece this puzzle 
together. :(

Any tips would be greatly appreciated.

Django (1, 4, 0, 'alpha', 0)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/K-MmaLu9m_kJ.
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: request.method not working as expected

2011-09-20 Thread dm03514
Fabio in your dev server output is it saying the type of request is
get?
ARe you accessing "/method/" through your form or are you just
directing your webserver to http://192.168.0.2:8000/method/???


On Sep 20, 11:46 am, Fabio Natali  wrote:
> Hi everybody!
>
> I have a very simple view which is supposed to print out GET or POST,
> depending which has been used to send data. The problem is I always get
> "GET" even when sending data via POST.
>
> ### views.py:
> def method(request):
>      return HttpResponse(request.method)
>
> ### urls.py:
> (r'^method/$', method)
>
> ### php script to send data to the Django page:
> http://192.168.0.2:8000/method/;>
>    
>    
> 
>
> I am running Django version 1.2.5, development server.
>
> Am I missing something? Any hint?
>
> Thanks, Fabio.
>
> --
> Fabio Natali FNstudio

-- 
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: request.method not working as expected

2011-09-20 Thread Babatunde Akinyanmi
Correct me if I'm wrong but it seems your "method" function is
supposed to return the request method type(POST or GET) sent to the
view. If I'm correct then your syntax will always return GET. That's
because I think all the django middleware workings adjust the initial
arguments and the response such that it always ends up as a GET.
Try storing request.method in a variable first and then return that
variable with your HttpResponse like

def method(request):
method_type = request.method
Return HttpResponse(method_type)

Haven't tried it but I'm sure this will give the desired result

On 9/20/11, Fabio Natali  wrote:
> Hi everybody!
>
> I have a very simple view which is supposed to print out GET or POST,
> depending which has been used to send data. The problem is I always get
> "GET" even when sending data via POST.
>
> ### views.py:
> def method(request):
>  return HttpResponse(request.method)
>
> ### urls.py:
> (r'^method/$', method)
>
> ### php script to send data to the Django page:
> http://192.168.0.2:8000/method/;>
>
>
> 
>
> I am running Django version 1.2.5, development server.
>
> Am I missing something? Any hint?
>
> Thanks, Fabio.
>
> --
> Fabio Natali FNstudio
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

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



Selecting field value for different tables in Admin Site

2011-09-20 Thread MiSTiX
Hi,

I have a field named "deger". I want to bind deger value from 3 or 4
source tables via foreignkey, find mechanism or what ever ??.
(ajax, jquery, customform ... etc)

After the user choice "object_id" (source tables id) and releated
field "field_id" (source table field name), user can select value from
these.

Which way/mechanism can I use?

Please help? I new on django but not python.


Best regards
Mustafa YILDIRIM


class kapi_rules(models.Model):
kapi_rule_id = models.AutoField("Kural ID", primary_key=True,
editable=False)
created_user = models.ForeignKey(User, db_column='created_user',
related_name='created_user', blank=True, null=True, editable=False,
verbose_name='Kuralı Oluşturan')
changed_user = models.ForeignKey(User, db_column='changed_user',
related_name='changed_user', blank=True, null=True, editable=False,
verbose_name='Kuralı Değiştiren')
rule_adi = models.CharField("Kural Tanımı", max_length=255,
null=False)
birim_id = models.ForeignKey(birimler, db_column='birim_id',
verbose_name='Birim ID')
kapi_id = ChainedForeignKey(kapilar, chained_field='birim_id',
chained_model_field = 'birim_id', db_column = 'kapi_id',
show_all=False, auto_choose=True, verbose_name='Kapı ID')
object_id = models.ForeignKey(kapi_object_list, db_column =
'object_id',verbose_name='Tablo');
field_id = ChainedForeignKey(kapi_object_field_list,
chained_field='object_id', chained_model_field = 'object_id',
db_column = 'field_id', show_all=False, auto_choose=True,
verbose_name='Alan')
deger = models.CharField("Alan Değeri", max_length=255,
null=False)

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



Testcases are not working with PREPEND_WWW

2011-09-20 Thread Felix Stiehler
Hello there, I am trying to use the Django way of testing, but it
somehow does not work together with the PREPEND_WWW setting. All I get
is the 301 status code and no redirect is followed even when follow=True.

from django.test.client import Client
c = Client()
r = c.get('/users/login/', follow=True)
r.status_code

301
r.content

''
r.redirect_chain

[]

Any help how to make the tests work without touching some webserver
config stuff would be appreciated.

Felix





-- 
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: request.method not working as expected

2011-09-20 Thread Fabio Natali

On 09/20/2011 05:53 PM, DrBloodmoney wrote:

On Tue, Sep 20, 2011 at 11:46 AM, Fabio Natali  wrote:

Hi everybody!

I have a very simple view which is supposed to print out GET or POST,
depending which has been used to send data. The problem is I always get
"GET" even when sending data via POST.

### views.py:
def method(request):
return HttpResponse(request.method)

### urls.py:
(r'^method/$', method)

### php script to send data to the Django page:
http://192.168.0.2:8000/method/;>
  
  


I am running Django version 1.2.5, development server.

Am I missing something? Any hint?

Thanks, Fabio.

--
Fabio Natali FNstudio


I'm not 100% sure, but since you aren't including the
csrfmiddlewaretoken in the post data, I would expect it to 403 if you
aren't exempting the view from CSRF protection [1].

[1] https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/


Hi DrBloodmoney, thanks for your kind reply.

I've modified my view as follows:

### views.py:
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def method(request):
 return HttpResponse(request.method)

However everything behaves the same way, I still have "GET" erroneously 
detected.


Do you have any other hint on how to investigate?

Thanks, Fabio.

--
Fabio Natali FNstudio

--
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: Virtualenv and Django in Production

2011-09-20 Thread Markus Gattol
 - it's just symlinks i.e. not more overhead
 - you won't clutter your system Python or vice versa when you up/downgrade 
something
 - easy to 
detect http://www.markus-gattol.name/ws/python.html#detect_a_virtualenv
 - if you want a production setup use e.g. gunicorn/nginx or even better 
uwsgi/mongrel2
 - as all the others here, I can strongly recommend using a virtualenv for 
production as well as for development

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/QZpISAJq0cEJ.
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: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Jonas Geiregat



> So you want to edit the User object through the ModelForm of the other model, 
> or you just want to display it?
> 

I want to edit the User object through the ModelForm.

-- 
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: Virtualenv and Django in Production

2011-09-20 Thread Tom Evans
On Tue, Sep 20, 2011 at 4:35 PM, dm03514  wrote:
> Virtualenv provides you with more control over your production
> environments.   We run apache/virtualenv on 10 of our production
> servers.
> There very well might be more overhead running through a virtualenv.
> For us it is too negligible to make a difference.
>
> We use fabric to deploy our django apps, and automatically initiate
> virtualenvs, or update virtualenvs on remote servers.  I think virtual
> env is great on production because it keeps all of our environments on
> the same page.  ie.  If we update a python package to a newer version,
> or roll it back to an older version.  All we have to do is make the
> appropriate changes in our code, change the package version entry in
> our bootstrap.py file and deploy through fabric, no manually managing
> packages on our production servers, nice and simple
>

There is no more overhead in virtualenv than there is in python
itself. To understand why, you should look at how and why virtualenv
works - you are using a different python interpreter, so that python
interpreter looks in a different place than the stock interpreter.

virtualenv is entirely free magic that makes your deployments more
consistent and repeatable. Use it!

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: request.method not working as expected

2011-09-20 Thread DrBloodmoney
On Tue, Sep 20, 2011 at 11:46 AM, Fabio Natali  wrote:
> Hi everybody!
>
> I have a very simple view which is supposed to print out GET or POST,
> depending which has been used to send data. The problem is I always get
> "GET" even when sending data via POST.
>
> ### views.py:
> def method(request):
>    return HttpResponse(request.method)
>
> ### urls.py:
> (r'^method/$', method)
>
> ### php script to send data to the Django page:
> http://192.168.0.2:8000/method/;>
>  
>  
> 
>
> I am running Django version 1.2.5, development server.
>
> Am I missing something? Any hint?
>
> Thanks, Fabio.
>
> --
> Fabio Natali FNstudio

I'm not 100% sure, but since you aren't including the
csrfmiddlewaretoken in the post data, I would expect it to 403 if you
aren't exempting the view from CSRF protection [1].

[1] https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/

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



request.method not working as expected

2011-09-20 Thread Fabio Natali

Hi everybody!

I have a very simple view which is supposed to print out GET or POST, 
depending which has been used to send data. The problem is I always get 
"GET" even when sending data via POST.


### views.py:
def method(request):
return HttpResponse(request.method)

### urls.py:
(r'^method/$', method)

### php script to send data to the Django page:
http://192.168.0.2:8000/method/;>
  
  


I am running Django version 1.2.5, development server.

Am I missing something? Any hint?

Thanks, Fabio.

--
Fabio Natali FNstudio

--
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: Virtualenv and Django in Production

2011-09-20 Thread dm03514
Virtualenv provides you with more control over your production
environments.   We run apache/virtualenv on 10 of our production
servers.
There very well might be more overhead running through a virtualenv.
For us it is too negligible to make a difference.

We use fabric to deploy our django apps, and automatically initiate
virtualenvs, or update virtualenvs on remote servers.  I think virtual
env is great on production because it keeps all of our environments on
the same page.  ie.  If we update a python package to a newer version,
or roll it back to an older version.  All we have to do is make the
appropriate changes in our code, change the package version entry in
our bootstrap.py file and deploy through fabric, no manually managing
packages on our production servers, nice and simple

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



DjangoCon US 2011 Videos

2011-09-20 Thread Marc Aymerich
Hi,
Anyone know if the talks from past djangocon US will be availabe for online
watching? any posible date?

Thanks
-- 
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: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Ilian Iliev
So you want to edit the User object through the ModelForm of the other
model, or you just want to display it?


-- 
eng. Ilian Iliev
Web Software Developer

Mobile: +359 88 66 08 400
Website: http://ilian.i-n-i.org


On Tue, Sep 20, 2011 at 4:37 PM, Jonas Geiregat  wrote:

>
> > Hi,
> >
> > ModelForm should automatically create a dropdown list for your foreign
> key.
> > If there is nor such drop-down created probably you are doing something
> wrong.
> >
>
> I don't want the dropdown list I want the values of the foreinkey to be
> expaneded into fields
>
> For example I have user as ForeignKey to the contrib.auth.models.User
> model. This model has username as field.
>
> I want to display the username field of the user foreinkey.
>
> --
> 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: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Jonas Geiregat

> Hi,
> 
> ModelForm should automatically create a dropdown list for your foreign key.
> If there is nor such drop-down created probably you are doing something wrong.
> 

I don't want the dropdown list I want the values of the foreinkey to be 
expaneded into fields

For example I have user as ForeignKey to the contrib.auth.models.User model. 
This model has username as field.

I want to display the username field of the user foreinkey.

-- 
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: Virtualenv and Django in Production

2011-09-20 Thread DrBloodmoney
On Tue, Sep 20, 2011 at 1:55 AM, adrian s  wrote:
> Hi all, I've been using virtualenv as recommended in my development
> environments.
> I am now migrating a project which was not using virtualenv, to another
> server and now
> have the opportunity to use it in production.
> I've spent a while googling this subject and I'm not sure what the best
> practice is.
> Is it common to run a production django deployment with apache behind
> virtualenv? If so,
> could anyone steer me in the proper direction for getting this setup with
> the wsgi file...
> Or, is virtualenv best for just testing isolated environments, and running
> production
> with the existing global space (I feel naive typing this out, so I must be
> wrong (: )
>  as is (isn't there more overhead with virtualenv anyhow?)
> I hope I made sense.
> If anyone has any relevant docs that clarify this (maybe my searches stink)
> I'd love to read
> over what there is so I may make an appropriate call.
> Adrian

I run a VPS with several django apps isolated into different
virtualenvs. They are served by either uwsgi or gunicorn and reverse
proxied by nginx. There are several good guides if you google for some
of those keywords.

It is a pretty easy set-up. If you were only serving one django app,
it may be slight overkill, but it may be worth the effort to get it
set up this way so you can easily add more django applications and
have them be completely isolated from each other.

-- 
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: Create socket server in django

2011-09-20 Thread Preston Holmes


On Sep 20, 12:07 am, Micke  wrote:
> Thank you for your quick reply!
>
> My socket server is ready, but I dont know where to import it in
> django so it starts when django starts?

You are going to run your socket server in a different python process
than Django.  Django is based on more of a CGI request-response cycle
and doesn't mesh well with a socket server.

However you can access the DB and Django models from inside your
socket server.  Think about it as importing parts of Django in your
socket server, then serving views of that data from the Django process

-P

>
> br
> Mikael
>
> On Sep 19, 11:38 pm, Andy McKay 
> wrote:
>
>
>
> > You could write a Python process that starts up a Socket Server and imports
> > all the Django stuff, just like the current server does for HTTP. Then
> > there's no need to "send the data to django". Might help:
>
> >http://docs.python.org/library/socketserver.html
>
> > On Mon, Sep 19, 2011 at 2:00 PM, Micke  wrote:
> > > Hi,
> > > Im new to Django and need some help in the right direction.
>
> > > I will create a socket server, that should recive raw udp data and put
> > > it in a database. After that Django should present the data in a
> > > customized view.
>
> > > Is it possible to create the server in Django, like in the views file,
> > > so it starts up when django starts? So I can use the in data and use
> > > orm to put it in db. Or do I need to do a separate server, that sends
> > > data to django after it recieves it?
>
> > > Thanks
> > > Mikael
>
> > > --
> > > 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.



Virtualenv and Django in Production

2011-09-20 Thread Matt Schinckel
I use virtualenv in production. It means you can install python packages using 
pip without having root or sudo access on the server.

You can also isolate installs, and use no-site-packages.

I can't think of a reason not to use it.

Matt.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/BNM2owzrojoJ.
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: Virtualenv and Django in Production

2011-09-20 Thread Preston Holmes
How you use a virtualenv in production depends on all the parts of
your production stack.  If you are using mod_wsgi, search mod_wsgi +
virtualenv, gunicorn, etc

You might also consider one of the new "platform-as-a-service" hosting
options that basically solve this for you.

-P

On Sep 19, 10:55 pm, adrian s  wrote:
> Hi all, I've been using virtualenv as recommended in my development
> environments.
>
> I am now migrating a project which was not using virtualenv, to another
> server and now
> have the opportunity to use it in production.
>
> I've spent a while googling this subject and I'm not sure what the best
> practice is.
> Is it common to run a production django deployment with apache behind
> virtualenv? If so,
> could anyone steer me in the proper direction for getting this setup with
> the wsgi file...
>
> Or, is virtualenv best for just testing isolated environments, and running
> production
> with the existing global space (I feel naive typing this out, so I must be
> wrong (: )
>  as is (isn't there more overhead with virtualenv anyhow?)
>
> I hope I made sense.
>
> If anyone has any relevant docs that clarify this (maybe my searches stink)
> I'd love to read
> over what there is so I may make an appropriate call.
>
> Adrian

-- 
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: Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Ilian Iliev
Hi,

ModelForm should automatically create a dropdown list for your foreign key.
If there is nor such drop-down created probably you are doing something
wrong.

-- 
eng. Ilian Iliev
Web Software Developer

Mobile: +359 88 66 08 400
Website: http://ilian.i-n-i.org


On Tue, Sep 20, 2011 at 1:26 PM, Jonas Geiregat  wrote:

> Hello,
>
> I have a UserProfile model:
>
> class UserProfile(FacebookProfileModel):
>user = models.ForeignKey(User, unique=True)
>lastfm_user = models.CharField(max_length=20, blank=True)
>
> This should be turned into a real HTML form , I which to use the ModelForm
> class for this.
>
> class UserProfileForm(ModelForm):
>class Meta:
>model = UserProfile
># I can select lastfm_user or any other properties I have
> defined in the UserProfile model
># But what if I wanted to only show the user__username field
> in the form ?
>
># This doesn't work
>fields = ('user__username',)
>
> I've searched the docs , read the page about creating froms from models but
> didn't found any clues.
> Is this even possible at all ?
>
> Now I'm implementing the form by hand , which is a lot of work , being able
> to use the ModelForm would speed up this process.
>
> Regards,
>
>
> Jonas Geiregat
> jo...@geiregat.org
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Virtualenv and Django in Production

2011-09-20 Thread adrian s
Hi all, I've been using virtualenv as recommended in my development
environments.

I am now migrating a project which was not using virtualenv, to another
server and now
have the opportunity to use it in production.

I've spent a while googling this subject and I'm not sure what the best
practice is.
Is it common to run a production django deployment with apache behind
virtualenv? If so,
could anyone steer me in the proper direction for getting this setup with
the wsgi file...

Or, is virtualenv best for just testing isolated environments, and running
production
with the existing global space (I feel naive typing this out, so I must be
wrong (: )
 as is (isn't there more overhead with virtualenv anyhow?)

I hope I made sense.

If anyone has any relevant docs that clarify this (maybe my searches stink)
I'd love to read
over what there is so I may make an appropriate call.

Adrian

-- 
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: Passing multiple arguments to custom template filter

2011-09-20 Thread skazhy
Thanks for your answer, somehow I overlooked the pluralize syntax. ;)

On 20 sept., 12:53, Tom Evans  wrote:
> On Tue, Sep 20, 2011 at 10:31 AM, skazhy  wrote:
> > Hi all!
>
> > I was trying to pass multiple arguments to a custom template filter
> > (in the same way as, eg {{ myvar|pluralize:"y","ies" }} but it didn't
>
> That's not how pluralize works, from the manual:
>
>    You have {{ num_cherries }} cherr{{ num_cherries|pluralize:"y,ies" }}.
>
> You can see that unlike how you typed it, it is only passing one
> argument, which is composed of two parts. The filter itself takes care
> of splitting that single argument.
>
> Filters all take one value and at most one argument, as explained in the docs.
>
> 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: Create socket server in django

2011-09-20 Thread Thorsten Sanders

import sys,os

sys.path.append('/path/to/your/django_project')
os.environ['DJANGO_SETTINGS_MODULE'] = 'your_settings_file'

This works fine for a cronjob I created

On 20.09.2011 10:48, Thomas Orozco wrote:


You just have to run your server as a daemon and use Django's 
setup_environment so you can use the ORM to interact with your Django DB.


I can try and find the lines you need to do that if you can't find them.

Le 20 sept. 2011 09:08, "Micke" > a écrit :

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



Does ModelForm follow ForeignKey relations ?

2011-09-20 Thread Jonas Geiregat
Hello,

I have a UserProfile model:

class UserProfile(FacebookProfileModel):
user = models.ForeignKey(User, unique=True) 

 
lastfm_user = models.CharField(max_length=20, blank=True)

This should be turned into a real HTML form , I which to use the ModelForm 
class for this.

class UserProfileForm(ModelForm):
class Meta:
model = UserProfile
# I can select lastfm_user or any other properties I have 
defined in the UserProfile model 
# But what if I wanted to only show the user__username field in 
the form ?

# This doesn't work
fields = ('user__username',)

I've searched the docs , read the page about creating froms from models but 
didn't found any clues. 
Is this even possible at all ?

Now I'm implementing the form by hand , which is a lot of work , being able to 
use the ModelForm would speed up this process.

Regards,


Jonas Geiregat
jo...@geiregat.org





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



Re: Passing multiple arguments to custom template filter

2011-09-20 Thread Tom Evans
On Tue, Sep 20, 2011 at 10:31 AM, skazhy  wrote:
> Hi all!
>
> I was trying to pass multiple arguments to a custom template filter
> (in the same way as, eg {{ myvar|pluralize:"y","ies" }} but it didn't

That's not how pluralize works, from the manual:

   You have {{ num_cherries }} cherr{{ num_cherries|pluralize:"y,ies" }}.

You can see that unlike how you typed it, it is only passing one
argument, which is composed of two parts. The filter itself takes care
of splitting that single argument.

Filters all take one value and at most one argument, as explained in the docs.

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.



Passing multiple arguments to custom template filter

2011-09-20 Thread skazhy
Hi all!

I was trying to pass multiple arguments to a custom template filter
(in the same way as, eg {{ myvar|pluralize:"y","ies" }} but it didn't
work. I saw some old tickets and posts in here on this subject & there
was no ready sollution to this. Is it possible now (in 1.3)?

Maybe someone could clarify the situation, so I (or someone else)
could add this information to Django docs.

Thanks in advance!

-Karlis Lauva /skazhy/

-- 
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: Create socket server in django

2011-09-20 Thread Thomas Orozco
You just have to run your server as a daemon and use Django's
setup_environment so you can use the ORM to interact with your Django DB.

I can try and find the lines you need to do that if you can't find them.
Le 20 sept. 2011 09:08, "Micke"  a écrit :

-- 
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: Uploading and viewing images problem

2011-09-20 Thread Praveen Krishna R
*Have you done something like this in your project urls.py*
*
*
*
urlpatterns += patterns('',
*
(r'^site_media/(?P.*)$',
'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}),
)
So that you can enable serving the media from the development server ?!
*my MEDIA_URL = '/site_media/'*

And html from the templates
* *


On Tue, Sep 20, 2011 at 7:43 AM, Rodney Topor  wrote:

> I've written a small project to upload and view images using a recent
> development version of Django.  In settings.py, I've defined
> MEDIA_ROOT = join(PATH, 'media') # the full path to the media
> subdirectory of my project directory
> MEDIA_URL = '/media/'
> I've created subdirectories /media/images in my project directory.
> I've defined my model with an ImageField(upload_to='images'), defined
> a form with enctype="multipart/form-data/", etc.
> When I create a new object with a selected image, the image is
> correctly uploaded to /media/images/.  The HTML page intended to
> display the image correctly (?) uses the following HTML element:
>  width="100" />
> The development server displays a message of the form:
> [20/Sep/2011 14:35:04] "GET /media/images/foo.jpg HTTP/1.1" 404 2218
> I.e., the image is not found and the rendered page contains only a
> query where the image should be displayed.
> So the images are being uploaded correctly, the generated HTML
> contains  elements that refer to the correct locations of the
> images, but they are not being displayed.  The image and its
> containing directories are all world-readable.
> So can someone please explain what else I have to do to make this
> work?  Many thanks.
> Rodney
>
> --
> 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.
>
>


-- 
Thanks and Regards,
*Praveen Krishna R*

-- 
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 TinyMCE don't displays Html tags to vistors

2011-09-20 Thread Aljoša Mohorović
On Tue, Sep 20, 2011 at 8:18 AM, Tsung-Hsien  wrote:
> I've been done my admin interface with TinyMCE. However,  aftering
> editing, I see words with HTML tags update to my website.
>
> What's a good way to solve this?

you need to add "{{ tinymce_content|safe }}", docs:
https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#safe

Aljosa

-- 
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: Create socket server in django

2011-09-20 Thread Micke
Thank you for your quick reply!

My socket server is ready, but I dont know where to import it in
django so it starts when django starts?

br
Mikael

On Sep 19, 11:38 pm, Andy McKay 
wrote:
> You could write a Python process that starts up a Socket Server and imports
> all the Django stuff, just like the current server does for HTTP. Then
> there's no need to "send the data to django". Might help:
>
> http://docs.python.org/library/socketserver.html
>
>
>
>
>
>
>
> On Mon, Sep 19, 2011 at 2:00 PM, Micke  wrote:
> > Hi,
> > Im new to Django and need some help in the right direction.
>
> > I will create a socket server, that should recive raw udp data and put
> > it in a database. After that Django should present the data in a
> > customized view.
>
> > Is it possible to create the server in Django, like in the views file,
> > so it starts up when django starts? So I can use the in data and use
> > orm to put it in db. Or do I need to do a separate server, that sends
> > data to django after it recieves it?
>
> > Thanks
> > Mikael
>
> > --
> > 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.



How TinyMCE don't displays Html tags to vistors

2011-09-20 Thread Tsung-Hsien
I've been done my admin interface with TinyMCE. However,  aftering
editing, I see words with HTML tags update to my website.

What's a good way to solve this?

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