Re: What happens to DB data when I change my models?

2011-04-20 Thread Shawn Milochik
Django has nothing built in at this time to handle data migrations. You need to use South (or manual SQL commands) to do this. http://south.aeracode.org/ When you make changes to your model, doing syncdb again will _not_ change the database. Depending on the changes made it's possible you could g

Re: Formset and Choices with Objects

2011-04-21 Thread Shawn Milochik
For the first question, you can use the form's 'instance' property to access the underlying model instance. For the latter, it sounds like you just need to concatenate the stuff you display. -- You received this message because you are subscribed to the Google Groups "Django users" group. To po

Running Django tests from Python

2011-04-21 Thread Shawn Milochik
I want to use pyinotify[1] to monitor my project directory and run my unit tests whenever I save a .py file. The monitoring part is working. All I need now is to know how to call the tests from my "watcher" script. As noted in the docs[2], I'm already running setup_test_environment() in my scrip

Best-practice for building URLs in templates with JavaScript

2011-04-22 Thread Shawn Milochik
I'm working on an app which makes extensive use of AJAX. I'm also using named URLs so I don't have to hard-code URLs into my templates. The problem is that if a URL pattern requires extra info after the path, my templates don't render, because the extra parameters aren't known until the user makes

Re: extending a shopping cart

2011-04-22 Thread Shawn Milochik
I think you just re-invented generic foreign keys: http://docs.djangoproject.com/en/1.3/ref/contrib/contenttypes/#generic-relations -- 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.c

Re: Unicode translation problem

2011-04-22 Thread Shawn Milochik
What does "it just doesn't work" mean? What errors are you getting? What is it doing or not doing? -- 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

Re: django 1.1 performance versus django 1.2 performance

2011-04-22 Thread Shawn Milochik
This was mentioned in Eric Florenzano's talk at DjangoCon 2010. Each version has gotten slower. I haven't heard anything about the cause or plans to fix this, though. If you've got a good test suite you can always use tools like Python's profile module to track down slowdowns in your Django code a

Re: logout problem - NameError - newbie

2011-04-22 Thread Shawn Milochik
It's probably that you didn't import 'farewell' from views.py in urls.py, so it's not in scope. -- 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, s

Re: extending a shopping cart

2011-04-23 Thread Shawn Milochik
Did you check out the docs for adding a generic foreign key to your model itself? -- 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: Best-practice for building URLs in templates with JavaScript

2011-04-23 Thread Shawn Milochik
On Sat, Apr 23, 2011 at 3:31 AM, Ryan Osborn wrote: > You could always make the payment_id group optional using a ?: > > update_payment/(?P\w+)? Ryan, Thanks. I considered that first, but rejected it because I want the extra field to be required. If it's missing then it's an error. Giving it a

Re: Checking for user type in view

2011-04-24 Thread Shawn Milochik
It's not recommended that you subclass User. Better: Create a class to use for a user profile and associate it with the User using the instructions here: http://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users Then give that class a 'role' field or something

Re: Checking for user type in view

2011-04-25 Thread Shawn Milochik
You can use a user profile for a lot more, and there's no reason the two roles have to be mutually exclusive when you're creating your own class. I just wanted to make that point. I have never used the built-in groups myself, but from your explanation it seems like a good solution for the original

Re: Dynamically form modification - Is this possible?

2011-04-25 Thread Shawn Milochik
If your __init__ method of the form reads the contents of the data kwarg and adds to self.fields then you can validate the additional fields. If your form has a prefix you have to ensure that the dynamic fields that get passed in the POST also have the same prefix. However, this allows an attacke

Re: Dynamically form modification - Is this possible?

2011-04-25 Thread Shawn Milochik
I was assuming you'd use JavaScript to dynamically add elements to the DOM during the user experience. How else would you do it? Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroup

Re: Dynamically form modification - Is this possible?

2011-04-25 Thread Shawn Milochik
There are two pieces to this. 1. The Django form. 2. Whatever comes back in your HTML form's POST. Your Django form will have zero or more fields in it. Your HTML form will POST back those fields (if any) and possibly new ones. Your Django form's __init__ will read the 'data' keyword arg

Re: How i connect my PostgreeSQL to a Django?

