Re: newbie doubt about editing an objects field

2010-02-24 Thread Shawn Milochik
There's no need to pass 'instance' if you're instantiating your ModelForm with request.POST. You only need to pass the instance if you already have a specific model instance programmatically and want to get a ModelForm for it. You can replace if request.method=='POST': with if request.POST: Add

Re: need help in multy db.

2010-02-24 Thread Shawn Milochik
Multi-DB support doesn't exist in 1.1 -- only 1.2 (still in beta). The "managed" attribute in the Meta tells Django whether it should handle the model with its ORM. The default is True. If it's True, Django will make a database table for that model. If not, Django's ORM won't do anything to the

Re: how to capture the exception

2010-02-24 Thread Shawn Milochik
Note: As written, your code will never let you edit an existing Article. You should add an if statement to check whether 'self.pk' is true also. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to djang

Re: schema migration

2010-02-25 Thread Shawn Milochik
The way to go is South: http://south.aeracode.org/ Shawn On Feb 24, 2010, at 11:51 PM, vishal d wrote: > Hi to all > > Am new to django...plz suggest me which is the better one for the > schema migration for django apps > > Thanks in advance > > vishal > 2009vis...@gmail.com > > -- > Yo

Re: Banned from the #django irc channel

2010-02-26 Thread Shawn Milochik
Have you tried different clients? Have you tried posting in different Freenode chat rooms? Is your account an authenticated one with Freenode? 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-

Re: Banned from the #django irc channel

2010-02-26 Thread Shawn Milochik
I asked in the IRC, but nobody answered. There seemed to be almost no activity at all, though. Maybe someone who's associated with the room will see this thread and help. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: Django book

2010-03-01 Thread Shawn Milochik
I highly recommend "The Definitive Guide," second edition. Then you'll know 1.1, and then learning the new stuff in 1.2 will be easy enough from the online docs. The transition from 1.1 to 1.2, although it adds new functionality, doesn't change enough to require you to re-learn everything. Sh

Re: Permissions to see a view

2010-03-02 Thread Shawn Milochik
Step 1: docs.djangoproject.com Step 2: mailing list. You skipped step 1: http://docs.djangoproject.com/en/1.1/topics/auth/#limiting-access-to-logged-in-users-that-pass-a-test Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to th

Re: Update a single column of a row in a Model

2010-03-02 Thread Shawn Milochik
Use a forms.ModelForm and exclude all the fields except one, or use a forms.Form with one field and use its value in a queryset .update() call. Shawn Sent from my iPhone On Mar 2, 2010, at 7:11 PM, Ken wrote: Folks This is a bit of a newbie question on Model updates. I've been happily

Re: "ImportError: No module named django" with MacPorts

2010-03-03 Thread Shawn Milochik
Please post the results of these commands: which python python -V You can have different versions of Python installed (or even the same version) in multiple places on your Mac. The most likely situation is that when you're trying to actually run things you're using different version of Pyth

Re: "ImportError: No module named django" with MacPorts

2010-03-03 Thread Shawn Milochik
Printing sys.modules won't show django unless you've imported Django. What are you trying to do, anyway? You don't normally import Django in a Python script. You usually start a Django project by using django-admin.py and letting it create a manage.py which uses the proper Python. Search your s

Re: Templates sometimes load at bottom of page

2010-03-03 Thread Shawn Milochik
Dude, I have one word for you, and you've heard it already tonight: virtualenv I do everything on my Mac, and virtualenv and git make it a lot easier than I deserve. Let me know if you need help. Shawn On Mar 3, 2010, at 9:28 PM, timdude wrote: > I know I should do it. But I'm such a noob, t

Re: how to audit which user made changes

2010-03-04 Thread Shawn Milochik
This helped me: http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser 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-us...@googlegroups.com. To unsubscribe from this group, send email

Re: Update a single column of a row in a Model

2010-03-04 Thread Shawn Milochik
Here's a simple example. It could be improved, but it's meant to be very simple. #Make a simple form. class AgeForm(forms.Form): age = forms.IntegerField() #When the user submits the form: age_form = AgeForm(request.POST) if age_form.is_valid() #get the pk however you need to

Re: Update a single column of a row in a Model

