mviamari | 1 Aug 2009 01:31
Picon

Dynamic Choices for ChoiceField


Hello,

I'm trying to make a form for data entry into my database that uses
ChoiceFields for foreign keys.  Obviously, the ideal choice would be
ModelChoiceField, however I'm not using the django ORM, so I've
assumed that's not going to work (I'm using Elixir/SQLAlchemy).

I originally set the choices parameter in the ChoiceField declaration
to be derived from a query result from SQLAlchemy (returned as an
array of tuples).  The problem is that the choices don't update when
the database changes.  They are fixed to whatever was present when the
server is initialized (or at least it appears to be).

I've worked around this by using CharFields and implementing my own
validation method that checks for the value in the aforesaid query
result.  Unforunately, that doesn't help me if i want to use the
forms.as_<html> methods.

I'm looking for suggestions/advice on to get the ChoiceField choices
to update when the form is the used.

Thanks,
Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users <at> googlegroups.com
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
(Continue reading)

When ideas fail | 1 Aug 2009 02:04
Picon

Log in problem


Hi, i am using this template to log people in, but it seems to always
return the login form no matter what i do, i can be logged in or
logged out and it will still say i need to log in.

Does anyone know what might be happening. Any help would be
appreciated.

Thanks

{% extends "blogSite/index.html" %}

{% block content %}
	{% if not request.user.is_authenticated %}
		{% if form.errors %}
    			<p class="error">Sorry, that's not a valid username or
password</p>
  		{% endif %}
			<p> Please enter you user name and password below:</p>
			<form action="" method="post">
    				<label for="username">Username:</label>
    				<input type="text" name="username" value=""
id="username"><br><br>
    				<label for="password">Password:</label>
    				<input type="password" name="password" value=""
id="password"><br><br>

				<input type="submit" value="login" />
    				<input type="hidden" name="next" value="../login/" />
  			</form>
(Continue reading)

Luke Seelenbinder | 1 Aug 2009 02:09
Picon

Re: Log in problem


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Are you passing the "request" to it?
That's the only thing I can think of that would mess it up, otherwise it
looks good syntactically.

Luke

luke.seelenbinder <at> gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire

When ideas fail wrote:
> Hi, i am using this template to log people in, but it seems to always
> return the login form no matter what i do, i can be logged in or
> logged out and it will still say i need to log in.
> 
> Does anyone know what might be happening. Any help would be
> appreciated.
> 
> Thanks
> 
> {% extends "blogSite/index.html" %}
> 
> {% block content %}
> 	{% if not request.user.is_authenticated %}
> 		{% if form.errors %}
(Continue reading)

Vasil Vangelovski | 1 Aug 2009 02:13
Picon
Gravatar

Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?


I'm making a very small project that will use the apps/models from a 
larger one. This will be hosted on a separate domain. Now the larger 
project uses the models from django.contrib.auth, but I don't need and 
don't want to store users in a database for this smaller one. I'll just 
provide my own authentication backend that reads usernames and password 
from a config file and uses Base64 authentication. Do I still need to 
put django.contrib.auth in INSTALLED_APPS?

--~--~---------~--~----~------------~-------~--~----~
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 <at> googlegroups.com
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Luke Seelenbinder | 1 Aug 2009 02:16
Picon

Re: Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vasil,

That will vary on what the apps you are using. If none of the apps
depend on django.contrib.auth, you won't need it, unless you want to use
the django admin (which depends on django.contrib.auth).

To fully answer your question, we would need to know what apps it is using.

Luke
luke.seelenbinder <at> gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire

Vasil Vangelovski wrote:
> I'm making a very small project that will use the apps/models from a 
> larger one. This will be hosted on a separate domain. Now the larger 
> project uses the models from django.contrib.auth, but I don't need and 
> don't want to store users in a database for this smaller one. I'll just 
> provide my own authentication backend that reads usernames and password 
> from a config file and uses Base64 authentication. Do I still need to 
> put django.contrib.auth in INSTALLED_APPS?
> 
> > 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
(Continue reading)

When ideas fail | 1 Aug 2009 02:26
Picon

Re: Log in problem


I'm using (r'^login/$', 'django.contrib.auth.views.login',
{'template_name': 'blogSite/login.html'}), for the view, so does that
pass a request of not?