2011-04-26 Thread Shawn Milochik
What error are you getting? -- 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 op

Re: Is there a more basic tutorial?

2011-04-26 Thread Shawn Milochik
This has nothing to do with Django. This is a Web design question. Try a mailing list about HTML and/or CSS. Mostly CSS. 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. T

Re: User Profile and Form initial values

2011-04-26 Thread Shawn Milochik
If you're creating a ModelForm that already has data in the database, don't pass in request.POST. Instead, pass in the instance with the 'instance' keyword argument. For example, if it was a ModelForm for the User object: form = UserForm(instance = request.user) -- You received this messa

Re: User Profile and Form initial values

2011-04-26 Thread Shawn Milochik
On 04/26/2011 06:04 PM, Kenny Meyer wrote: On Tue, Apr 26, 2011 at 4:17 PM, Shawn Milochik wrote: If you're creating a ModelForm that already has data in the database, don't pass in request.POST. Instead, pass in the instance with the 'instance' keyword argument. For

Re: User Profile and Form initial values

2011-04-26 Thread Shawn Milochik
Yeah, it's documented. Right at the tippy-top of the ModelForms docs. http://docs.djangoproject.com/en/1.3/topics/forms/modelforms/ -- 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

Re: sqlite3 and south data migration

2011-04-27 Thread Shawn Milochik
On 04/27/2011 05:22 AM, Amit Sethi wrote: Hi all does sqlite3 not support data migration. I am trying to implement migration on my test fixtures using south however i get this particular error : AttributeError: 'DatabaseFeatures' object has no attribute 'supports_tablespaces' Not all feature

Re: Unexpected error

2011-04-27 Thread Shawn Milochik
If you know how to cause this error, run manage.py shell and import or instantiate whatever you have to in order to make this happen. The traceback you get there will be more useful. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To po

Re: Javascript frameworks with Django

2011-04-27 Thread Shawn Milochik
In my experience you almost definitely do want to take advantage of templates. It makes things a lot easier. Simple example: A main template (including things like the and tags and doctype). A detail template that just includes, say, a table of results. In action: The user ta

Re: Running Django tests from Python

2011-04-27 Thread Shawn Milochik
I figure it's been long enough that I can bump this post. I'm currently using subprocess to do this. There must be an easy way to simply invoke the tests from within Python. So, how do you (within Python), do the equivalent of the following?: ./manage.py test myapp1, myapp2, myapp3 Thanks,

Re: Running Django tests from Python

2011-04-27 Thread Shawn Milochik
Sorry, I realize that last post is missing the context of the original question. Please see this: https://groups.google.com/d/topic/django-users/-4f3J1bJ10k/discussion Thanks, Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: Running Django tests from Python

2011-04-27 Thread Shawn Milochik
On 04/27/2011 04:06 PM, Kenny Meyer wrote: Hi Shawn, http://docs.djangoproject.com/en/dev/ref/django-admin/#running-management-commands-from-your-code Does this answer your question? Kenny Kenny, This is *exactly* what I was looking for. Unfortunately it doesn't work. It keeps saying that

Re: Running Django tests from Python

2011-04-27 Thread Shawn Milochik
On 04/27/2011 04:06 PM, Kenny Meyer wrote: Hi Shawn, http://docs.djangoproject.com/en/dev/ref/django-admin/#running-management-commands-from-your-code Does this answer your question? Kenny Never mind. More pdb action and I figured out that I had overwritten DJANGO_SETTINGS_MODULE at the bas

Running tests automatically as you work.

2011-04-27 Thread Shawn Milochik
http://dpaste.com/hold/536487/ I cobbled this little script together that monitors my project folder and runs tests every time a .py file is saved. I'm sharing it in case anyone is interested. Feedback is welcome, of course. Interesting bits: pyinotify: This module plugs into kernel noti

Re: Transform words into links with regex

2011-04-28 Thread Shawn Milochik
You need to use mark_safe. Otherwise Django will be protecting you from potential malicious input. http://docs.djangoproject.com/en/1.3/ref/utils/#django.utils.safestring.mark_safe -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to thi

Re: can't create test (secondary) database