2010-03-04 Thread Shawn Milochik
; Would that work...? I'll attempt to hack an example in my code and > tell you what happens... > > Thanks for your time... > > Ken > > > On 4 Mar, 17:28, Shawn Milochik wrote: >> Here's a simple example. It could be improved, but it's meant to be v

Re: shortest way to recover from a QuerySet "object not found"

2010-03-04 Thread Shawn Milochik
Just create your own Manager and override the default (named 'objects') in your models. Have 'get' behave any way you like. http://docs.djangoproject.com/en/1.1/topics/db/managers/ Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post

Re: build URL based on fields for admin change form

2010-03-04 Thread Shawn Milochik
Get the URL, preferably by using an absolute_url method of the model. Then do something like this: from urllib import urlencode attrs = { 'latitude': address.latitude, 'longitude': address.longitude, } map_link = "%s?%s" % (urlencode(attrs),) Shawn On Mar 4, 2010, at 5:

Re: shortest way to recover from a QuerySet "object not found"

2010-03-04 Thread Shawn Milochik
If the question is answered to your satisfaction, why don't we drop the thread now and avoid the personal stuff? There is nothing to be gained by arguing with a respected core Django developer, and nothing the rest of us will learn from it. Thanks, Shawn -- You received this message because

Re: Sqlite3, saving many items simultaneosly

2010-03-05 Thread Shawn Milochik
Yes. Look at the syntax for executemany() (as opposed to execute()). 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-us...@googlegroups.com. To unsubscribe from this group, send email to django

Re: InternalError: current transaction is aborted, commands ignored until end of transaction block PROBLEM

2010-03-07 Thread Shawn Milochik
Please provide the least amount of code possible to duplicate this problem. Saying "when I try to user raw SQL commands it breaks" is kind of like telling a mechanic "my engine is making a funny noise." Where does the noise come from? Does it happen only when the engine is running? Does i

Re: django & wsgi: what is the preferred webserver?

2010-03-07 Thread Shawn Milochik
Have a look here: http://code.djangoproject.com/wiki/ServerArrangements In general, you should have two Web servers (e.g. Apache and nginx or lighttpd). Apache (with mod_wsgi) to serve Django and nginx or lighttpd to serve the static files (CSS, JavaScript, images, etc.). I'm not an expert

Re: is there any possibility for two settings.py

2010-03-07 Thread Shawn Milochik
Just specify an argument for --settings when you launch the server for each instance. example (development): ./manage.py runserver --settings=myproject.myapp.special_settings Sawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: is there any possibility for two settings.py

