StackOverflow to the rescue:
http://stackoverflow.com/questions/1059831/strange-behavior-with-modelform-and-saving
On Jun 29, 2:43 pm, Huuuze wrote:
> This problem is very strange and I'm hoping someone can help me. For
> the sake of argument, I have a Author model with
This problem is very strange and I'm hoping someone can help me. For
the sake of argument, I have a Author model with ForeignKey
relationship to the Book model. When I display an author, I would
like to have a ChoiceField that ONLY displays the books associated
with that author. As such, I over
Malcolm, I believe you and appreciate your advice, but you need to
ease up. You're getting hung up on semantics. In this instance, I'm
simply differentiating between a user clicking a link that says
"Logout" (a.k.a, a manual logout) versus Django detecting the lack of
a session cookie and redire
Yes, it does generate new session_id. The user has essentially told
Django to expire the session, which in turn results in a new session
key.
I'm starting to agree with Malcolm. Outside of an elaborate solution,
this one may not be possible. As soon as the session expires, Django
updates the r
on" table.
>> However, the records in this table cannot be associated with that user
>> because the sessionid value in the cookie is reset when the redirect occurs.
>> I'm guessing I'm not the first to encounter this dilemma. Does anyone have
>> insight int
omething
> > terrible with JavaScript. If not, or you can at least wait a little
> > while--run a cron job (every minute, if you'd like) that finds all of
> > the sessions that are past their expiration date. You can log them as
> > you'd like, and then clear t
Jeff (and Jacob)...
I appreciate your responses and I stand corrected. With that being
said, are either of you (or anyone reading this) aware of a method
that would allow me to track idle session timeouts? I'd like to audit
when a user has been logged out due to a timeout.
Huuuze
On M
I opened the following ticket which was unceremoniously closed by a
committer:
http://code.djangoproject.com/ticket/10518
Here is the text from the ticket:
>> I have set the SESSION_COOKIE_AGE value in my settings.py file to expire
>> sessions after 1 hour. Django successfully logs the user out
I would like to audit when a user has experienced an idle timeout in
my Django application. In other words, if the user's session cookie's
expiration date exceeds the SESSION_COOKIE_AGE found in settings.py,
the user is redirected to the login page. When that occurs, an audit
should also occur.
C
I recently added "SESSION_SAVE_EVERY_REQUEST". As the name implies,
the session ID is changed for every request made to the server. IMO,
this is overkill. If your page has 10 images on it, the session ID
will be changed 11 times (once for the initial page request and then
10 more times for each
There are no tracebacks in this instance. I can see the non-descript
500 errors appearing in my terminal window.
On Sep 23, 12:06 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, Sep 23, 2008 at 11:53 AM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > I'm
I'm preparing to deploy my Django app and I noticed that when I change
the "DEBUG" setting to False, all references to static files (i.e.,
JavaScript, CSS, etc..) result in HTTP 500 errors.
Any idea what's causing that issue (and how to fix it)?
--~--~-~--~~~---~--~--
I got it working by using Psycopg 2 Beta 7, rather than Beta 8. You
can DL it here:
http://www.initd.org/svn/psycopg/psycopg2/tags/2_0_BETA_7/
On Sep 17, 1:02 am, "Whyneedsgoogle2know?" <[EMAIL PROTECTED]>
wrote:
> Graham Dumpleton wrote:
> > On Aug 29, 6:43 am,
I recently installed PostgreSQL 8.3.3 and psycopg 2 (latest from
SVN). When I attempt to start Django, I receive this error:
File "/Library/Python/2.5/site-packages/django/db/backends/
postgresql_psycopg2/base.py", line 20, in
raise ImproperlyConfigured("Error loading psycopg2 module: %s" %
The latest Django beta added this method to the admin models:
>> save_model(self, request, obj, form, change)
I have a business case where a "delete_model" method would come in
very handy. Does anyone know if this will be included in an upcoming
release?
If not, here is my dilemma. When an it
I'd appreciate it if someone else chimed in, but it appears as though
the HOWTO contains a typo. I've looked at the older versions of
Django and the NFA branch and none of them include the "model"
parameter in the "save_add" method.
Anyone else agree?
On J
I am using Django 1.0alpha and I'm attempting to modify the add/change
behavior of my ModelAdmin. As such, I'm following this example found
on the Django wiki:
http://code.djangoproject.com/wiki/NewformsHOWTO#Q:HowcanIchangewhereIgetsentaftersavinganewentrytothedatabase
Unfortunately, the metho
Disregard. Odd issue with my ADMIN_MEDIA_PREFIX.
On Jul 15, 2:13 pm, Huuuze <[EMAIL PROTECTED]> wrote:
> When I click the button to add a new Person object (one of my objects,
> not the User object) in the admin interface, I receive the following
> error in my console wi
When I click the button to add a new Person object (one of my objects,
not the User object) in the admin interface, I receive the following
error in my console window:
ERROR: invalid input syntax for integer: "static_media/admin/js/
core.js"
STATEMENT: SELECT "person_person"."id", "person_perso
n or at
> > least the svn trunk. I'm not adding the extra field to the model
> > because it doesn't really belong there, though it's related to the
> > model.
>
> > On Jul 3, 6:10 pm, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > > Yes, you can do
Yes, you can do that, but you'd need to add it to the ModelForm's
fields:
>> self.fields['short_name'] = forms.CharField(label='Short Name', max_length=9)
This code would need to be added to an overridden __init__ in your
ModelForm. One question, however: why don't you add this field to
your mo
I figured out the puzzle:
self.fields['state'] = forms.CharField(required=False,
widget=forms.HiddenInput(), initial=self.instance.state)
Still open to feedback since I'm new to Django.
On Jul 2, 11:19 am, Huuuze <[EMAIL PROTECTED]> wrote:
> I use the following cod
I use the following code to disable a ModelForm field in a custom
__init__:
self.fields['state'] =
USStateField(widget=widgets.Select({'class':'disabled', 'disabled':'',
'tabindex':'-1',}, choices=STATE_CHOICES), required=False)
Unfortunately, this presents a problem. When I post the form with
> urlpatterns = patterns('',
> (r'/step-1.html', 'billpay.views.DoPayDetailForm'),
> )
>
> Wouldn't this call the dopaydetailform view if you went to the page /
> step-1.html ?
It's close. Re-write it as such:
> urlpatterns = patterns('',
> (r'^step-1.html/$', billpay.views.DoPayDetail
You da man. That worked perfectly.
Just out of curiosity, are the Django devs working on a patch? I
wasn't able to find a ticket for this issue.
On Jun 26, 12:46 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote:
> On Jun 26, 8:29 am, Huuuze <[EMAIL PROTECTED]> wrote:
&g
I'm using a ModelForm to render a model that contains a
USStateField.
>> state = models.USStateField(blank=True, null=True)
Unfortunately, when it renders, the first selection is always
"Alabama" rather than "--" or some other defined blank value
(i.e., "Please select a state"). How can I a
data
> from the form, but doesn't save it to the db, then you can handle it
> like a regular model.
>
> On Jun 25, 5:04 pm, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > For the sake of argument, I have two models: Book and Author. Book
> > has many fields and has a f
ave it to the db, then you can handle it
> like a regular model.
>
> On Jun 25, 5:04 pm, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > For the sake of argument, I have two models: Book and Author. Book
> > has many fields and has a foreign key relationship with Author.
>
For the sake of argument, I have two models: Book and Author. Book
has many fields and has a foreign key relationship with Author.
Author has two fields and no additional relationships. To stay DRY, I
have BookForm and AuthorForm classes that I use to generate the HTML
for each class.
When I s
alues. This seems odd. Is that by design with Django? Here is
the code from my model for that ultimately gets rendered by my
ModelForm:
>> middle_name = models.CharField(max_length=30, blank=True, null=True)
On Jun 25, 5:02 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote:
>
quot; here doesn't seem to work. Any thoughts?
On Jun 25, 4:44 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Jun 25, 2008 at 4:39 PM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > Thanks for getting back to me. You're correct -- that article is not
>
can I go about
creating a NullIntegerField? This is new territory for me.
On Jun 25, 4:28 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Huuuze wrote:
> > I have defined a zip code field as follows in my Address model:
>
> > zip = models.IntegerField(blank=True, nu
I have defined a zip code field as follows in my Address model:
zip = models.IntegerField(blank=True, null=True)
Being a good Djangonaut, I'm using a ModelForm to convert my address
model into HTML. Now this where things get dicey. As you can see in
the model, zip code can except empty values.
d to address you by your proper name, but
> unfortunately some developer forgot to pass a variable to the template used
> to render me! You should call and complain.
> {% endif %}
>
> :)
> -richard
>
> On 6/24/08, Huuuze <[EMAIL PROTECTED]> wrote:
>
>
>
> &g
ologize in advance if using RequestContext does resolve this issue
-- still learning!
On Jun 24, 10:02 am, "Johan Liseborn" <[EMAIL PROTECTED]>
wrote:
> On Tue, Jun 24, 2008 at 15:47, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > A n00b question for everyone: My base templ
A n00b question for everyone: My base template has a "Welcome
" section in it. Currently, I'm adding the username (which
is coming from Django's auth/auth framework) to the template with the
following bit of code:
{{ request.session.user.username }}
This works, however, it requires me to add th
You da man. This worked perfectly out of the box. Thank you!
On Jun 19, 5:54 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote:
> On Jun 19, 3:45 pm, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote:
>
> > if self.instance.state == 'processing':
> > queryset = q
You're off by one. The value added to the PYTHONPATH (note, not
system path) should be:
/Library/Python/2.5/site-packages/
That will trigger the auto-complete for django classes. One warning:
auto-completion for Model.objects is broken. PyDev will flag that as
an error -- the author of PyDev
In this example, what if you wanted to selectively remove a value from
the choice list. For example, let's say the list contained New, In
Process, and Closed. When an item is "In Process", it cannot revert
back to "New". As such, "New" should not be displayed amongst the
choices if "In Process"
Got it worked out using ModelForms. Version 0.96.2 didn't include any
of these slick features.
For what its worth, I don't believe it would've ever worked using
v0.96.2.
On Jun 19, 11:01 am, Huuuze <[EMAIL PROTECTED]> wrote:
> On Jun 18, 7:32 pm, "Karen Trac
One additional note: Can you post the code you used to get it working?
On Jun 18, 7:32 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Jun 18, 2008 at 4:53 PM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > I have the following model:
>
> >
On Jun 18, 7:32 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Jun 18, 2008 at 4:53 PM, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > I have the following model:
>
> > class Publishers(models.Model):
> > books = models.CharField(maxlength=1,
I have the following model:
class Publishers(models.Model):
books = models.CharField(maxlength=1, choices=BOOKS)
BOOKS is a tuple:
BOOKS = ( ('1', 'Book A'), ('2', 'Book B') )
When I use form_for_instance(Publishers) to generate my template's
HTML based upon the Publisher model, the books fie
Its a typo. It should've been...
>> pid = models.ForeignKey(Person)
On Jun 9, 5:06 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> What is this `pid = models.ForiegnKey()` ?
>
> On 9 июн, 23:44, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > I have
I have the following models in my models.py file:
>> class Person(models.Model):
>> pid = models.AutoField(primary_key=True)
>> fname = models.CharField(max_length=50)
>> lname = models.CharField(max_length=50)
>> class Books(models.Model)
>> bid = models.AutoField(primary_key=True)
>>
I have a method that evaluates the incoming "HttpRequest" from a
webpage. As such, I'll use the following call to retrieve the data:
>> person_id = request.GET.get('person_id', '')
At this point, assuming I have a valid value for "some_id", I'd like
to use it in this statement:
>> results = Pe
I'm new to Django, so please be gentle. Basic question: when
developing a web app, I've typically created an "includes" directory
which stores commonly used functions or methods. From a best practice
standpoint, is it recommended that I create an "includes" directory
(not application) within my
47 matches
Mail list logo