2011-04-29 Thread Shawn Milochik
You can specify the test database info (db, name, and password) for each database defined in settings, if you're using 1.2 or greater. http://docs.djangoproject.com/en/1.3/ref/settings/#databases This doesn't help if the same host is being used, but you can get around this by creating a second

Re: Does django 1.3 has a ubuntu deb package released!

2011-04-29 Thread Shawn Milochik
It's always better to download the latest, and use virtualenv. -- 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+unsubs

Re: How do I set permissions for manual install of 1.3 for ubuntu 11.04?

2011-04-29 Thread Shawn Milochik
What's the actual command you're typing, and from which directory? -- 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+un

Re: django uwsgi

2011-04-30 Thread Shawn Milochik
It sounds like your project directory is not on your PYTHONPATH, so when settings tries to import your default urls.py it fails. I'm not familiar with uwsgi, so maybe that's what the addsitedir is supposed to do, but other wsgi files I've seen there's always been a line like sys.path.append(pr

Re: problem installing django 1.3 in virtualenv

2011-04-30 Thread Shawn Milochik
You shouldn't have to. Django should be installed within the virtualenv -- that's kind of the point of virtualenv. You can have any versions of any Python packages (like Django) without any effect on your OS's Python installation or other virtualenvs. -- You received this message because you are

Re: probably a simple query: looping for an integer number within an html page

2011-04-30 Thread Shawn Milochik
This works: {% for val in the_list %} {{ val }} {% endfor %} -- 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

Re: django postgre_psycopg2 error

2011-05-01 Thread Shawn Milochik
Read the traceback you posted. The bottom line tells you exactly where the problem is. -- 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 emai

Re: django postgre_psycopg2 error

2011-05-01 Thread Shawn Milochik
This has nothing to do with Postgres. This is a simple Python issue. Your production machine isn't set up the same as your development machine. -- 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@go

Re: Do any financial firms use a Django framework?

2011-05-03 Thread Shawn Milochik
It seems to me that anyone asking for precedent in their own industry is actually interested in whether Django is considered safe from things like the OWASP Top Ten. They're not interested enough to do the research themselves, so they're going to take an "argument from authority" as evidence

Re: Django Admin template

2011-05-03 Thread Shawn Milochik
You can check out the urls.py in admin and use that to find the view and template. http://code.djangoproject.com/browser/django/trunk/django/contrib/auth?order=name -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send em

Re: Django Admin template

2011-05-03 Thread Shawn Milochik
On 05/03/2011 05:39 PM, roberto wrote: django-google-toolbar ? or django-debug-toolbar ? The latter. The former must have been a typo. https://github.com/robhudson/django-debug-toolbar -- You received this message because you are subscribed to the Google Groups "Django users" group. To pos

Re: Runserver has connection limit?

2011-05-05 Thread Shawn Milochik
Try gunicorn. It's just as easy as runserver, and you just replace 'runserver' with 'gunicorn' in your manage.py command line. The only downside is that it doesn't auto-refresh by default when you change code. However, I'm pretty confident that the core developers have no time or interest in m

Re: How to send notification when reply to a comment?

2011-05-05 Thread Shawn Milochik
http://docs.djangoproject.com/en/1.3/topics/email/ -- 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...@google

Re: Django password reset modification

2011-05-05 Thread Shawn Milochik
This is a bad idea for multiple reasons. Don't do it. -- 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...@goo

Re: not able to use editable=True or false in forms.CharField()

2011-05-05 Thread Shawn Milochik
Unless you want guesses, we'll need to see the code causing the problem. Can you post your models.py (or wherever the 'editable' kwarg is)? Can you also confirm that removing the 'editable' kwarg gets rid of the error? That, along with the code, will help a lot. -- You received this message b

Re: Best practice for async task in django?

2011-05-06 Thread Shawn Milochik
I throw in my +1 for Celery and/or django-celery, plus Rabbit MQ. However, if you want to try something else that's growing in popularity, check out ZeroMQ. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email t

Re: how to use jquery for point of Sale

2011-05-06 Thread Shawn Milochik
On 05/06/2011 11:19 AM, GKR wrote: how to use jquery for point of Sale How to ask an actual question so maybe someone can answer it. -- 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@googlegro

Re: django-voting : How to get objects with number of votes.

2011-05-06 Thread Shawn Milochik
You could probably sort ascending, take a subset, then reverse the search. Something like this: | .order_by('created_datetime', 'modified_datetime')[:100].reverse()| -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, s

Re: django-voting : How to get objects with number of votes.

2011-05-06 Thread Shawn Milochik
Sorry, I was going off of your pasted code. Sounds like this could be a case for annotate. http://docs.djangoproject.com/en/1.3/ref/models/querysets/#annotate I recommend reading this whole page, along with the two prerequisite pages called for at the top. It'll help a lot. -- You received th

Re: how to use jquery for point of Sale

2011-05-06 Thread Shawn Milochik
On 05/06/2011 11:52 AM, Jacob Kaplan-Moss wrote: On Fri, May 6, 2011 at 10:21 AM, Shawn Milochik wrote: How to ask an actual question so maybe someone can answer it. Shawn, that's uncalled-for. I'm super-impressed with how much work Yeah, you're right, of course. I just los

Re: how to use jquery for point of Sale

2011-05-06 Thread Shawn Milochik
On 05/06/2011 11:50 AM, GKR wrote: sorry for that please help me i wanted to add a table and a input text for the purpose of Point Of Sale. So that the id when entered in the textbox will add the item onto the table with other values like rates etc for billing. how can i implement this.. p

Re: Get child model class

2011-05-06 Thread Shawn Milochik
This might work: http://docs.python.org/library/functions.html#isinstance -- 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

Re: Get child model class

2011-05-06 Thread Shawn Milochik
On 05/06/2011 03:32 PM, pbzRPA wrote: I now the isinstance function but that will return the CF class. I want to know the child class of CF for that specific primary key. The isinstance function doesn't return a class. It returns a boolean, based on the class(es) you are inquiring about. Yo

Re: ajax select box

2011-05-07 Thread Shawn Milochik
You'll need to write JavaScript. Specifically: Write a function that uses AJAX to pass the state to a Django view and receive the city list, then populate the city drop-down. Bind that function to the change event of your state drop-down box. This isn't a Django question, though. If

Re: Instantiate a model using a string (or a dict)??

2011-05-08 Thread Shawn Milochik
You can do it with a dictionary. Just pass it using **kwargs. -- 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+unsubsc

Re: curl pages behind login_required

2011-05-08 Thread Shawn Milochik
Do a Google search on using cookies in curl. On May 8, 2011 4:17 PM, "CarlFK" wrote: > I am trying to curl pages that require being logged in via django's > default auth. I don't care if the actual login is done with curl, > python, firefox or whatever is easiest. > > This only works sometimes, so

Re: curl pages behind login_required

2011-05-08 Thread Shawn Milochik
And just to be clear, I wasn't saying go away. I think you can authenticate completely in curl. If not you can in wget. -- 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 unsubs

Re: Many2many field and ModelChoiceField

2011-05-09 Thread Shawn Milochik
You can exclude that field from your ModelForm and manually add in a new field with just the option(s) you want. Then override the save() of your ModelForm to set the proper value of self.cleaned_data or self.instance to the value from your custom field. -- You received this message because

Re: Encrpting urls to hide PKs

2011-05-09 Thread Shawn Milochik
There's no need to change your models to add UUIDs. You can just store a dict of UUID-to-primary key values in the session data. -- 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.

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread Shawn Milochik
http://docs.djangoproject.com/en/1.3/ref/contrib/admin/ Check out 'fields' and 'exclude.' -- 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: How to deal with an auto-incrementing primary key

2011-05-10 Thread Shawn Milochik
What's your model look like? Did you add the foreign_key = True kwarg to the field in question? -- 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,

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread Shawn Milochik
I think the problem is that you used IntegerField instead of AutoField. http://docs.djangoproject.com/en/1.3/ref/models/fields/#autofield However, why even bother? Why not get rid of that field and use the built-in id field that you're going to get from a Django model? There's no benefit at al

Re: How to deal with an auto-incrementing primary key

2011-05-10 Thread Shawn Milochik
If you don't mind losing all your data you can destroy the database then do syncdb. If you re-run syncdb without re-creating the database then it will do nothing for existing tables. You can use South[1] if you need to keep your data intact. [1] http://south.aeracode.org/ -- You received th

Logging view exceptions: A tip and a question.

2011-05-10 Thread Shawn Milochik
Tip part 1: I just learned about the awesome logging.exception function today. Instead of a logger.error or logging.debug, you can call logging.exception (if you're in the "except" of a try/except block), and it will automatically include the stack trace. This is super-helpful, especially now

Re: Where are request.user defined and assigned?

2011-05-10 Thread Shawn Milochik
The User model is in django.contrib.auth, not in the core of Django. request.user is dealt with in the middleware that comes with the auth module. http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/middleware.py -- You received this message because you are subscribed to t

How do you apply a decorator to all views in a views.py file?

2011-05-10 Thread Shawn Milochik
I have a decorator I'd like to apply to every view in a given views.py file. Is there an elegant way to do that in Django? I searched Google and the docs but didn't find anything. So, I wrote some code which works and demonstrates what I'm trying to do, but it's really ugly. http://dpaste.com

Re: Where are request.user defined and assigned?

2011-05-10 Thread Shawn Milochik
On 05/10/2011 04:00 PM, Andy wrote: Thank you. So LazyUser is there to cache the user instance. Not exactly. It appears to be 'lazy' in that it doesn't actually do a database lookup to get the user until it has to. Read the LazyUser code and you'll see. In LazyUser(object), the user instanc

Re: Decimal * Float problem

2011-05-10 Thread Shawn Milochik
What error do you get? You should be able to import Decimal then do: discount = Decimal('0.65') -- 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,

Re: Can django admin log be trusted?

2011-05-10 Thread Shawn Milochik
For what it's worth: Regardless of logging you should be able to identify any gaps in the table's primary keys. Your database should guarantee that. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to dja

Re: How do you apply a decorator to all views in a views.py file?

2011-05-10 Thread Shawn Milochik
On 05/10/2011 05:15 PM, Jason Culverhouse wrote: http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-exception Jason, That's perfect. I didn't know about process_exception. I asked about using middleware for this earlier today on this list, but nobody replied to that one. So

Re: Can django admin log be trusted?

2011-05-10 Thread Shawn Milochik
On 05/10/2011 05:59 PM, Paweł Roman wrote: You're right, I've just checked it and there's a gap for 100+ ids, so he must be right. Two things. One won't help you (this time), but the other will. 1. I have a post_save signal listener and I dump the info about each model instance with a timesta

Re: Can django admin log be trusted?

2011-05-10 Thread Shawn Milochik
On 05/10/2011 09:11 PM, Venkatraman S wrote: @Shawn : can you elucidate on how your system with MongoDB performs? -V If you mean what is the performance penalty I couldn't really say. Our user-base is fairly small, so I don't know what the penalty is. If you want to know how it works, it's r

Re: django-simple-history

2011-05-10 Thread Shawn Milochik
The official answer is that you can't unless you rewrite everything to accept 'user' as a keyword-argument and then pass it from all your views. The dirty, wicked, reviled answer is to use threadlocals, but don't do that* or all the kids will laugh at you and you won't have any friends. Shawn

Re: Logging view exceptions: A tip and a question.

2011-05-11 Thread Shawn Milochik
On 05/11/2011 09:57 AM, Venkatraman S wrote: My response is more along the lines of performance gain - why not use asynchronous logging? I havent used logging extensively, but is the default logging scheme in scheme synchronous? -V This was already answered by a couple of people yesterday

Re: Django Admin site and password field

2011-05-11 Thread Shawn Milochik
It sounds like you're not using the built-in Django admin, which would make your life easier. Assuming you want to do it the hard way, you can just use a PasswordInput widget. http://docs.djangoproject.com/en/1.3/ref/forms/widgets/ -- You received this message because you are subscribed to t

Re: DecimalFields, Floats, and Strings?

2011-05-11 Thread Shawn Milochik
On 05/11/2011 03:01 PM, Nan wrote: Using Django 1.2.3, I recently declared a DecimalField on a model, and it happily accepts a float as its default value, but it won't filter on a float (it throws a TypeError instead). Is there a reason for this inconsistency? DecimalField subclasses Field, w

Re: DecimalFields, Floats, and Strings?

2011-05-11 Thread Shawn Milochik
On 05/11/2011 05:26 PM, Nan wrote: Yeah, I'm aware of the distinction between the types -- just wasn't paying enough attention when I added the default and the filter, and had to back up and take a second look when the filter started throwing exceptions. So basically it's a weird artifact of how

Re: Overide error messages in models

2011-05-12 Thread Shawn Milochik
On 05/12/2011 08:08 PM, Daniel França wrote: no way? I'll need to create new model forms? 2011/5/12 Daniel França Hi all, I need to override error messages (like for required fields) directly in Models, I don't wanna duplicate code declaring some fields again in forms, and in some cases I don'

Re: Overide error messages in models

2011-05-12 Thread Shawn Milochik
On 05/12/2011 09:35 PM, Daniel França wrote: I wanna change the error messages without to need to rewrite fields code, to be more specific I want to translate them... Did you try setting the error_messages value? http://docs.djangoproject.com/en/1.3/ref/forms/validation/#using-validators The

Re: Change select to a form in a ForeignKey relationship

2011-05-13 Thread Shawn Milochik
To do that you need to add a Meta to your ModelForm and exclude the address. Then add another ModelForm for Address and put both on the page at the same time. Then, after the POST, you'll need to first save the address and then add it to the cleaned_data of the employee form (or its self.insta

Re: connection lost with concurrent transactions

2011-05-13 Thread Shawn Milochik
Are you using RabbitMQ as a backend? We're using both Celery and django-celery successfully with Django + Postgres and I've never seen the issue you describe. We do all our Celery stuff asynchronously, since the main point (for us) is to have the user's page load time as short as possible. Sh

Re: Change select to a form in a ForeignKey relationship

2011-05-13 Thread Shawn Milochik
On 05/13/2011 04:22 PM, Guevara wrote: Thank you shaw! You're welcome. Note that there's no reason to add 'commit = True' when saving the address -- that's the default. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this g

Re: Why is request.session.flush() deleting my objects from DB?

2011-05-13 Thread Shawn Milochik
Given that logging a user out calls flush(), I don't believe that's what's deleting your data. Otherwise everyone using contrib.auth would be complaining. What data is being deleted? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: MEDIA and STATIC in a nutshell?

2011-05-13 Thread Shawn Milochik
Did you read the docs? http://docs.djangoproject.com/en/1.3/ref/contrib/staticfiles/ To use the staticfiles app you need to not only put the right things in settings.py, but also run manage.py collectstatic to gather up all your static content, then rsync/copy/whatever that content to the prope

Re: MEDIA and STATIC in a nutshell?

2011-05-14 Thread Shawn Milochik
It sounds like all your issues with these features are a result of not reading the documentation. Feel free to ignore these optional features and do things the hard way if you feel like it. On the other hand, you could invest a small amount of time in understanding them and get the benefits.

Re: Django app models

2011-05-14 Thread Shawn Milochik
All you should need is for the external app to be somewhere on your PYTHONPATH. Then you can add it to INSTALLED_APPS in settings.py and you'll be all set. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to d

Re: Django app models

2011-05-14 Thread Shawn Milochik
On 05/14/2011 04:25 PM, augdawg wrote: I can add it to my PYTHONPATH by doing 'export PYTHONPATH=""' right? Yes, but you might want to just append it to your PYTHONPATH, in case there's already something there you don't want to lose. Like this: export PYTHONPATH=$PYTHONPATH; Maybe even pu

Re: form new versus edit

2011-05-14 Thread Shawn Milochik
On 05/14/2011 05:04 PM, Greg Donald wrote: I have a "new" contact form. If I post it, and it has error, I found (while debugging, not documented that I can find) that I can redraw the submitted form data using form.name.data like this: The problem is that you're doing this at all. You shoul

Re: form new versus edit

2011-05-14 Thread Shawn Milochik
On 05/14/2011 05:14 PM, Greg Donald wrote: On Sat, May 14, 2011 at 4:08 PM, Shawn Milochik wrote: On 05/14/2011 05:04 PM, Greg Donald wrote: I have a "new" contact form. If I post it, and it has error, I found (while debugging, not documented that I can find) that I can redraw the

Re: form new versus edit

2011-05-14 Thread Shawn Milochik
On 05/14/2011 05:33 PM, Greg Donald wrote: On Sat, May 14, 2011 at 4:22 PM, Daniel Roseman wrote: Which is what Shawn said. If you follow the pattern described in the excellent documentation, you'll see that there's no reason to try and reference the form's data, as the form will re-render itse

Re: form new versus edit

2011-05-14 Thread Shawn Milochik
On 05/14/2011 05:47 PM, Greg Donald wrote: On Sat, May 14, 2011 at 4:39 PM, Shawn Milochik wrote: I'm certain there are plenty of reasons that others could chime in with. In any case, you're free to do it however you like. But if you choose to use Django, be aware of the fact t

Re: form new versus edit

2011-05-14 Thread Shawn Milochik
On 05/14/2011 06:09 PM, Greg Donald wrote: On Sat, May 14, 2011 at 4:58 PM, Shawn Milochik wrote: > This isn't a case of "our way rules and if you disagree then you > suck." I just wanted to make sure you don't walk away with that > impression. How can I set

Re: Am I over-normalizing?

2011-05-14 Thread Shawn Milochik
On 05/14/2011 06:50 PM, bendavis78 wrote: I have a database of patients ("Patient" model), and a patient can have subordinate accounts which is a self-foreign-key (eg, for family members), We also store multiple addresses for each patient (home, work, billing). I'm pretty sure I need to have a

Re: MEDIA and STATIC in a nutshell?

2011-05-14 Thread Shawn Milochik
Eiji, If you put a folder in each app named 'static' it will automatically be used when you run 'manage.py collectstatic.' You only need to specify additional directories if you want to pull static media from somewhere else, of if you named your static folders something other than 'static' i

Re: existing data failing validation

2011-05-14 Thread Shawn Milochik
On 05/14/2011 07:51 PM, Greg Donald wrote: How does one handle non-changing existing data when updating a form? My 'add' form includes several fields my 'edit' form does not. For example once I create a contact and assign it a company_id foreign key, it will never change. So when I implement m

Re: MEDIA and STATIC in a nutshell?

2011-05-14 Thread Shawn Milochik
Eiji, Sorry to hear about the Japanese translation being out-of-date. I just checked and saw that it's extremely old. The development of Django moves too quickly to rely on static documentation. I don't know of any alternatives to the English version if you want to remain current, but in any

Re: existing data failing validation

2011-05-14 Thread Shawn Milochik
On 05/14/2011 08:09 PM, Greg Donald wrote: I have from django.db import models from django.forms import ModelForm class Contact( models.Model ): company = models.ForeignKey( Company ) name = models.CharField( max_length=32 ) class ContactForm( ModelForm ): class Meta:

Re: Problems importing model classes that reference each other...

2011-05-14 Thread Shawn Milochik
If you have two models that need to explicitly refer to each other then they should probably be in the same app. If they need to be in two apps, you can have a foreign key in one and from the other use the RelatedManager to access the first. You'll have to make these decisions based upon what

Re: How change field to "unique" in existing mysql database?

2011-05-14 Thread Shawn Milochik
The best way is to use South. http://south.aeracode.org/ In your current situation, after you install South (pip install then add to INSTALLED_APPS, and syncdb to add the South table) you'll just have to do this: 1. manage.py convert_to_south appname #this will set up the basics, you'll

Re: existing data failing validation

2011-05-15 Thread Shawn Milochik
I think the reason you're getting the error you are is that you didn't add 'company' to 'exclude' in your modelform. The code you pasted indicates that you will have an existing object 100% of the time in this view. If that's the case, your line to instantiate the form with request.POST and th

Re: PyStack and Djangoverflow

2011-05-15 Thread Shawn Milochik
On 05/15/2011 04:27 AM, Jonathan Endersby wrote: Hi If you're on Twitter you might want to follow these two feeds of highly rated Python and Django questions from Stack Overflow. http://twitter.com/#!/djangoverflow and http://twitter.com/#!/pystack Thanks. We'll see how much more of my time

<    3   4   5   6   7   8   9   10   11   12   >