Re: new project directory not defined when starting :

2012-02-21 Thread Jisson Varghese
Hi,
the 
linkmay
help 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.



Re: new project directory not defined when starting :

2012-02-21 Thread Babatunde Akinyanmi
Hi niceseb,
Please be more specific about what you mean by nothing happens. That
way you'll be able to quickly get useful assistance.

On 2/21/12, niceseb  wrote:
> Hi Python experts,
>
> I want to start a new project with :
>
> C:\Users\Django_Projects>django-admin.py startproject mysite
>
> but nothing happens
>
> I have already checked that I have Python and Django installed and
>
> defined Env Path: C:\Python27\Lib\site-packages\django\bin, where the
> django_admin.py is defined
>
> Though I am not sure C:\Python27\Scripts also has this django-admin.py
> file defined too?
>
> But if so it is not in the Path right? Should I remove one of them?
>
> --
> 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.



Re: import error

2012-02-21 Thread dummyman dummyman
Hi i fixed the error . I didnt add the parent directory of project to
sys.path.append in the standalone script thanks


On Wed, Feb 22, 2012 at 10:35 AM, kalyani ram wrote:

> every time you import something, plz done forget to include that in
> installed_apps. this mostly solves the import errors and
> templatedoesnotexist errors problem
>
> On Feb 21, 2:28 pm, dummyman efiles and directories securely between
> remote hosts without starting an FTP session or logging into the remote
> systems explicitly. The scp command uses SSH to transfer data, so it
> requires a password or passphrase for authentication. Unlike rcp or FTP,
> scp encrypts both the file and any passwords exchanged so that anyone
> snooping on the network can't view them.
>
> Warning: Be careful when copying between hosts frdummyman <
> tempo...@gmail.com> wrote:
> > Hi ,
> >
> > I have a django project and a standalone python script . From the view
> > function, i have invoked the standalone script. I am getting the error ."
> > No module named 
> >
> > this is my code for standalone script
> >
> > import os
> >
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
> >
> > from django.conf import settings
> >
> > after that i ve imported the app inside this
> > .
> >
> > from mysite.app.models import some
> > but still i am getting the error no module  named mysite
> > Please help in finding the reason for the error
>
> --
> 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: Associating Form Data with Users

2012-02-21 Thread Kelly Nicholes
And by "API" do you mean "ORM?"