On 1 Aug, 01:09, Luke Seelenbinder <luke.seelenbin... <at> gmail.com>
wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Are you passing the "request" to it?
> That's the only thing I can think of that would mess it up, otherwise it
> looks good syntactically.
>
> Luke
>
> luke.seelenbin... <at> gmail.com
>
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
>
>
>
> When ideas fail wrote:
> > Hi, i am using this template to log people in, but it seems to always
> > return the login form no matter what i do, i can be logged in or
> > logged out and it will still say i need to log in.
>
> > Does anyone know what might be happening. Any help would be
> > appreciated.
(Continue reading)

Luke Seelenbinder | 1 Aug 2009 02:30
Picon

Re: Log in problem


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

No it doesn't. That would be your problem, you would have to write a
custom backend if you wanted to not show the login form to already
logged-in visitors.

Luke
luke.seelenbinder <at> gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire

When ideas fail wrote:
> I'm using (r'^login/$', 'django.contrib.auth.views.login',
> {'template_name': 'blogSite/login.html'}), for the view, so does that
> pass a request of not?
> 
> On 1 Aug, 01:09, Luke Seelenbinder <luke.seelenbin... <at> gmail.com>
> wrote:
> Are you passing the "request" to it?
> That's the only thing I can think of that would mess it up, otherwise it
> looks good syntactically.
> 
> Luke
> 
> luke.seelenbin... <at> gmail.com
> 
> "I [may] disapprove of what you say, but I will defend to the death your
(Continue reading)

Vasil Vangelovski | 1 Aug 2009 02:29
Picon
Gravatar

Re: Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?


It's like this:
I actually have 3 projects. These projects share apps. So all the apps 
besides the third party ones are placed in one folder which is on 
PYTHONPATH. The third party ones are in another folder on the 
PYTHONPATH. Yes 2 of these projects use the admin and do use the 
ModelBackend for authentication, I have django.contrib.auth in 
INSTALLED_APPS for those 2.

But this smaller project I'm asking about provides just a few views for 
a REST API. Now the calls to that REST service are made only by one 
application on the internal network which will have it's own 
username/password in the settings file. And this project doesn't use the 
admin or any of the models in django.contrib.auth (besides returning 
User from the authenticate method in the backend).

So I guess I don't need django.contrib.auth in INSTALLED_APPS for that 
project.

Luke Seelenbinder wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Vasil,
>
> That will vary on what the apps you are using. If none of the apps
> depend on django.contrib.auth, you won't need it, unless you want to use
> the django admin (which depends on django.contrib.auth).
>
> To fully answer your question, we would need to know what apps it is using.
(Continue reading)

Luke Seelenbinder | 1 Aug 2009 02:31
Picon

Re: Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

No, you would not. Hope that helps.

Luke

luke.seelenbinder <at> gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire

Vasil Vangelovski wrote:
> It's like this:
> I actually have 3 projects. These projects share apps. So all the apps 
> besides the third party ones are placed in one folder which is on 
> PYTHONPATH. The third party ones are in another folder on the 
> PYTHONPATH. Yes 2 of these projects use the admin and do use the 
> ModelBackend for authentication, I have django.contrib.auth in 
> INSTALLED_APPS for those 2.
> 
> But this smaller project I'm asking about provides just a few views for 
> a REST API. Now the calls to that REST service are made only by one 
> application on the internal network which will have it's own 
> username/password in the settings file. And this project doesn't use the 
> admin or any of the models in django.contrib.auth (besides returning 
> User from the authenticate method in the backend).
> 
> So I guess I don't need django.contrib.auth in INSTALLED_APPS for that 
(Continue reading)

Vasil Vangelovski | 1 Aug 2009 02:34
Picon
Gravatar

Re: Do I need django.contrib.auth in my INSTALLED_APP when if I don't use the models from there?


Thanks :)

Luke Seelenbinder wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> No, you would not. Hope that helps.
>
> Luke
>
> luke.seelenbinder <at> gmail.com
>
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
>
>
> Vasil Vangelovski wrote:
>   
>> It's like this:
>> I actually have 3 projects. These projects share apps. So all the apps 
>> besides the third party ones are placed in one folder which is on 
>> PYTHONPATH. The third party ones are in another folder on the 
>> PYTHONPATH. Yes 2 of these projects use the admin and do use the 
>> ModelBackend for authentication, I have django.contrib.auth in 
>> INSTALLED_APPS for those 2.
>>
>> But this smaller project I'm asking about provides just a few views for 
>> a REST API. Now the calls to that REST service are made only by one 
>> application on the internal network which will have it's own 
(Continue reading)


Gmane