How to use ModelForm for both new or existing data

2011-09-05 Thread David
Hi, I'm having trouble figuring out the best way to use ModelForm in the following situation. I have these post variables coming into the view course_id course_department course_number And course_id may or may not be an empty string. If I do course_form = CourseForm(request.POST) Then the

Re: Authorization workflow model

2011-09-05 Thread Mike Dewhirst
On 6/09/2011 5:46am, Mario8k wrote: Hello, Does anyone knows some solution (reusable app, snippet or any idea) to model an authorization workflow of data? That is... supose that a user have restricted some model field, ie, cannot edit directly this field. And now supose that he could request

Admin TabularInline Edit Parent Record?

2011-09-05 Thread Lee
I use TabularInlines for Many-to-Many join tables, with the foreign keys appearing in select lists. The Admin interface automatically provides the stellar "Add-Another" icon (a plus sign) with the select list, to add a new parent record on the fly. It would be extremely useful to also have an edit

Re: Beginner's unit test question

2011-09-05 Thread Rodney Topor
Never mind. I've found the answer. The problem was that my app name "messages" somehow clashed with the app "django.contrib.messages" which was earlier in my INSTALLED_APPS. This didn't prevent my project from working, but did confuse the test framework, which looked in

Re: admin site not showing up?

2011-09-05 Thread mrstevegross
Figured it out: gotta run autodiscover(). --Steve -- 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

Re: Beginner's unit test question

2011-09-05 Thread Rodney Topor
I'm sorry for my inconsistency. I tried to "simplify", but made a mistake. In fact, I used the app "messages" throughout, in my code and in the test command. The project containing the app works fine. In particular, the app "messages" is included in INSTALLED_APPS. So, if the test "should

admin site not showing up?

2011-09-05 Thread mrstevegross
I'm dutifully following the instructions at the django tutorial (https://docs.djangoproject.com/en/1.3/intro/tutorial02/). I have amended admin.py and urls.py as indicated and restarted the server; however, the admin website does NOT provide any interface to the polls app. Instead, it tells me:

forms.ChoiceField/forms.ModelChoiceField Needs a Lot of Love

2011-09-05 Thread Terribyte
I don't know if anyone has said this outright, but I think that ChoiceField and ModelChoiceField are just broken. It seems that every time I want to do something with them I'm having to write a custom init function get what I want done. As a community I think we should be able to improve the

Re: Authorization workflow model

2011-09-05 Thread Shawn Milochik
You could use a model with three fields: A generic foreign key to the instance to be modified. A char field containing the fieldname on that instance. The new value. Of course you'd need another field to store the user (assuming the person making the authorization will base their

Authorization workflow model

2011-09-05 Thread Mario8k
Hello, Does anyone knows some solution (reusable app, snippet or any idea) to model an authorization workflow of data? That is... supose that a user have restricted some model field, ie, cannot edit directly this field. And now supose that he could request to change that field, seeing the real

Minimal change broken my csrf validation.

2011-09-05 Thread Yaşar Arabacı
Can you please take a look at here: http://stackoverflow.com/q/7312029/886669 -- http://yasar.serveblog.net/ -- 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

Re: Use primary key in filenames on FileFields