On Feb 21, 10:45 pm, Kelly Nicholes  wrote:
> errr--
>
> django.contrib.auth.models import User
>
> class YourModel(models.Model):
>     user = models.ForeignKey(User)
>
> On Feb 21, 10:42 pm, Kelly Nicholes  wrote:
>
>
>
>
>
>
>
> > Your YourModelForm is a modelform of a model.  If you're setting a
> > property of that model, AND YOU WANT IT TO PERSIST IN THE DATABASE,
> > you set the property equal to the request.user and save that object.
> > If you don't have a foreignkeyfield to User, there's no way you're
> > going to associate that model with a user and have it persist.
> > Setting it in memory is going to be useless (unless you use it in the
> > view/template immediately after you associate the user with the
> > model).
>
> > class YourModel(inherit from whatever the model is that you should
> > inherit from):
> >     field = models.Charfield(...blahblahblah)
> >     user = models.ForeignKeywhatever()
>
> > Then do what Thorsten said.
>
> > On Feb 21, 2:28 pm, ds39  wrote:
>
> > > I just have one final question. The method suggested by Thorsten
> > > appears to work. But, is the attached user object an accessible filter
> > > parameter in the API now ? For instance, I don't see it listed as a
> > > part of the actual model in the API. How would I go about accessing
> > > it ?
>
> > > On Feb 20, 5:25 pm, Thorsten Sanders  wrote:
>
> > > > You could do for example:
>
> > > > exclude the user field from the form and in your view something like 
> > > > this:
>
> > > > form = YourModelForm(request.POST)  #fill the modelform with the data
> > > >          if form.is_valid(): # check if valid
> > > >              mynewobject = form.save(commit=False) #save it to create
> > > > the object but dont send to database
> > > >              mynewobject.user = request.user # attach the user to it
> > > >              mynewobject.save() # now do the real save and send it to
> > > > the database
>
> > > > Am 20.02.2012 22:59, schrieb ds39:
>
> > > > > I hate to keep bringing this issue up, but I'm still not entirely sure
> > > > > how to implement this. I've tried a number of different ways to
> > > > > connect some kind of user ID with form data without much success. Is
> > > > > the idea that after authenticating the user in the view, request.user
> > > > > be set to some variable that allows the user ID to be added to the
> > > > > model or ModelForm ? Would this make the user object associated with
> > > > > the form or model object accessible by filtering in the API ?
>
> > > > > Thanks again
>
> > > > > On Feb 19, 9:48 pm, Shawn Milochik  wrote:
> > > > >> On 02/19/2012 09:29 PM, ds39 wrote:
>
> > > > >>> Thanks for your response. But, would you mind expanding on it a 
> > > > >>> little
> > > > >>> bit ?
> > > > >> How about you give it a try and see what you can figure out? In your
> > > > >> view, request.user will return the currently logged-in user (or an
> > > > >> AnonymousUser if they're not logged in). Since you said your view
> > > > >> requires login, you'll have a User object all ready to go.
>
> > > > >> 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: Associating Form Data with Users

2012-02-21 Thread Kelly Nicholes
errr--

django.contrib.auth.models import User

class YourModel(models.Model):
user = models.ForeignKey(User)

On Feb 21, 10:42 pm, Kelly Nicholes  wrote:
> Your YourModelForm is a modelform of a model.  If you're setting a
> property of that model, AND YOU WANT IT TO PERSIST IN THE DATABASE,
> you set the property equal to the request.user and save that object.
> If you don't have a foreignkeyfield to User, there's no way you're
> going to associate that model with a user and have it persist.
> Setting it in memory is going to be useless (unless you use it in the
> view/template immediately after you associate the user with the
> model).
>
> class YourModel(inherit from whatever the model is that you should
> inherit from):
>     field = models.Charfield(...blahblahblah)
>     user = models.ForeignKeywhatever()
>
> Then do what Thorsten said.
>
> On Feb 21, 2:28 pm, ds39  wrote:
>
>
>
>
>
>
>
> > I just have one final question. The method suggested by Thorsten
> > appears to work. But, is the attached user object an accessible filter
> > parameter in the API now ? For instance, I don't see it listed as a
> > part of the actual model in the API. How would I go about accessing
> > it ?
>
> > On Feb 20, 5:25 pm, Thorsten Sanders  wrote:
>
> > > You could do for example:
>
> > > exclude the user field from the form and in your view something like this:
>
> > > form = YourModelForm(request.POST)  #fill the modelform with the data
> > >          if form.is_valid(): # check if valid
> > >              mynewobject = form.save(commit=False) #save it to create
> > > the object but dont send to database
> > >              mynewobject.user = request.user # attach the user to it
> > >              mynewobject.save() # now do the real save and send it to
> > > the database
>
> > > Am 20.02.2012 22:59, schrieb ds39:
>
> > > > I hate to keep bringing this issue up, but I'm still not entirely sure
> > > > how to implement this. I've tried a number of different ways to
> > > > connect some kind of user ID with form data without much success. Is
> > > > the idea that after authenticating the user in the view, request.user
> > > > be set to some variable that allows the user ID to be added to the
> > > > model or ModelForm ? Would this make the user object associated with
> > > > the form or model object accessible by filtering in the API ?
>
> > > > Thanks again
>
> > > > On Feb 19, 9:48 pm, Shawn Milochik  wrote:
> > > >> On 02/19/2012 09:29 PM, ds39 wrote:
>
> > > >>> Thanks for your response. But, would you mind expanding on it a little
> > > >>> bit ?
> > > >> How about you give it a try and see what you can figure out? In your
> > > >> view, request.user will return the currently logged-in user (or an
> > > >> AnonymousUser if they're not logged in). Since you said your view
> > > >> requires login, you'll have a User object all ready to go.
>
> > > >> 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: Associating Form Data with Users

2012-02-21 Thread Kelly Nicholes
Your YourModelForm is a modelform of a model.  If you're setting a
property of that model, AND YOU WANT IT TO PERSIST IN THE DATABASE,
you set the property equal to the request.user and save that object.
If you don't have a foreignkeyfield to User, there's no way you're
going to associate that model with a user and have it persist.
Setting it in memory is going to be useless (unless you use it in the
view/template immediately after you associate the user with the
model).

class YourModel(inherit from whatever the model is that you should
inherit from):
field = models.Charfield(...blahblahblah)
user = models.ForeignKeywhatever()

Then do what Thorsten said.

On Feb 21, 2:28 pm, ds39  wrote:
> I just have one final question. The method suggested by Thorsten
> appears to work. But, is the attached user object an accessible filter
> parameter in the API now ? For instance, I don't see it listed as a
> part of the actual model in the API. How would I go about accessing
> it ?
>
> On Feb 20, 5:25 pm, Thorsten Sanders  wrote:
>
>
>
>
>
>
>
> > You could do for example:
>
> > exclude the user field from the form and in your view something like this:
>
> > form = YourModelForm(request.POST)  #fill the modelform with the data
> >          if form.is_valid(): # check if valid
> >              mynewobject = form.save(commit=False) #save it to create
> > the object but dont send to database
> >              mynewobject.user = request.user # attach the user to it
> >              mynewobject.save() # now do the real save and send it to
> > the database
>
> > Am 20.02.2012 22:59, schrieb ds39:
>
> > > I hate to keep bringing this issue up, but I'm still not entirely sure
> > > how to implement this. I've tried a number of different ways to
> > > connect some kind of user ID with form data without much success. Is
> > > the idea that after authenticating the user in the view, request.user
> > > be set to some variable that allows the user ID to be added to the
> > > model or ModelForm ? Would this make the user object associated with
> > > the form or model object accessible by filtering in the API ?
>
> > > Thanks again
>
> > > On Feb 19, 9:48 pm, Shawn Milochik  wrote:
> > >> On 02/19/2012 09:29 PM, ds39 wrote:
>
> > >>> Thanks for your response. But, would you mind expanding on it a little
> > >>> bit ?
> > >> How about you give it a try and see what you can figure out? In your
> > >> view, request.user will return the currently logged-in user (or an
> > >> AnonymousUser if they're not logged in). Since you said your view
> > >> requires login, you'll have a User object all ready to go.
>
> > >> 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.



Validation For all form fields in Django templates

2012-02-21 Thread shaini sasidhar
How can I do the automatic client side form validation in django?

-- 
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 classes uses different databases

2012-02-21 Thread kalyani ram
I kinda understand your doubt. are you aware of the class meta: ?? I
am not aware of any such meta attributes, but thuis class is used to
querying the db
like you know, grouping and ordering etc. If this is doubt, well and
good
Thanks.


Regards,
Kalyani

On Feb 22, 2:01 am, airween  wrote:
> Hello there,
>
> I have to create two (or more) classes, and rows of classes are stored
> in different databases.
>
> I've read about 
> multi-db:https://docs.djangoproject.com/en/dev/topics/db/multi-db/
> - that's clear for me. (Or may be I'm confused...)
>
> Is it the only way to handle the databases and classes relations? I
> mean, there would be a meta attribute (example), which describe that
> class which database have to use... Any idea?
>
> Thanks:
>
> a.

-- 
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: import error

2012-02-21 Thread kalyani ram
every time you import something, plz done forget to include that in
installed_apps. this mostly solves the import errors and
templatedoesnotexist errors problem

On Feb 21, 2:28 pm, dummyman dummyman  wrote:
> Hi ,
>
> I have a django project and a standalone python script . From the view
> function, i have invoked the standalone script. I am getting the error ."
> No module named 
>
> this is my code for standalone script
>
> import os
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
>
> from django.conf import settings
>
> after that i ve imported the app inside this
> .
>
> from mysite.app.models import some
> but still i am getting the error no module  named mysite
> Please help in finding the reason for the error

-- 
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: Calling "manage.py shell" from the Python Shell in Tutorial Part 1

2012-02-21 Thread kalyani ram
Hey I am a begginer too and i went tru the same tutorial and trust me
i had so many errors and i just struggled tru..
now indentation errors are quite common. what u need to do is, go to u
models.py, admin.py, views.py or any other .py file for which ever the
code is written, and plz try using python editor to write instead of
other text editors. they help u indent the code pretty well. and then
give python manage.py shell after syncdb n validate.
I am sure u ll get tru. indent your functions properly.
all the best.


Regards,
kalyani Ram

On Feb 22, 4:41 am, Django_for_SB  wrote:
> Django Gurus,
>
> I'm an absolute beginner using Python in Django. I'm currently going
> through the tutorial, part 1, on the djangoproject.com main 
> website:https://docs.djangoproject.com/en/1.3/intro/tutorial01/. I keep trying
> to complete part 1 of the tutorial, step by step, meaning, I'll go
> through the tutorial part 1, progress up to a certain point, then
> close my shell command and shut-down my computer. Then, when I get
> back to opening up the project in which I initially began working on,
> namely, "mysite" (as the tutorial instructs us to name), my shell
> commands aren't valid anymore.
>
> Example:
>
> manage.py shell                                     -> This
> initially works if I start the project from scratch
>
> manage.py shell                                     -> This won't
> work if I leave my project, then go back to continue to
>
> work on it later
>
> This is the error I keep getting:
>
> Traceback(most recent call last):
>
> IndentationError: unexpected Indent
>
> I'm not quite sure what's going on. Any assistance would be more than
> appreciated. What am I missing here? Thank you.
>
> Best,
>
> SB

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



a simple doubt

2012-02-21 Thread kalyani ram
I am working with django for past 1 week, and i ve done a lot of study
on few resources.
Now i am thinking of doing a simple email application using Django-
python.
So wer shud i start? What and shud i ve? Cz i am skeptical about one
thing. can i just use two active email ids and as test?
Plz help and thanks in advance.


Regards,
Kalyani Ram

-- 
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: Production server on windows

2012-02-21 Thread Eugeny Klementev
I'm deploying my application to Windows Azure cloud.
I prefer python web servers.

Yes apache is good solution, and i'll use it if will not find any
other alternatives.

On Feb 21, 8:04 pm, Bill Freeman  wrote:
> Sorry, but I have to ask the obligatory question: why Windows?
>
> But apart from that, I suggest that even on Windows you should use
> Apache and mod_wsgi.  It'f fast, effective, free (as in beer and as in
> speech), widely used (meaning it's easier to get help for this
> configuration on the web).
>
> Bill
>
> On 2/21/12, Eugeny Klementev  wrote:
>
>
>
>
>
>
>
> > I implement application on django framework.
> > Now i select web server for production deployment of my application.
> > Platform is Windows Azure.
>
> > For development i used embedded 'python manage.py runserver'.
> > django documentation does not recommend use it as production solution.
>
> > I try to use rocket web server, but i have strange problems with 'POST'
> > queries.
>
> > I have found the twisted+django solution:
> > Lacking Credibility - Twisted + Django: It won't burn down your
> > house.
>
> > Which web server is more preferable for production solution on windows
> > platform?
>
> > --
> > 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: [re-open] viewing generated SQL without running the query

2012-02-21 Thread Russell Keith-Magee

On 22/02/2012, at 10:32 AM, diafygi wrote:

> There's a previous thread about this[1], but it was closed back in
> 2006 without resolution. So I'd like to check back in and see if there
> is a way to get a complete query string without executing the query.
> 
> At first, I thought I could just use the QuerySet.query.__str__(), but
> that does not put quotes around dates, so MySQL returns a warning when
> trying to execute it. I filed a bug report[2], but apparently
> QuerySet.query.__str__() isn't supposed to return a valid query
> string.
> 
> So is there a way to get the compiled query string without executing
> the query (including when debug=False)?
> 


Technically, yes; practically, no.

The problem is that the SQL argument quoting isn't something that is under 
Django's control. The PyDB interface specifies (with good reason) that you pass 
SQL to the database using parameterized SQL, with a separate tuple of 
arguments. The PyDB backend then handles the process of escaping, quoting, or 
whatever else is required to combine the SQL and arguments to make sure that 
the final SQL is valid.

Unfortunately, what the PyDB interface *doesn't* provide is a way to extract 
the actual SQL that was (or will be) executed.

So - in order for Django to provide a 100% guaranteed correct output for 
Queryset.query.__str()__, we would need to re-implement the quoting and 
escaping feature of the PyDB backend -- and we'd need to do so for every 
backend (because quoting and escaping requirements are slightly different for 
every backend). This would be complex to implement, would be error prone, and 
would lead to even more confusing errors whenever the quoting/escaping failed 
to implement exactly what the PyDB backend implements.

The alternative -- which is what Django has opted to do -- is to provide SQL 
output that is indicative of what was (or would be) executed, and accept that 
sometimes that SQL won't run verbatim. Incorrect quoting is more than 
sufficient for eyeballing whether a query is correct; if you actually need to 
execute the SQL it's not *that* hard to manually correct the quoting.

Yes, it's annoying. Yes, in an ideal world, SQL output would be guaranteed 
valid. However, in this case, pragmatism takes precedence.

Yours,
Russ Magee %-)


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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-open] viewing generated SQL without running the query