2010-03-08 Thread Shawn Milochik
You can definitely do this. Say you have a project called myproject, and apps named app1 and app2. You can do this (development example -- don't use runserver in production): ./manage.py runserver --settings=myproject.app1.settings 127.0.0.1:8080 ./manage.py runserver --settings=myproject.a

Re: how to start with django

2010-03-08 Thread Shawn Milochik
It all depends. Do you have a specific project you would like to develop with Django, or do you just want to generally learn how to use it for projects you haven't thought of yet? If you know exactly what you want to do, read "The Definitive Guide to Django, Second Edition" (cover to cover)

Re: How to get current session user in models.py?

2010-03-09 Thread Shawn Milochik
I wonder if this is something that might end up in Django as a built- in feature at some point. It comes up regularly on this list. Here's what I used. It's a hack, but it works. http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser Shawn -- You received this message because you are

Re: Not able to view the admin page through the browser

2010-03-09 Thread Shawn Milochik
Something is broken in your code. If you set DEBUG = True, you'll find out what. But since it's False, it is hiding that information for security reasons. It tries to display an error page to the browser, and it expects a template to exist called 500.html to show to your poor, out-of-luck u

Re: How to get current session user in models.py?

2010-03-09 Thread Shawn Milochik
On Mar 9, 2010, at 10:37 AM, James Bennett wrote: On Tue, Mar 9, 2010 at 8:47 AM, Shawn Milochik wrote: I wonder if this is something that might end up in Django as a built-in feature at some point. It comes up regularly on this list. Were I to sit here all morning doing nothing but

Re: Django server side ajax vallidation

2010-03-09 Thread Shawn Milochik
On Mar 9, 2010, at 12:19 PM, MMRUser wrote: Is there no one??? Nobody who wants to do your work for you? Maybe. Especially when you end your e-mail with "Your valuable corporation [sic] is expected." Perhaps, if you write a short, easy-to-read e-mail with a very clear question that can

Re: Django editor for Debian

2010-03-10 Thread Shawn Milochik
I did a little looking into this, and it seems like SPE (Stani's Python Editor) is the best pick for Ubuntu. It has been around for years and has remained popular. It's also specifically designed (obviously) for Python. Shawn -- You received this message because you are subscribed to the Googl

Re: ModelForm+datepicker

2010-03-10 Thread Shawn Milochik
Here you go: http://docs.djangoproject.com/en/1.1/ref/forms/widgets/ (Try searching http://docs.djangoproject.com/ before Google. It's really a great reference.) Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, s

Re: need help in multi db

2010-03-10 Thread Shawn Milochik
Go to google.com. Search for this: multi-database support in django You will find that the first result is from a page on code.djangoproject.com which directly discusses this and links to the usage documentation. Note that this feature is currently in beta, and will be officially released as p

Re: ModelForm+datepicker

2010-03-10 Thread Shawn Milochik
The widget has nothing to do with the model. It needs to be specified in your forms.Form or forms.ModelForm. Remember that the model is all about the database table and the form is all about the HTML form. Shawn -- You received this message because you are subscribed to the Google Groups "Dj

Re: overriding saving fails in loop

2010-03-10 Thread Shawn Milochik
Every time you save(), you call makeOrder(). Every time you run makeOrder(), you call save(). You've introduced an infinite loop. Well, infinite until Python decides enough is enough. One simple possibility is to add an optional argument with a default of True to the save() override that determ

Re: why is __exact filter really doing an inexact match?

2010-03-10 Thread Shawn Milochik
What database are you using? 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For

Re: overriding saving fails in loop

2010-03-10 Thread Shawn Milochik
I think you missed my point, or I explained it badly. 1. In makeOrder, change i.save() to i.save(reorder = False). 2. Change the save function to something like the following (untested): def save(self, *args, **kwargs): do_ordering = kwargs.pop('reorder', True) super(Subject, s

getting request.user from a signal

2010-03-11 Thread Shawn Milochik
Yes, this is essentially the same topic that was discussed here: http://groups.google.com/group/django-users/browse_thread/thread/44ced967d9da3500 However, there has not yet been an answer, and I think this particular (and probably common) use-case renders the "write a function that accepts a

Re: Adding Fields To Querysets

2010-03-11 Thread Shawn Milochik
Maybe I'm missing something in your requirements, but I think the example in the Manager docs does exactly that: http://docs.djangoproject.com/en/1.1/topics/db/managers/#adding-extra-manager-methods It demonstrates adding an extra field (calculated from the data in the database row) to the r

Re: I need django-evolution app

2010-03-12 Thread Shawn Milochik
South has become the dominant DB migration tool for Django. Have a go at that. http://south.aeracode.org/ 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-us...@googlegroups.com. To unsubscrib

Re: object has no attribute 'count'

2010-03-15 Thread Shawn Milochik
If you're doing a 'get,' then you're always going to return exactly one results (or get an error). If you do a 'filter' you can use count(). 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-us

Re: Tesing in Django and python

2010-03-15 Thread Shawn Milochik
http://docs.djangoproject.com/en/1.1/topics/testing/ http://docs.python.org/library/unittest.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this gro

Re: Question about request.POST.get('subject', ' ')

2010-03-23 Thread Shawn Milochik
This is a Python question, not a Django question. The Python dictionary get() function accepts a second, optional value to use as the default for what would otherwise raise a KeyError. Shawn Sent from my iPhone On Mar 24, 2010, at 1:39 AM, Daniel wrote: Hi there, I'm reading the django

Re: How verbose model name in admin panel

2010-03-24 Thread Shawn Milochik
The verbose name options you show should work, but they should be in a meta class within the main model. Example: class Category(models.Model): #your stuff here class Meta: verbose_name = "Kategoria" verbose_name_plural = "Kategorie" Shawn -

Re: Simple export of CSV

2010-03-24 Thread Shawn Milochik
Have your 'export' button make an AJAX call to a view, which creates the CSV file and prompts the user to 'Save As.' Details: 1. Use the same view you currently have, with an 'if' statement which returns a standard (html) response or a CSV file based on a slug in your URL. 2.

Re: Overriding admin Media class

2010-03-24 Thread Shawn Milochik
> >> The problem is you are defining get_class as >> an instance method and trying to call it is a class method (or static >> method). > > Sorry, I have no idea what you're referring to here, and Googling for > static vs. class methods is not turning up anything I can understand. > Can you show w

Re: ForeignKeyField

2010-03-25 Thread Shawn Milochik
This should help: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#raw-id-fields 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-us...@googlegroups.com. To unsubscribe from this group, s

Re: Converting cleaned ModelMultipleChoiceField to a list of ids

2010-03-27 Thread Shawn Milochik
On Mar 28, 2010, at 1:16 AM, Wilberoni wrote: > > ModelMultipleChoiceField in a form takes a queryset to load the > selectable items. > > volunteers = > forms.ModelMultipleChoiceField( queryset=VolunteerProfile.objects.all ) > > In save(), I call cleaned_data to get the items that were sel

Re: Hosting for Django sites

2010-04-03 Thread Shawn Milochik
+1 for Webfaction also. I've only had to use customer service once and they were unhelpful, but the way the hosting site is set up make it trivial to create new Django apps, subdomains, and static sites for media URLs. For slightly less than I used to pay for fairly simplistic hosting that cou

Re: database engine problem

2010-04-05 Thread Shawn Milochik
Read the error you posted -- especially the last couple of sections, which repeatedly tell you exactly what the problem is. Shawn #kettlebell On Apr 6, 2010, at 12:29 AM, yangyang wrote: I followed the tutorial and set up the database engine as SQLight and it seemed to be successful. Howev

Re: Error when following the tutorial

2010-04-07 Thread Shawn Milochik
Your poll app is not in INSTALLED_APPS properly. What does INSTALLED_APPS look like in your settings.py? What does your directory structure look like, starting with the directory in which you ran startproject? Shawn -- You received this message because you are subscribed to the Google Groups

Re: Error when following the tutorial

2010-04-07 Thread Shawn Milochik
Off of the top of my head that looks correct. Perhaps there's a problem with your PYTHONPATH. Try to echo $PYTHONPATH and see what you get. See if anything in your home directory is in there, and whether the fact that you have a subdirectory with a name identical to it's parent directory could

Re: Error when following the tutorial

2010-04-07 Thread Shawn Milochik
On Apr 7, 2010, at 4:53 PM, TheNational22 wrote: > I have added /home/crossen/crossen to the python path, and I am still > getting the errors Okay, but do the directories you've added to the path contain __init__.py files? (zero-byte is fine, they just have to be there) -- You received this m

Re: Error when following the tutorial

2010-04-07 Thread Shawn Milochik
nal22 wrote: > sorry, that should've read home/kevin/crossen > > > On Apr 7, 4:57 pm, TheNational22 wrote: >> Yes /home/crossen/crossen has the init and so does polls >> >> On Apr 7, 4:55 pm, Shawn Milochik wrote: >> >> >> >>> On

Re: installing django

2010-04-11 Thread Shawn Milochik
Your problem (and solution) are described here: http://groups.google.com/group/django-users/browse_thread/thread/c9ff6c7c8e13e32b/54fb2f345b642188?hl=en&lnk=gst&q=django-admin.py+path#54fb2f345b642188 -- You received this message because you are subscribed to the Google Groups "Django users" g

Re: TemplateDoesNotExistError makes no sense

2010-04-11 Thread Shawn Milochik
On Apr 11, 2010, at 5:22 PM, David Zhou wrote: > On Sun, Apr 11, 2010 at 4:26 PM, Dexter wrote: > >> I have a server running with primarily nginx and secundary apache2, >> And I am getting an template error trying to browse an app. It seems it >> cannot find a template, but it is certainly ther

Re: Retrieving values of checked boxes as a csv string

2010-04-11 Thread Shawn Milochik
http://docs.djangoproject.com/en/1.1/ref/forms/fields/#booleanfield -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+u

Re: installing Django / building a website

2010-04-12 Thread Shawn Milochik
First off, you should know Python a bit before you start trying to use Django. Otherwise you'll keep asking "how do I do X in Django," when what you really want to know is how to do it in Python. http://docs.python.org/tutorial/index.html Secondly, start with the official documentation, which is

Re: Installing django

2010-04-14 Thread Shawn Milochik
The instructions on the site are incorrect. You only use django-admin.py to create the project. After that you use manage.py for everything else -- including syncdb. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Installing django

2010-04-14 Thread Shawn Milochik
Actually, since you seem to have already installed Django successfully, I suggest you dump that faulty page and use the official tutorial. http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01 Shawn -- You received this message because you are subscribed to the Google Groups

Re: Problem with encoding in unit tests

2012-02-12 Thread Shawn Milochik
How did you get the name into your fixtures? Did you type it in manually, or enter it in Django admin and then use dumpdata? It looks like the value in your fixtures got its encoding mangled. It should work properly if the unicode is correct in your database and you use manage.py dumpdata to d

Re: Custom constraints on User fields

2012-02-13 Thread Shawn Milochik
You can override and customize the forms, then manually add the unique indexes to your database. Django doesn't provide much index functionality and adding indexes to your database manually may be required for something like this or performance. Whenever possible update the related code with

Re: Custom constraints on User fields

2012-02-13 Thread Shawn Milochik
On 02/13/2012 03:25 PM, Nicolas Bazire wrote: On Feb 13, 9:16 pm, Shawn Milochik wrote: You can override and customize the forms, then manually add the unique indexes to your database. Overriding the forms is only part of the problem. For instance, forms are not used with

Re: Custom constraints on User fields

2012-02-13 Thread Shawn Milochik
It's probably related to the 80/20 rule. No tool or framework is going to be 100% what you need. Use it for the 80%. When your needs can't be handled by the tool, you can choose to twist yourself into a pretzel within the constraints of the tool or break free and do it the "manual" way -- usual

Re: How can I know when the third multiple is reached in an arbitrarily long list

2012-02-13 Thread Shawn Milochik
You can use the divisibleby template tag in combination with a forloop.counter (both explained on this page): https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#divisibleby -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: Populating a list in a form based on a relationship

2012-02-13 Thread Shawn Milochik
You override the __init__ of the form object and set the .choices property of the form field representing the items. -- 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 unsubsc

Re: Testing: Fixtures vs Factories vs ???

2012-02-17 Thread Shawn Milochik
I don't think there's one true way. In other words, the answer is "all of the above," depending on your project and the needs of each individual test. It also depends on your code. If you've done TDD, and therefore made your code easier to test, you can probably do it the simplest way possibl

Re: Script to call loaddata on multiple fixtures

2012-02-18 Thread Shawn Milochik
Why not just put all those manage.py commands in a shell script and run that? -- 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 dja

Re: Related Objects

2012-02-19 Thread Shawn Milochik
I think what you're looking for is annotate(): https://docs.djangoproject.com/en/1.3/topics/db/aggregation/ -- 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

Re: Associating Form Data with Users

2012-02-19 Thread Shawn Milochik
When you process the form in your view, you'll have access to request.user. Just use that. -- 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: Associating Form Data with Users

2012-02-19 Thread Shawn Milochik
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). Si

Re: I am getting TypeError: coercing to Unicode: need string or buffer, long found. Please help.

2012-02-20 Thread Shawn Milochik
Read the error message 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 em

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 G

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

Re: psycopg2, postgres9.1, Mac OS - problem with psycopg2

2012-02-22 Thread Shawn Milochik
You can either add the proper path of pg_config to your PATH, or just extract the psycopg2 and add the full path to pg_config into the config file it contains then run 'python setup.py install' on the setup.py in the package. -- You received this message because you are subscribed to the Googl

Re: Setup a webserver that handles user input

2012-02-24 Thread Shawn Milochik
Certainly. People do it all the time. https://github.com/ask/django-celery Celery is probably the main way to go, and django-celery makes it super-simple to set up. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send em

Re: Saving Django User in Form

2012-02-24 Thread Shawn Milochik
Read the Django docs about ModelForms, then use the 'exclude' kwarg to exclude the author from your ModelForm. Then, use request.user to get the appropriate user in your view and pass that to the form save(), which you must override to accept the extra argument, and use that user in the save() met

Re: Admin Module

2012-02-25 Thread Shawn Milochik
Check your code to find out what "get_notes_health" is and you'll be 99% of the way to your answer. It's something to do with that, and that's something in your code, not Django itself. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: How do i view json data returned from django

2012-03-01 Thread Shawn Milochik
On 03/01/2012 07:48 AM, Stanwin Siow wrote: Hello, I want to view the actual json data from django view, is there anyway i can do that before i parse it into jQuery? Assuming that you have a dictionary named "return_data," this will do it: return HttpResponse(simplejson.dumps(return_data),

Re: Is it time to start sqlite3 DB from scratch?

2012-03-02 Thread Shawn Milochik
If it's dummy data then you can always wipe it and reset South. There are some issues with sqlite. Not all constraints are enforced and it doesn't support removing fields, for two biggies. So you can't delete a field from a model (the migration will fail), and you can't use the 'unique_togethe

Re: Is it time to start sqlite3 DB from scratch?

2012-03-02 Thread Shawn Milochik
On 03/02/2012 09:55 PM, DF wrote: Thanks. Still not sure how to wipe the database before starting fresh with South. If it's a sqlite database you just delete the file. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, se

Re: Is it time to start sqlite3 DB from scratch?

2012-03-02 Thread Shawn Milochik
You're welcome. To clarify, South is wonderful. It's sqlite that is the problem. The migrations only fail because sqlite doesn't support all normal SQL commands. I love sqlite, but it's not always the best solution. -- You received this message because you are subscribed to the Google Groups "

Re: Problems getting started

2012-03-07 Thread Shawn Milochik
On 03/07/2012 05:21 PM, Andre Terra wrote: Again, don't install as root, use virtualenv. This will save you headaches in the future, and unless you have an inexcusable reason to have Django run as root, you shouldn't. Sincerely, AT +1. Also, there is no excusable reason to need to do it as ro

Re: Problems getting started

2012-03-07 Thread Shawn Milochik
On 03/07/2012 08:58 PM, Andres Reyes wrote: For me, the main reason to use virtualenv has nothing to do with security or anything like that, is the convenience of having different projects with different sets of requirements not interfering with each other It's really all about convenience. N

Outputting JSON in Django logs (98% of the way there!)

2012-03-08 Thread Shawn Milochik
Hi everyone. I'm hoping someone has gotten this working and can point out whatever tiny thing I'm doing wrong here. I want to log JSON instead of the default. I found JsonFormatter here: https://github.com/madzak/python-json-logger It works great with a small script I created based on the exa

[SOLVED] Outputting JSON in Django logs (98% of the way there!)

2012-03-08 Thread Shawn Milochik
It turns out I was just missing quotes around the () for the custom formatter. I just wrote a blog post will a full working example in case anyone else is interested. http://shawnmilo.blogspot.com/2012/03/using-json-logging-in-django-and-python.html -- You received this message because you a

Re: What reason is Django administration

2012-03-08 Thread Shawn Milochik
On 03/08/2012 03:44 PM, Stone wrote: Dear users, I have developed some web pages and I have never used Django administration? Is there any control for controlling access of users? Do you have any examples? Thank you Petr https://docs.djangoproject.com/en/1.3/topics/auth/#permissions -- Yo

Re: signals

2012-03-10 Thread Shawn Milochik
You can do exactly that by specifying a sender: https://docs.djangoproject.com/en/1.3/topics/signals/#connecting-to-signals-sent-by-specific-senders Also, note that the sender is available in the receiver because it's always the first argument sent by the signal, so you can have a function tha

Re: Multiple Choice Quiz

2012-03-11 Thread Shawn Milochik
On 03/11/2012 02:13 PM, jbr3 wrote: I've gone through the tutorial. But I would just like to get a general idea of the best way to incorporate all these elements so I can save and reuse them. What have you tried, and what specific issues have you run into? If you ask a question and nobody se

Re: Multiple Choice Quiz

2012-03-11 Thread Shawn Milochik
I think I'd do this: Models: Question question text Answer question foreign key answer text correct (boolean) Guess user foreign key answer foreign key That should be all you need (along with the User model or your own method of tra

Re: Batch processing in parallel (celery)

2012-03-12 Thread Shawn Milochik
You can just use Celery. It's very simple if you use django-celery and MongoDB as the broker. Next, you could make sure you're using the ORM effectively. Use select_related where possible, avoid doing any querying in loops, pre-pulling data from the database and storing it in memory (in a dic

Re: "Dynamyc" modells

2012-03-12 Thread Shawn Milochik
First, I would avoid using the word 'list' for describing anything in your own data, since it's a Python built-in. Maybe CodeList or PromoList or something, if they're going to be promotion codes. Or maybe just Promo, since a model should be a singular name, and each instance of your model will

Re: "Dynamyc" modells

2012-03-12 Thread Shawn Milochik
On 03/12/2012 03:34 PM, Ervin Hegedüs wrote: The main problem is the PromoList is _dynamyc_ - it means all administrator on admin site should add new PromoList, without me :), so I can't derivate all subclass in code... You can't dynamically create database tables on the fly. That would requi

Re: Newbie Django queryset question

2012-03-15 Thread Shawn Milochik
If you don't know which fields your users will be searching on in advance, you'll have to create Q objects and dynamically build your query in your view. https://docs.djangoproject.com/en/1.3/topics/db/queries/#complex-lookups-with-q-objects -- You received this message because you are subscr

Re: Newbie Django queryset question

2012-03-15 Thread Shawn Milochik
You can certainly use Q objects to query across models, just as you can in a normal QuerySet, by using the double-underscore notation. https://docs.djangoproject.com/en/1.3/topics/db/queries/#lookups-that-span-relationships -- You received this message because you are subscribed to the Google

Re: Query Set to search for a combination of model fields?

2012-03-15 Thread Shawn Milochik
Look at how the Q objects are being used in the example and it's clear why that is. It's using the pipe (|) to do an "or" query. If you want to change how the search works you'll have to add more code: 1. Split the search parameters on whitespace. 2. Create Q objects for searching in either or

Re: Newbie Django queryset question

2012-03-15 Thread Shawn Milochik
On 03/15/2012 11:22 PM, Murilo Vicentini wrote: Uhmmm, thank you a lot. That was what I was looking for! Sorry for wasting your time. One last question, does this double-underscore notation work at my html template? Because after filtering I will want to display the information of the different

Re: python manage.py syncdb Error: No module named messages

2012-03-16 Thread Shawn Milochik
Check your PYTHONPATH. Perhaps it's not set right on the CentOS machine. The Linux distro shouldn't make a difference, nor should the presence of Cpanel or MySQL. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send ema

Re: python manage.py syncdb Error: No module named messages

2012-03-16 Thread Shawn Milochik
Not a PATH issue, but a PYTHONPATH issue. Run "python manage.py shell" and try to import 'messages.' I suspect it's not where you think it is, or its location is not on your PYTHONPATH. -- You received this message because you are subscribed to the Google Groups "Django users" group. To pos

Re: Django/Python version compatibility

2012-03-19 Thread Shawn Milochik
Django won't support 3.x for a while. You can't go wrong with 2.7 for now. https://www.djangoproject.com/weblog/2012/mar/13/py3k/ 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@googlegro

Re: How to restrict values in admin input form?

2012-04-06 Thread Shawn Milochik
https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#adding-custom-validation-to-the-admin Essentially, make a ModelForm exactly as you would normally, and add logic to it. You're going to want to change the queryset of the field(s) in question. For example: class ThingAdminForm(forms.M

Re: storing objects in session

2012-04-06 Thread Shawn Milochik
Try using pdb and/or logging statements to trace it. You will almost certainly find your problem that way. If not, you'll be able to ask a more specific question that will be easier for others to answer. On Apr 6, 2012 3:11 PM, "imgrey" wrote: > I'm trying to store temporary cart in session, but

<    1   2   3   4   5   6   7   8   9   10   >