2011-09-05 Thread Bingimar
try this def get_file_path(instance, filename): path = 'your upload directory' extension = filename.split('.')[-1].lower() new_file_name = self.id return '%(path)s/%(filename)s.%(extension)s' % {

DecimalField values changing on save()

2011-09-05 Thread Wilfred Hughes
Hi all I know this is a bit of a corner case, but I was slightly surprised by the behaviour of DecimalField with the value -0.0. Given the model: class Word(models.Model): word = models.CharField(max_length=50, unique=True) number = models.DecimalField(max_digits=8, decimal_places=5)

Use primary key in filenames on FileFields

2011-09-05 Thread Stratos Moros
Hello, I have a model that includes a FileField. When the user uploads a file via the admin interface, I want the file to be saved as 'upload_to/ primary_key/original_filename'. Since the object will not be saved in the database when the user uploads the file, it will not have a primary key at

Re: Use primary key in filenames on FileFields

2011-09-05 Thread Stratos Moros
I forgot to mention that i have imported models like this: import django.db.models as m This should explain the first two lines. On Mon, Sep 5, 2011 at 12:28 PM, Stratos Moros wrote: > Hello, > > I have a model that includes a FileField. When the user uploads a file > via the

Re: Class-based FormView Contact Form

2011-09-05 Thread Russell Keith-Magee
On Mon, Sep 5, 2011 at 6:17 PM, Paul Walsh wrote: > Anyone? > I really want to use class-based views, but it is hard with so much missing > in terms of examples/tutorials. Hi Paul, First off, apologies for the current state of the Class-based views documentation. It's one

RE: sitemap

2011-09-05 Thread Fatih ERİKLİ
> Exception Value: Reverse for 'entry' with arguments '('my 1st post',)'look at > urls.py > Date: Sun, 4 Sep 2011 22:25:50 -0700 > Subject: sitemap > From: veva...@yandex.ru > To: django-users@googlegroups.com > > Would You please help me to find a mistake? > --- blog.model.py: > from

Re: foregin keys

2011-09-05 Thread bruno desthuilliers
On Sep 4, 7:20 pm, Kevin Anthony wrote: > hi, how do i join two models on something OTHER then the primary key? You didn't search for long, did you ? https://docs.djangoproject.com/en/1.3/ref/models/fields/#django.db.models.ForeignKey.to_field Please do the minimal

Re: Beginner's unit test question

2011-09-05 Thread bruno desthuilliers
On Sep 5, 5:18 am, Rodney Topor wrote: > I'm trying to use unit tests for the first time. > > In app/tests.py I have: > > import unittest > from django.test.client import Client > > class IndexTest(unittest.TestCase): >     def test_index(self): >         client = Client() >    

Re: logging django errors also on the server

2011-09-05 Thread Uros Trebec
Take a look at Sentry: http://readthedocs.org/docs/sentry/ It works pretty well, uses polling to update the log view, can track multiple sites with separate Sentry Server, etc. Good luck, Uros On Sep 5, 12:58 am, Gelonida N wrote: > Hi, > > Im am debugging a django

Re: time part of datetime not saved

2011-09-05 Thread het.oosten
I did change the model from DateField to DateTimeField, removed the table, synced the database and restarted the wsgi instance. As I found out I should have restarted the wsgi server right after deleting the table from the database. The second time I did remove, recreate and restart in the same

Re: time part of datetime not saved

2011-09-05 Thread Masklinn
On 2011-09-05, at 14:08 , Jirka Vejrazka wrote: > OK - I can't see anything wrong with your code that'd jump at me. Can > you check your database table format? Maybe you've declared your model > fields as models.DateField first and then changed to DateTimeField > without changing the underlying

Re: time part of datetime not saved

2011-09-05 Thread Jirka Vejrazka
OK - I can't see anything wrong with your code that'd jump at me. Can you check your database table format? Maybe you've declared your model fields as models.DateField first and then changed to DateTimeField without changing the underlying table? Just a guess :) Jirka -- You received this

Re: time part of datetime not saved

2011-09-05 Thread Masklinn
On 2011-09-05, at 13:13 , Jirka Vejrazka wrote: > Can you tell us what is the "[0:6]" supposed to be doing in your time > conversion funcions? strptime returns a struct_time[0] which is a 9-tuple. The datetime constructor takes up to 8 arguments, but the last 2 are microseconds and a tzinfo

Re: time part of datetime not saved

2011-09-05 Thread het.oosten
On 5 sep, 13:40, bik...@gmail.com wrote: > Just call it a hunch, but can you try [0:8] please..? I get this error in that case TypeError: tzinfo argument must be None or of a tzinfo subclass, not type 'int' I think that the strptime works correctly, because the returned datetime is:

Re: time part of datetime not saved

2011-09-05 Thread bikkit
Just call it a hunch, but can you try [0:8] please..? Sent from my BlackBerry® from Vodafone -Original Message- From: "het.oosten" Sender: django-users@googlegroups.com Date: Mon, 5 Sep 2011 04:30:44 To: Django users Reply-To:

Re: time part of datetime not saved

2011-09-05 Thread het.oosten
It is a python 2.4 workaround for using strptime. Without the '[0:6]' I get this error: TypeError: function takes at most 8 arguments (9 given) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: time part of datetime not saved

2011-09-05 Thread Jirka Vejrazka
Can you tell us what is the "[0:6]" supposed to be doing in your time conversion funcions? -- 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

Re: time part of datetime not saved

2011-09-05 Thread het.oosten
Oh btw, it is all about importing a facebook eventcalendar (in icalendar format) into a database. -- 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

Re: time part of datetime not saved

2011-09-05 Thread het.oosten
Here is a code dump (still work in progress :-) ): http://pastebin.com/szQKRw7d -- 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

Re: Class-based FormView Contact Form

2011-09-05 Thread Paul Walsh
Anyone? I really want to use class-based views, but it is hard with so much missing in terms of examples/tutorials. thx. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit

Re: time part of datetime not saved

2011-09-05 Thread Praveen Krishna R
*dump your code ?! * *BTW, * *You can set auto_now_add = true in the model, which will assign the current datetime, while saving without any code at all. * On Mon, Sep 5, 2011 at 11:54 AM, het.oosten wrote: > I have a model start = models.DateTimeField() > > In my view I

time part of datetime not saved

2011-09-05 Thread het.oosten
I have a model start = models.DateTimeField() In my view I create a datetime: x = datetime.datetime(*(time.strptime(str(component.get('dtstamp')),'%Y %m%dT%H%M%SZ')[0:6])) . This return a valid datetime: >>> x datetime.datetime(2011, 9, 4, 8, 45, 32) The problem is that only the date part is

Re: logging django errors also on the server

2011-09-05 Thread Gelonida N
On 09/05/2011 03:05 AM, Reinout van Rees wrote: > On 05-09-11 02:25, Gelonida N wrote: >> I see my own log traces. >> In many situations I do see error messages in the log output. > > An important thing that's not mentioned too clearly in Django 1.3's > logging docs: *add a root logger*. So a