2012-02-21 Thread diafygi
There's a previous thread about this[1], but it was closed back in
2006 without resolution. So I'd like to check back in and see if there
is a way to get a complete query string without executing the query.

At first, I thought I could just use the QuerySet.query.__str__(), but
that does not put quotes around dates, so MySQL returns a warning when
trying to execute it. I filed a bug report[2], but apparently
QuerySet.query.__str__() isn't supposed to return a valid query
string.

So is there a way to get the compiled query string without executing
the query (including when debug=False)?

Thanks!
Daniel

[1] - 
http://groups.google.com/group/django-users/browse_thread/thread/37a6222006d0633b/
[2] - https://code.djangoproject.com/ticket/17741

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



Re: django 1.1: nonexistent URLs display 500.html instead of 404.html

2012-02-21 Thread rabousha
Yes, only for TEMPLATE_CONTEXT_PROCESSORS, the commas aren't added by
default after the strings. I suspect it's an old bug.

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth'
'django.core.context_processors.debug'
'django.core.context_processors.i18n'
'django.core.context_processors.media'
)

With the commas missing, all requests to nonexistent URLs returned a
500 error.


On Feb 22, 12:31 am, Ian Clelland  wrote:
> By 'missing commas', do you mean that there are *syntax errors* in your
> settings.py file?
>
> That will definitely cause a 500 error, and I would be surprised if it
> didn't do it on *every* request.
> It seems odd that you would get a 404 when Debug is turned on, but that may
> be related to the handling of the 500 error template, or possibly indicates
> another error in your application settings.
>
> Ian
>
> On Tue, Feb 21, 2012 at 10:36 AM, rabousha wrote:
>
>
>
>
>
>
>
>
>
> > I am using django 1.1, with DEBUG = False, and
> > TEMPLATE_CONTEXT_PROCESSORS is missing commas, all nonexistent URLs
> > display 500.html instead of 404.html. If I set DEBUG to True, it
> > displays the default 404 page. if I add the commas to
> > TEMPLATE_CONTEXT_PROCESSORS, then it displays the 404 page. The commas
> > are not added by default. All pages do exist, so I am not missing
> > anything.
>
> > Is this a known bug?
>
> > --
> > 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,
> Ian Clelland
> 

-- 
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: Calling "manage.py shell" from the Python Shell in Tutorial Part 1

2012-02-21 Thread Furbee
Python is indentation-specific. It determines the semantics of your code by
it's levels of indentation. For instance:

# print False
if False:
print "false"
print "done"

if False:
print "false"
else:
print "true"

Note that inside the if block, all lines which are indented belong to that
if block. The block ends when the indentation ends. The error
"IndentationError:
unexpected Indent" tells you that Python got an indentation it was not
expecting. This could be as simple as a single space that shouldn't be
there. Check your models.py and settings.py files for any lines that are
indented which are not supposed to be.

Furbee

On Tue, Feb 21, 2012 at 3:41 PM, Django_for_SB wrote:

> Django Gurus,
>
> I'm an absolute beginner using Python in Django. I'm currently going
> through the tutorial, part 1, on the djangoproject.com main website:
> https://docs.djangoproject.com/en/1.3/intro/tutorial01/. I keep trying
> to complete part 1 of the tutorial, step by step, meaning, I'll go
> through the tutorial part 1, progress up to a certain point, then
> close my shell command and shut-down my computer. Then, when I get
> back to opening up the project in which I initially began working on,
> namely, "mysite" (as the tutorial instructs us to name), my shell
> commands aren't valid anymore.
>
> Example:
>
> manage.py shell -> This
> initially works if I start the project from scratch
>
> manage.py shell -> This won't
> work if I leave my project, then go back to continue to
>
> work on it later
>
> This is the error I keep getting:
>
> Traceback(most recent call last):
>
> IndentationError: unexpected Indent
>
>
>
> I'm not quite sure what's going on. Any assistance would be more than
> appreciated. What am I missing here? Thank you.
>
> Best,
>
> SB
>
> --
> 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.



Calling "manage.py shell" from the Python Shell in Tutorial Part 1

2012-02-21 Thread Django_for_SB
Django Gurus,

I'm an absolute beginner using Python in Django. I'm currently going
through the tutorial, part 1, on the djangoproject.com main website:
https://docs.djangoproject.com/en/1.3/intro/tutorial01/. I keep trying
to complete part 1 of the tutorial, step by step, meaning, I'll go
through the tutorial part 1, progress up to a certain point, then
close my shell command and shut-down my computer. Then, when I get
back to opening up the project in which I initially began working on,
namely, "mysite" (as the tutorial instructs us to name), my shell
commands aren't valid anymore.

Example:

manage.py shell -> This
initially works if I start the project from scratch

manage.py shell -> This won't
work if I leave my project, then go back to continue to
 
work on it later

This is the error I keep getting:

Traceback(most recent call last):

IndentationError: unexpected Indent



I'm not quite sure what's going on. Any assistance would be more than
appreciated. What am I missing here? Thank you.

Best,

SB

-- 
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: Need help on a (maybe complex) query with aggregate/annotate

2012-02-21 Thread Michael Elkins

On Tue, Feb 21, 2012 at 01:10:28PM -0800, Enrico wrote:

But your query counts all the books, even the bad ones. I only need to
count the good ones...

For example, if my books are:

1. name: LOTR, rating: 10, publisher: A ...
2. name: ASOIAF, rating: 10, publisher: A ...
3. name: Twilight, rating 1, publisher: B ...

and my publishers are:
A and B

Your query returns:
[A, num_book=2]
[B, num_book=1]

the query on my first message returns:
[A, num_book=2]

and what I need is:
[A, num_book=2]
[B, num_book=0]

where num_books means number of good books.


Sorry, I missed that detail in your question.  You need to use the 
.extra() queryset method to do what you are attempting.  The 
following will add a 'num_good_books' attribute to each Publisher 
object:


qs = Publisher.objects.extra(select={'num_good_books': 'select count(*) from 
publisher_book where publisher_book.publisher_id = publisher_publisher.id and 
publisher_book.rating > 3.0'})
for o in qs:
  print o.name, o.num_good_books

Note that the "publisher_" prefix in the SQL is the name of the 
Django application in which your models reside.  So if your Django 
application is named "myapp", then you'd need to change the 
"publisher_" prefix to "myapp_".


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



Re: django 1.1: nonexistent URLs display 500.html instead of 404.html

2012-02-21 Thread Ian Clelland
By 'missing commas', do you mean that there are *syntax errors* in your
settings.py file?

That will definitely cause a 500 error, and I would be surprised if it
didn't do it on *every* request.
It seems odd that you would get a 404 when Debug is turned on, but that may
be related to the handling of the 500 error template, or possibly indicates
another error in your application settings.

Ian

On Tue, Feb 21, 2012 at 10:36 AM, rabousha wrote:

> I am using django 1.1, with DEBUG = False, and
> TEMPLATE_CONTEXT_PROCESSORS is missing commas, all nonexistent URLs
> display 500.html instead of 404.html. If I set DEBUG to True, it
> displays the default 404 page. if I add the commas to
> TEMPLATE_CONTEXT_PROCESSORS, then it displays the 404 page. The commas
> are not added by default. All pages do exist, so I am not missing
> anything.
>
> Is this a known bug?
>
> --
> 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,
Ian Clelland


-- 
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: Associating Form Data with Users

2012-02-21 Thread ds39
I just have one final question. The method suggested by Thorsten
appears to work. But, is the attached user object an accessible filter
parameter in the API now ? For instance, I don't see it listed as a
part of the actual model in the API. How would I go about accessing
it ?

On Feb 20, 5:25 pm, Thorsten Sanders  wrote:
> You could do for example:
>
> exclude the user field from the form and in your view something like this:
>
> form = YourModelForm(request.POST)  #fill the modelform with the data
>          if form.is_valid(): # check if valid
>              mynewobject = form.save(commit=False) #save it to create
> the object but dont send to database
>              mynewobject.user = request.user # attach the user to it
>              mynewobject.save() # now do the real save and send it to
> the database
>
> Am 20.02.2012 22:59, schrieb ds39:
>
>
>
>
>
>
>
> > I hate to keep bringing this issue up, but I'm still not entirely sure
> > how to implement this. I've tried a number of different ways to
> > connect some kind of user ID with form data without much success. Is
> > the idea that after authenticating the user in the view, request.user
> > be set to some variable that allows the user ID to be added to the
> > model or ModelForm ? Would this make the user object associated with
> > the form or model object accessible by filtering in the API ?
>
> > Thanks again
>
> > On Feb 19, 9:48 pm, Shawn Milochik  wrote:
> >> On 02/19/2012 09:29 PM, ds39 wrote:
>
> >>> Thanks for your response. But, would you mind expanding on it a little
> >>> bit ?
> >> How about you give it a try and see what you can figure out? In your
> >> view, request.user will return the currently logged-in user (or an
> >> AnonymousUser if they're not logged in). Since you said your view
> >> requires login, you'll have a User object all ready to go.
>
> >> 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: Need help on a (maybe complex) query with aggregate/annotate

2012-02-21 Thread Enrico
Thanks Micheal for the response!

But your query counts all the books, even the bad ones. I only need to
count the good ones...

For example, if my books are:

1. name: LOTR, rating: 10, publisher: A ...
2. name: ASOIAF, rating: 10, publisher: A ...
3. name: Twilight, rating 1, publisher: B ...

and my publishers are:
A and B

Your query returns:
[A, num_book=2]
[B, num_book=1]

the query on my first message returns:
[A, num_book=2]

and what I need is:
[A, num_book=2]
[B, num_book=0]

where num_books means number of good books.

I'm trying to do this with a single query because i need to iterate
over the queryset in one template with something like:
{% for p in publishers %}
{{ p.name }} - {{ p.number_good_books }}
{% endfor %}
Right now I'm using a custom method in the Publisher model
( get_number_of_good_books() ).
It works but it's really slow (one query for each publisher to count
the number of good books).

Ciao

On Feb 21, 7:50 pm, Michael  Elkins  wrote:
> On Feb 21, 6:11 am, Enrico  wrote:
>
> > This query:
> > Publisher.objects.filter(book__rating__gt=3.0).annotate(num_books=Count('bo 
> > ok'))
> > returns all the publishers with at least one good book (ranked > 3)
> > with annotated the number of good books for each publisher.
>
> > How can i modify the query to get the list of ALL publishers with
> > annotated the number of good books for each publisher?
> > In other words I want to keep in the results also the Publishers
> > without good books (num_books = 0).
>
> Hi Enrico,
>
> The Django documentation has an example of what you are trying to do:
>
> https://docs.djangoproject.com/en/1.3/topics/db/aggregation/#generati...
>
> The answer to your specific question is to do it this way:
>
> qs = Publisher.objects.annotate(num_books=Count('book'))
> for o in qs:
>   print o.num_books

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



Different classes uses different databases

2012-02-21 Thread airween
Hello there,

I have to create two (or more) classes, and rows of classes are stored
in different databases.

I've read about multi-db: 
https://docs.djangoproject.com/en/dev/topics/db/multi-db/
- that's clear for me. (Or may be I'm confused...)

Is it the only way to handle the databases and classes relations? I
mean, there would be a meta attribute (example), which describe that
class which database have to use... Any idea?


Thanks:


a.

-- 
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: Need help on a (maybe complex) query with aggregate/annotate

2012-02-21 Thread Michael Elkins

On Feb 21, 6:11 am, Enrico  wrote:
> This query:
> Publisher.objects.filter(book__rating__gt=3.0).annotate(num_books=Count('bo 
> ok'))
> returns all the publishers with at least one good book (ranked > 3)
> with annotated the number of good books for each publisher.
>
> How can i modify the query to get the list of ALL publishers with
> annotated the number of good books for each publisher?
> In other words I want to keep in the results also the Publishers
> without good books (num_books = 0).

Hi Enrico,

The Django documentation has an example of what you are trying to do:

https://docs.djangoproject.com/en/1.3/topics/db/aggregation/#generating-aggregates-for-each-item-in-a-queryset

The answer to your specific question is to do it this way:

qs = Publisher.objects.annotate(num_books=Count('book'))
for o in qs:
  print o.num_books

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



django 1.1: nonexistent URLs display 500.html instead of 404.html

2012-02-21 Thread rabousha
I am using django 1.1, with DEBUG = False, and
TEMPLATE_CONTEXT_PROCESSORS is missing commas, all nonexistent URLs
display 500.html instead of 404.html. If I set DEBUG to True, it
displays the default 404 page. if I add the commas to
TEMPLATE_CONTEXT_PROCESSORS, then it displays the 404 page. The commas
are not added by default. All pages do exist, so I am not missing
anything.

Is this a known bug?

-- 
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: I am getting TypeError: coercing to Unicode: need string or buffer, long found. Please help.

2012-02-21 Thread Tom Evans
On Tue, Feb 21, 2012 at 5:18 PM, Daniel Marquez
 wrote:
> Wow, I should've caught that. Thanks guys. However, since I needed a
> string, what I did was add "default=x" to the integer field as
> follows:
>
> class Phone(models.Model):
>        phonenumber = models.IntegerField(default=10)
>        pub_date = models.DateTimeField('date published')
>        def __unicode__(self):
>                return self.phonenumber
>
> and it worked.
>

That is still not returning unicode from the unicode method. When you
return a non unicode object, you should do something like this:

def __unicode__(self):
  return unicode(self.phonenumber)

Also, as Shawn said, you should use a CharField for your phone number
field. If you are collecting phone numbers for a specific country,
there are localized form fields for certain countries to ensure users
enter the data in the correct format - nothing worse than 'sdffdhj'
being allowed as a phone number!

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: I am getting TypeError: coercing to Unicode: need string or buffer, long found. Please help.

2012-02-21 Thread Shawn Milochik
On Tue, Feb 21, 2012 at 12:18 PM, Daniel Marquez <
daniel.marquez0...@gmail.com> wrote:

> Wow, I should've caught that. Thanks guys. However, since I needed a
> string, what I did was add "default=x" to the integer field as
> follows:
>
> class Phone(models.Model):
>phonenumber = models.IntegerField(default=10)
>pub_date = models.DateTimeField('date published')
>def __unicode__(self):
>return self.phonenumber
>
> and it worked.
>
>
As mentioned earlier, your phone number field should not be an integer.
Among other reasons, using a string allows you to validate for different
countries, have extensions, and more easily manipulate and display the
value everywhere you use it (you're never going to use it *as* an integer,
after all).

Also, setting an integer field to have a default value other than zero
smells really bad.

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: I am getting TypeError: coercing to Unicode: need string or buffer, long found. Please help.

2012-02-21 Thread Daniel Marquez
Wow, I should've caught that. Thanks guys. However, since I needed a
string, what I did was add "default=x" to the integer field as
follows:

class Phone(models.Model):
phonenumber = models.IntegerField(default=10)
pub_date = models.DateTimeField('date published')
def __unicode__(self):
return self.phonenumber

and it worked.

On Feb 20, 2:39 pm, Babatunde Akinyanmi  wrote:
> @Daniel
> Your __unicode__ should always return a string  so like Shawn said,
> when you check your phone model, its __unicode__ method should be
> returning str() or unicode() not int
>
> On 2/20/12, Shawn Milochik  wrote:
>
> > Read theerrormessage in your subject line. Then look at the
> > __unicode__ method of your Phone model. It appears that this is the
> > problem, and not the Device model.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-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.



new project directory not defined when starting :

2012-02-21 Thread niceseb
Hi Python experts,

I want to start a new project with :

C:\Users\Django_Projects>django-admin.py startproject mysite

but nothing happens

I have already checked that I have Python and Django installed and

defined Env Path: C:\Python27\Lib\site-packages\django\bin, where the
django_admin.py is defined

Though I am not sure C:\Python27\Scripts also has this django-admin.py
file defined too?

But if so it is not in the Path right? Should I remove one of them?

-- 
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: About managing dependencies in a collaborative development team and good practices.

2012-02-21 Thread Tom Evans
On Tue, Feb 21, 2012 at 3:54 PM, Shawn Milochik  wrote:
> On 02/21/2012 10:53 AM, Javier Guerra Giraldez wrote:
>>
>>
>> i do exactly that.  just a tip: to create and maintain the pip
>> requirements file do:
>>
>> pip freeze>  piprequirementsfile.txt
>>
>
>
> +1
>
> And it's checked into version control.
>
> Shawn
>

How else would one do Software Change Management? :)

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: Installing Django from GIT/Subversion - package dependency in virtual environment

2012-02-21 Thread shacker
Even easier, just 

pip install django

or in requirements.txt, simply:

Django

To upgrade later:

pip install --upgrade django

./s

-- 
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/-/UsTxK-PKGCAJ.
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: Production server on windows

2012-02-21 Thread Bill Freeman
Sorry, but I have to ask the obligatory question: why Windows?

But apart from that, I suggest that even on Windows you should use
Apache and mod_wsgi.  It'f fast, effective, free (as in beer and as in
speech), widely used (meaning it's easier to get help for this
configuration on the web).

Bill

On 2/21/12, Eugeny Klementev  wrote:
> I implement application on django framework.
> Now i select web server for production deployment of my application.
> Platform is Windows Azure.
>
> For development i used embedded 'python manage.py runserver'.
> django documentation does not recommend use it as production solution.
>
> I try to use rocket web server, but i have strange problems with 'POST'
> queries.
>
> I have found the twisted+django solution:
> Lacking Credibility - Twisted + Django: It won't burn down your
> house.
>
> Which web server is more preferable for production solution on windows
> platform?
>
> --
> 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: About managing dependencies in a collaborative development team and good practices.

2012-02-21 Thread Shawn Milochik

On 02/21/2012 10:53 AM, Javier Guerra Giraldez wrote:


i do exactly that.  just a tip: to create and maintain the pip
requirements file do:

pip freeze>  piprequirementsfile.txt




+1

And it's checked into version control.

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: About managing dependencies in a collaborative development team and good practices.

2012-02-21 Thread Javier Guerra Giraldez
On Tue, Feb 21, 2012 at 8:24 AM, Sébastien Billion
 wrote:
> Set a virtualenv is good thing. You can write a shell script which set the
> virtualenv and install all the external module with pip -r. Use pip -r
> nameofrequriementsfile.txt. In this file, put the list of module with
> version.

i do exactly that.  just a tip: to create and maintain the pip
requirements file do:

pip freeze > piprequirementsfile.txt

-- 
Javier

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



Re: email - inline image

2012-02-21 Thread ionic drive
Tom,

you are totally right!
The problem was me - not google ;-) I knew that. Did not know what I am
looking for.
I am sorry! & thank you very much Tom!

Cheers
ionic



On Tue, 2012-02-21 at 14:23 +, Tom Evans wrote:

> On Tue, Feb 21, 2012 at 2:18 PM, ionic drive  wrote:
> > Thx Tom,
> >
> > as you guess I have already googled quite a lot. > 5hours.
> > My search was kind of "django inline image email" and subcultures.
> > And I actually found some techniques ... but I guess your approach is
> > best.
> >
> 
> FYI, the link I referenced is fourth in the list when you search for
> "django inline image email".
> 
> 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.

<>

Need help on a (maybe complex) query with aggregate/annotate

2012-02-21 Thread Enrico
I'm having a bit of hard time with aggregation.

For simplicity's sake consider the models available in the aggregation
docs:
https://docs.djangoproject.com/en/1.3/topics/db/aggregation/#

This query:
Publisher.objects.filter(book__rating__gt=3.0).annotate(num_books=Count('book'))
returns all the publishers with at least one good book (ranked > 3)
with annotated the number of good books for each publisher.

How can i modify the query to get the list of ALL publishers with
annotated the number of good books for each publisher?
In other words I want to keep in the results also the Publishers
without good books (num_books = 0).

Ciao
Enrico

PS: Sorry for my horrible english

-- 
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: email - inline image

2012-02-21 Thread Tom Evans
On Tue, Feb 21, 2012 at 2:18 PM, ionic drive  wrote:
> Thx Tom,
>
> as you guess I have already googled quite a lot. > 5hours.
> My search was kind of "django inline image email" and subcultures.
> And I actually found some techniques ... but I guess your approach is
> best.
>

FYI, the link I referenced is fourth in the list when you search for
"django inline image email".

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: dropdown select box in django

2012-02-21 Thread larry.mart...@gmail.com
On Feb 21, 6:11 am, Mario Gudelj  wrote:
> not sure what you mean there,

I have a class that inherits from Model, and I want my field to be in
that class.

> but take a look at 
> thishttps://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield

That looks to be for foreign key references. In my case the choices
will be hard coded, as shown in my example code in my original post.

>
> On 21 February 2012 23:36, larry.mart...@gmail.com
> wrote:
>
>
>
>
>
>
>
> > On Feb 20, 9:52 pm, Mario Gudelj  wrote:
> > > Hey there,
>
> > > Try this:
>
> > > In your forms.py create a field such as this
>
> > > message = forms.ChoiceField(label='Event Type',
> > choices=EVENT_TYPE_CHOICES)
>
> > > That will create a dropdown.
>
> > My app does not have a forms.py file. I know I can just create one,
> > but then how would that field be scoped? I want it to be part of the
> > EventsTable class.
>
> > > Also, I think that the first thing in the tuple is a value and shouldn't
> > > have a space, so change:
>
> > > EVENT_TYPE_CHOICES = (('Event Created', 'EventCreated'),('Event Changed',
> > > 'EventChanged'),)
>
> > > to:
>
> > > EVENT_TYPE_CHOICES = (('event_created', 'Event
> > Created'),('event_changed',
> > > 'Event Changed'),)
>
> > > See if that works for you.
>
> > Changing that did not have any effect.
>
> > > Cheers,
>
> > > -m
>
> > >  message = models.CharField("Event Type", max_length=12,
>
> > > > > choices=EVENT_TYPE_CHOICES)
>
> > > On 21 February 2012 12:28, larry.mart...@gmail.com
> > > wrote:
>
> > > > On Feb 20, 5:54 pm, Anurag Chourasia 
> > > > wrote:
> > > > > This is weird
>
> > > > > I simply copy pasted your code in my environment and it shows me a
> > Drop
> > > > > Down.
>
> > > > > Could you save the models file again and close your browser (or even
> > try
> > > > > clearing cache) and restart your apache/django dev server whatever
> > may be
> > > > > the case and try again?
>
> > > > Tried all that, still no joy. Also tried 2 different browsers, no
> > > > difference. In the dev server also tried setting a breakpoint and then
> > > > printing out message.choices, and it has the choices I expected:
>
> > > > (Pdb) print message.choices
> > > > (('Event Created', 'EventCreated'), ('Event Changed', 'EventChanged'))
>
> > > > > Regards,
> > > > > Anurag
>
> > > > > On Mon, Feb 20, 2012 at 9:32 PM, larry.mart...@gmail.com <
>
> > > > > larry.mart...@gmail.com> wrote:
> > > > > > I'm fairly new to django, still getting my feet wet. I want to
> > have a
> > > > > > dropdown menu (django seems to call this a select box). I read
> > this:
>
> >https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.mo.
> > > > ..
>
> > > > > > So I did this:
>
> > > > > > class EventsTable(models.Model):
> > > > > >    EVENT_TYPE_CHOICES = (
> > > > > >        ('Event Created', 'EventCreated'),
> > > > > >        ('Event Changed', 'EventChanged'),
> > > > > >    )
>
> > > > > >    message = models.CharField("Event Type", max_length=12,
> > > > > > choices=EVENT_TYPE_CHOICES)
>
> > > > > > But I get a standard text entry field where I can type in anything.
>
> > > > > > I did more googling, and I read a lot of confusing stuff about
> > having
> > > > > > to use javascrpt, ajax, CSS, etc. I read some pages about using a
> > > > > > ChoiceField, but that is not part of the model class (it's in the
> > > > > > forms class). I'm not sure how that would be used with a class that
> > > > > > inherits form models.
>
> > > > > > What am I missing here? I can't imagine something as common as this
> > > > > > would be hard in django. Shouldn't the first thing I did work?
>
> > > > > > TIA!
> > > > > > -larry
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "Django users" group.
> > > > > > To post to this group, send email to django-users@googlegroups.com
> > .
> > > > > > To unsubscribe from this group, send email to
> > > > > > django-users+unsubscr...@googlegroups.com.
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/django-users?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> 

Re: email - inline image

2012-02-21 Thread ionic drive
Thx Tom,

as you guess I have already googled quite a lot. > 5hours.
My search was kind of "django inline image email" and subcultures.
And I actually found some techniques ... but I guess your approach is
best. 

I did not know that the magic chain I am looking for is "django mime
multipart email".

So for all future searchers: 
If you are interested in "django email inline image" or "django email
embedded image" please search for "django mime multipart email".
http://stackoverflow.com/questions/1633109/creating-a-mime-email-template-with-images-to-send-with-python-django

Thank you very much Tom!

Kind regards,
ionic


On Tue, 2012-02-21 at 13:49 +, Tom Evans wrote:
> On Tue, Feb 21, 2012 at 12:42 PM, ionic drive  wrote:
> > Hello djangos,
> >
> > I want to add a *.jpg image to an html-formated/email signature.
> >
> > I am not sure if this approach is correct, please help:
> >
> > image_file = open(settings.PROJECT_ROOT+'/static/images/image_name.jpg',
> > 'rb') #get the image file
> > msg_image =
> > MIMEImage(image_file.read())
> > #with proper MIME type
> > image_file.close()
> > msg.attach(msg_image)
> > #attach the image to the mail message.
> >
> > so far so good:
> > the image gets sent with the email message and is attached as
> > "attachment.dat".
> >
> > How can I reference this image now to see it appear inline in the mail
> > message!?
> >
> > 
> >
> > Please improve my code...
> > why is the image recognized as "attachment.dat" and not with proper
> > image_name???
> >
> > Is this the right approach to send a signature with inline image?
> >
> > Thanks for your help guys
> > ionic
> >
> >
> 
> You should really try to STFW before asking questions like this. You
> aren't the first person to want to do this.
> 
> http://stackoverflow.com/questions/1633109/creating-a-mime-email-template-with-images-to-send-with-python-django
> 
> This was the fifth link on a search for "django mime multipart email".
> 
> 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: About managing dependencies in a collaborative development team and good practices.

2012-02-21 Thread Tom Evans
On Tue, Feb 21, 2012 at 1:24 PM, Sébastien Billion
 wrote:
> Hi,
>
> Set a virtualenv is good thing. You can write a shell script which set the
> virtualenv and install all the external module with pip -r. Use pip -r
> nameofrequriementsfile.txt. In this file, put the list of module with
> version.
> Exemple:
> django==1.3
> PIL==1.1.7
>
> If you want distribute your own apps, submit them on Pypi
> http://wiki.python.org/moin/CheeseShopTutorial
>

A more realistic proposal for proprietary packages is to bundle them
up yourselves. Putting business critical/private code into a public
RCS/distribution hub is not always a good plan.

Any python library with an standard setuptools install.py can be made
into a source package by 'python setup.py sdist'. If you place all the
required packages in a internal web accessible location, you can then
use pip to discover and install packages from there directly, as
though it were PyPi.

Check out the pip flags --index-url, --extra-index-url and
--find-links, which can be inserted into the pip requirements file.

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: email - inline image

2012-02-21 Thread Tom Evans
On Tue, Feb 21, 2012 at 12:42 PM, ionic drive  wrote:
> Hello djangos,
>
> I want to add a *.jpg image to an html-formated/email signature.
>
> I am not sure if this approach is correct, please help:
>
> image_file = open(settings.PROJECT_ROOT+'/static/images/image_name.jpg',
> 'rb') #get the image file
> msg_image =
> MIMEImage(image_file.read())
> #with proper MIME type
> image_file.close()
> msg.attach(msg_image)
> #attach the image to the mail message.
>
> so far so good:
> the image gets sent with the email message and is attached as
> "attachment.dat".
>
> How can I reference this image now to see it appear inline in the mail
> message!?
>
> 
>
> Please improve my code...
> why is the image recognized as "attachment.dat" and not with proper
> image_name???
>
> Is this the right approach to send a signature with inline image?
>
> Thanks for your help guys
> ionic
>
>

You should really try to STFW before asking questions like this. You
aren't the first person to want to do this.

http://stackoverflow.com/questions/1633109/creating-a-mime-email-template-with-images-to-send-with-python-django

This was the fifth link on a search for "django mime multipart email".

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: django with ajax without using jquery

2012-02-21 Thread Sébastien Billion
Hi,

I understand you want to learn Ajax.. So google is your friend:
http://www.xul.fr/en-xml-ajax.html


2012/2/21 dummyman dummyman 

> Which is the best place to start with using django and ajax without using
> jquery ?
>
> I meant calling the view function from javascript without using jquery
> features
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: django with ajax without using jquery

2012-02-21 Thread Masklinn
On 2012-02-21, at 12:00 , dummyman dummyman wrote:
> Which is the best place to start with using django and ajax without using
> jquery ?
> 
> I meant calling the view function from javascript without using jquery
> features

The closest XMLHttpRequest tutorial? The Mozilla Developer Network is
usually a pretty good resource.

And this has little (to nothing) to do with Django, that's pure
javascripty stuff.

-- 
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: import error

2012-02-21 Thread Sébastien Billion
Hi,

You must add 'mysite'' in your INSTALLED_APP list in settings.py

2012/2/21 dummyman dummyman 

> Hi ,
>
> I have a django project and a standalone python script . From the view
> function, i have invoked the standalone script. I am getting the error ."
> No module named 
>
>
>
> this is my code for standalone script
>
> import os
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
>
> from django.conf import settings
>
> after that i ve imported the app inside this
> .
>
> from mysite.app.models import some
> but still i am getting the error no module  named mysite
> Please help in finding the reason for the error
>
> --
> 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: About managing dependencies in a collaborative development team and good practices.

2012-02-21 Thread Sébastien Billion
Hi,

Set a virtualenv is good thing. You can write a shell script which set the
virtualenv and install all the external module with pip -r. Use pip -r
nameofrequriementsfile.txt. In this file, put the list of module with
version.
Exemple:
django==1.3
PIL==1.1.7

If you want distribute your own apps, submit them on Pypi
http://wiki.python.org/moin/CheeseShopTutorial

2012/2/21 Santiago Basulto 

> Hello people,
>
> some time ago with a couple of friends started a project with Django.
> We are really getting into it now, and have made several progress in
> the last 3 months. But, as the code starts to grow up, everything
> start to get complicated.
>
> Right now we have our project hosted on Bitbucket, and is simple to
> set the enviroment to develop. Just clone the repo, syncdb, run a
> script that install some fixtures, and runserver.
>
> But, we started to use some externa apps, and add extra code, and it
> started to look like a mess. Furthermore, we are 3 guys coding, it
> starts to get complicated to all have the dependencies right.
>
> After taking a look how pinax handle it, it seems a good option to
> make use of PIP for the external apps, and create virtual envs.
>
> First question then: Is that good? To use PIP with the external apps?
> Will it be easy to deploy it?
>
> Second question: What about our own apps? Should i let them live in
> the project root directory? Should i try to pack them as "egg"
> packages?
>
> Finally: Do you have any good practice to tell me? Experience is
> really needed!!
>
> Thank you all!
>
> PD: I have no much experience with Python, i'm a Java guy, and don't
> think you like Maven ;)
>
> --
> 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.



Production server on windows

2012-02-21 Thread Eugeny Klementev
I implement application on django framework.
Now i select web server for production deployment of my application.
Platform is Windows Azure.

For development i used embedded 'python manage.py runserver'.
django documentation does not recommend use it as production solution.

I try to use rocket web server, but i have strange problems with 'POST'
queries.

I have found the twisted+django solution:
Lacking Credibility - Twisted + Django: It won't burn down your
house.

Which web server is more preferable for production solution on windows
platform?

-- 
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: dropdown select box in django

2012-02-21 Thread Mario Gudelj
not sure what you mean there, but take a look at this
https://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield

On 21 February 2012 23:36, larry.mart...@gmail.com
wrote:

> On Feb 20, 9:52 pm, Mario Gudelj  wrote:
> > Hey there,
> >
> > Try this:
> >
> > In your forms.py create a field such as this
> >
> > message = forms.ChoiceField(label='Event Type',
> choices=EVENT_TYPE_CHOICES)
> >
> > That will create a dropdown.
>
> My app does not have a forms.py file. I know I can just create one,
> but then how would that field be scoped? I want it to be part of the
> EventsTable class.
>
>
> > Also, I think that the first thing in the tuple is a value and shouldn't
> > have a space, so change:
> >
> > EVENT_TYPE_CHOICES = (('Event Created', 'EventCreated'),('Event Changed',
> > 'EventChanged'),)
> >
> > to:
> >
> > EVENT_TYPE_CHOICES = (('event_created', 'Event
> Created'),('event_changed',
> > 'Event Changed'),)
> >
> > See if that works for you.
>
> Changing that did not have any effect.
>
>
> >
> > Cheers,
> >
> > -m
> >
> >  message = models.CharField("Event Type", max_length=12,
> >
> > > > choices=EVENT_TYPE_CHOICES)
> >
> > On 21 February 2012 12:28, larry.mart...@gmail.com
> > wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Feb 20, 5:54 pm, Anurag Chourasia 
> > > wrote:
> > > > This is weird
> >
> > > > I simply copy pasted your code in my environment and it shows me a
> Drop
> > > > Down.
> >
> > > > Could you save the models file again and close your browser (or even
> try
> > > > clearing cache) and restart your apache/django dev server whatever
> may be
> > > > the case and try again?
> >
> > > Tried all that, still no joy. Also tried 2 different browsers, no
> > > difference. In the dev server also tried setting a breakpoint and then
> > > printing out message.choices, and it has the choices I expected:
> >
> > > (Pdb) print message.choices
> > > (('Event Created', 'EventCreated'), ('Event Changed', 'EventChanged'))
> >
> > > > Regards,
> > > > Anurag
> >
> > > > On Mon, Feb 20, 2012 at 9:32 PM, larry.mart...@gmail.com <
> >
> > > > larry.mart...@gmail.com> wrote:
> > > > > I'm fairly new to django, still getting my feet wet. I want to
> have a
> > > > > dropdown menu (django seems to call this a select box). I read
> this:
> >
> > > > >
> https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.mo.
> > > ..
> >
> > > > > So I did this:
> >
> > > > > class EventsTable(models.Model):
> > > > >EVENT_TYPE_CHOICES = (
> > > > >('Event Created', 'EventCreated'),
> > > > >('Event Changed', 'EventChanged'),
> > > > >)
> >
> > > > >message = models.CharField("Event Type", max_length=12,
> > > > > choices=EVENT_TYPE_CHOICES)
> >
> > > > > But I get a standard text entry field where I can type in anything.
> >
> > > > > I did more googling, and I read a lot of confusing stuff about
> having
> > > > > to use javascrpt, ajax, CSS, etc. I read some pages about using a
> > > > > ChoiceField, but that is not part of the model class (it's in the
> > > > > forms class). I'm not sure how that would be used with a class that
> > > > > inherits form models.
> >
> > > > > What am I missing here? I can't imagine something as common as this
> > > > > would be hard in django. Shouldn't the first thing I did work?
> >
> > > > > TIA!
> > > > > -larry
> >
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Django users" group.
> > > > > To post to this group, send email to django-users@googlegroups.com
> .
> > > > > To unsubscribe from this group, send email to
> > > > > django-users+unsubscr...@googlegroups.com.
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/django-users?hl=en.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-users@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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

django with ajax without using jquery

2012-02-21 Thread dummyman dummyman
Which is the best place to start with using django and ajax without using
jquery ?

I meant calling the view function from javascript without using jquery
features

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



import error

2012-02-21 Thread dummyman dummyman
Hi ,

I have a django project and a standalone python script . From the view
function, i have invoked the standalone script. I am getting the error ."
No module named 



this is my code for standalone script

import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

from django.conf import settings

after that i ve imported the app inside this
.

from mysite.app.models import some
but still i am getting the error no module  named mysite
Please help in finding the reason for the error

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



email - inline image

2012-02-21 Thread ionic drive
Hello djangos,

I want to add a *.jpg image to an html-formated/email signature. 

I am not sure if this approach is correct, please help:

image_file = open(settings.PROJECT_ROOT+'/static/images/image_name.jpg',
'rb') #get the image file
msg_image = MIMEImage(image_file.read())
#with proper MIME type
image_file.close()
msg.attach(msg_image)
#attach the image to the mail message.

so far so good:
the image gets sent with the email message and is attached as
"attachment.dat".

How can I reference this image now to see it appear inline in the mail
message!?



Please improve my code...
why is the image recognized as "attachment.dat" and not with proper
image_name???

Is this the right approach to send a signature with inline image?

Thanks for your help guys
ionic






-- 
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: dropdown select box in django

2012-02-21 Thread larry.mart...@gmail.com
On Feb 20, 9:52 pm, Mario Gudelj  wrote:
> Hey there,
>
> Try this:
>
> In your forms.py create a field such as this
>
> message = forms.ChoiceField(label='Event Type', choices=EVENT_TYPE_CHOICES)
>
> That will create a dropdown.

My app does not have a forms.py file. I know I can just create one,
but then how would that field be scoped? I want it to be part of the
EventsTable class.


> Also, I think that the first thing in the tuple is a value and shouldn't
> have a space, so change:
>
> EVENT_TYPE_CHOICES = (('Event Created', 'EventCreated'),('Event Changed',
> 'EventChanged'),)
>
> to:
>
> EVENT_TYPE_CHOICES = (('event_created', 'Event Created'),('event_changed',
> 'Event Changed'),)
>
> See if that works for you.

Changing that did not have any effect.


>
> Cheers,
>
> -m
>
>  message = models.CharField("Event Type", max_length=12,
>
> > > choices=EVENT_TYPE_CHOICES)
>
> On 21 February 2012 12:28, larry.mart...@gmail.com
> wrote:
>
>
>
>
>
>
>
> > On Feb 20, 5:54 pm, Anurag Chourasia 
> > wrote:
> > > This is weird
>
> > > I simply copy pasted your code in my environment and it shows me a Drop
> > > Down.
>
> > > Could you save the models file again and close your browser (or even try
> > > clearing cache) and restart your apache/django dev server whatever may be
> > > the case and try again?
>
> > Tried all that, still no joy. Also tried 2 different browsers, no
> > difference. In the dev server also tried setting a breakpoint and then
> > printing out message.choices, and it has the choices I expected:
>
> > (Pdb) print message.choices
> > (('Event Created', 'EventCreated'), ('Event Changed', 'EventChanged'))
>
> > > Regards,
> > > Anurag
>
> > > On Mon, Feb 20, 2012 at 9:32 PM, larry.mart...@gmail.com <
>
> > > larry.mart...@gmail.com> wrote:
> > > > I'm fairly new to django, still getting my feet wet. I want to have a
> > > > dropdown menu (django seems to call this a select box). I read this:
>
> > > >https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.mo.
> > ..
>
> > > > So I did this:
>
> > > > class EventsTable(models.Model):
> > > >    EVENT_TYPE_CHOICES = (
> > > >        ('Event Created', 'EventCreated'),
> > > >        ('Event Changed', 'EventChanged'),
> > > >    )
>
> > > >    message = models.CharField("Event Type", max_length=12,
> > > > choices=EVENT_TYPE_CHOICES)
>
> > > > But I get a standard text entry field where I can type in anything.
>
> > > > I did more googling, and I read a lot of confusing stuff about having
> > > > to use javascrpt, ajax, CSS, etc. I read some pages about using a
> > > > ChoiceField, but that is not part of the model class (it's in the
> > > > forms class). I'm not sure how that would be used with a class that
> > > > inherits form models.
>
> > > > What am I missing here? I can't imagine something as common as this
> > > > would be hard in django. Shouldn't the first thing I did work?
>
> > > > TIA!
> > > > -larry
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: RemoteUserBackend not creating user

2012-02-21 Thread Tom Evans
On Mon, Feb 20, 2012 at 11:29 PM, Roberto Bouza  wrote:
> Hello,
>
> I've been hitting my head pretty hard trying to figure out what the
> problem is hope someone here can help.
>
> I've set up the remote backends and middleware as per the docs and
> blatantly I'm coding the META remote_user and nothing happens. like
> this:
>
> MIDDLEWARE_CLASSES = (
>    'django.middleware.common.CommonMiddleware',
>    'django.contrib.sessions.middleware.SessionMiddleware',
>    'django.middleware.csrf.CsrfViewMiddleware',
>    'django.contrib.auth.middleware.AuthenticationMiddleware',
>    'django.contrib.auth.middleware.RemoteUserMiddleware',
>    'django.contrib.messages.middleware.MessageMiddleware',
> )

GOOD:
RemoteUserMiddleware will attempt to authenticate as REMOTE_USER if
the user has not already been authenticated.

>
> AUTHENTICATION_BACKENDS = (
>    'django.contrib.auth.backends.RemoteUserBackend',
> )

GOOD:
RemoteUserBackend will create new users when an unknown user is authenticated.

>
> Then on my view:
>
> def login_(request):
>    request.META['REMOTE_USER'] = 'test123'
>    try:
>        user = User.objects.get(username=request.META['REMOTE_USER'])
>        logger.debug("got user: %s, %s", user.last_name,
> user.first_name)
>    except ObjectDoesNotExist:
>        logger.debug("username: %s, does not exist",
> request.META['REMOTE_USER'])
>
>    return render_to_response('myapp/dashboard.html',
> {'section':'dashboard'}, context_instance=RequestContext(request))
>
> All goes as planned, but the user is not being created. Am I missing
> something here?

Yes, wtf are you trying to do here? You cannot randomly change things
in request.META from inside your view, and expect the middleware code
*that has already run* to create and authenticate as your user. If
REMOTE_USER was being set correctly by your web server, what you have
configured would work.

With it set up correctly, you wouldn't have to mess around looking at
request.META['REMOTE_USER'] to get the user, it would be available on
request.user.

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.