Re: Problems saving model objects

2009-07-02 Thread Shawn Milochik
Would you post the model and the relevant parts of the form and/or view? In any case, you can easily fix it by following the error message's suggestion of str(your_float). But if you think there's a discrepancy between the way your fields are behaving, post some code and we'll see if we can

Re: Getting the name of a matched URL pattern

2009-07-02 Thread Shawn Milochik
On Jul 1, 2009, at 9:56 PM, Nick Fishman wrote: > > Hey everyone, > > I'm working with Django's named URL patterns, and was wondering how to > fetch the name of the URL pattern that triggered the view. For > example, with the following urlpatterns > > urlpatterns = patterns('', >url(r'^archi

Re: Sending JSON response from views

2009-07-13 Thread Shawn Milochik
> > > The question, how can I return username of user in fields. I want > the JSON response to contain value user.username instead of id of > user oject > > Thanks, > Oleg > Get everything you want into a dictionary. Then something like this will give you what you need: return safestring.ma

Re: Add extra field to ModelForm

2009-07-13 Thread Shawn Milochik
On Jul 11, 2009, at 6:23 PM, adelaide_mike wrote: > > Thanks Alex. > > A simpler way out would be if the agent field, which is a foreign key > pick list, could be caused to show only those values I determine > dynamically. > > Is this possible in a ModelForm? > > Mke If I understand correctly,

unittest DB questions

2009-07-13 Thread Shawn Milochik
My Django app uses postgres. I've defined TEST_DATABASE_NAME in settings and created that database in postgres. However, I haven't given my Django DB user permission to create and destroy databases -- just to own the database. So, I can't run manage.py test, because it fails to delete the

Re: unittest DB questions

2009-07-13 Thread Shawn Milochik
>> > > I highly highly recommend that you separate your development, testing, > and production instances of your DB and web server. You should never > ever develop or test on a production system! > > - -- > Randy Barlow That's already the case. I guess I wasn't clear enough. All the tests wil

DjangoCon 09 Recording (was: Re: DjangoCon '09)

2009-07-14 Thread Shawn Milochik
we can even get one of those onto each podium, I think we could have awesome sound quality. So, if there's already something planned, please let me know. If not, let's see if we can hack something together so that everyone can benefit from an

Re: I need to get psycopg2 installed on Mac OS X 10.5

2009-07-14 Thread Shawn Milochik
I had the same terrors. Unfortunately I didn't document exactly how I did it, but my best recollection is that this will work: 1. Update setuptools: sudo easy_install -U setuptools 2. Download and unzip the tarball for psycopg2. 3. Edit the config file for psycopg2 as directed on other Web si

Re: Way to show Progress bar in django while processing to send emails

2009-07-14 Thread Shawn Milochik
On Jul 14, 2009, at 2:51 AM, gganesh wrote: > > Hi friends, > It could be helpful if someone suggest me to find a way to show > Progress Bar while django is processing to send mails .I have a form > where list of email Id's are displayed with checkbox and user selects > those and submits.Here i

Re: Database Model Layout Advice

2009-07-14 Thread Shawn Milochik
I think you'd just have the interview table without any foreign keys, then add a ManyToMany to each of your Author and Illustrator models. You would still, of course, be able to start with your interview table and get the authors or illustrators, if necessary in your app. It might be handy

Re: Database Model Layout Advice

2009-07-14 Thread Shawn Milochik
On Jul 14, 2009, at 9:23 AM, The Danny Bos wrote: > > > So the Author and Illustrator tables would stay as is. > How would the Interview table talk to both of those tables at once, to > allow me to assign an interview to who I'm interviewing. Whether it's > an Illustrator, Author or even down th

Re: Count from 1 to 50

2009-07-14 Thread Shawn Milochik
On Jul 14, 2009, at 10:27 AM, The Danny Bos wrote: > > Is there a way to create a simple list using Django to go from 1 to > 50. > Eg: > > 1, 2, 3, 4, 5 ... 49, 50 > > I figured it'd be easy, but I can't get it. > I tried ... > > {% for i = 1 in 10 %} > {{ i }}, > {% endfor %

Re: Database Model Layout Advice

2009-07-14 Thread Shawn Milochik
On Jul 14, 2009, at 10:35 AM, Jonathan Buchanan wrote: > > One option would be to use a generic relation: > > http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1 > > Regards, > Jonathan. > > Yes, this is probably the right way to do it. I had heard about generic relation, but

Re: newbie question information about js

2009-07-14 Thread Shawn Milochik
On Jul 14, 2009, at 12:30 PM, luca72 wrote: > > Hello > I have a question in my view fiole i have this > > def myfunct() > do this... > now i need only to return a js alert message on the same page > is it possible? We need more information. Are you calling myfunct()

Re: How to store user

2009-07-14 Thread Shawn Milochik
On Jul 14, 2009, at 2:50 PM, Viktor Semykin wrote: > > Hi everyone. > > I use django.views.generic.create_update.create_object to allow users > to post new entries on my site. > How can I make model automatically save the user currently logged in? > Model like > class MyModel(Model): >user =

Re: multi applications

2009-07-14 Thread Shawn Milochik
On Jul 14, 2009, at 2:57 PM, sjtirtha wrote: > Hi, > > I'm looking for documentation, which describes how to build a web > application which includes many other applications. > For example like Facebook, it has following applications on the > first screen: > 1. On the left side is dynamic me

Basic AJAX (was: Re: multi applications)

2009-07-14 Thread Shawn Milochik
On Jul 14, 2009, at 3:43 PM, sjtirtha wrote: > Thank you for the explanation. > This helps me very much. > > You mentions about handling the smaller apps on the page with AJAX. > Is there any basic functionality to do this from Django Framework? > Or do you have any ajax lib/framework as prefe

Deployment Tool Recommendation

2009-07-15 Thread Shawn Milochik
I need to set up a one-click deployment from development to production. What tool(s) are currently best-of-breed in the Django community? Thanks in advance. The tool must be able to automate the following manual process: 1. Log into the production server via ssh, using a user ID which requ

Re: Deployment Tool Recommendation

2009-07-15 Thread Shawn Milochik
> > Any reason why you can't do 'sudo -u otheruser bash -l' or even > 'sudo su > - otheruser'? Seems strange to be able to sudo to root, but unable to > sudo to a role account. No, I don't see a reason not to do it that way. I just can't directly su to the other user due to the lack of a pas

Re: New to unit testing, need advice

2009-07-15 Thread Shawn Milochik
Basically, you want to test anything that might break if another part of the code is changed that interacts with it, might break if the application takes an alternative flow (maybe finally hits the 'else' of that if/else statement), or could possibly receive invalid input. Unfortunately, t

Re: syncdb doesn't updated database after adding null=True to an IntegerField

2009-07-17 Thread Shawn Milochik
> > Apart from django-evolution, also take a look at http://south.aeracode.org/ I second that -- I use South and it's really handy. I couldn't get Evolution to work (maybe I didn't wait long enough ^_^), but South does everything I need. The nice thing about it is that it's easily reversib

Re: Generating forms question.

2009-07-17 Thread Shawn Milochik
On Jul 16, 2009, at 5:16 AM, Viacheslav Chumushuk wrote: > > class Book(models.Model): >author = models.ForeignKey(Author) >title = models.CharField(max_length=100) > > All that I need is edit some book by primary key. Just make a forms.ModelForm for your Book model. The class Meta will

Re: Accessing Form Data in Form Object

2009-07-17 Thread Shawn Milochik
Try using form.data.initial to get the text only. --~--~-~--~~~---~--~~ 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 grou

Re: question about the DEBUG setting

2009-07-17 Thread Shawn Milochik
And as a brief aside, I've found it helpful to have a local_settings.py, which lives outside version control. If you put your database stuff and DEBUG flag there, you never have to fix it when you move to production. --~--~-~--~~~---~--~~ You received this mes

Re: Non-editable (but visible) fields in admin?

2009-07-17 Thread Shawn Milochik
On Jul 16, 2009, at 11:11 PM, Rubens Altimari wrote: > > Hello, > > Is there a way to show model fields in admin, but prevent them from > being edited? Using 'editable=False' in the model won't do, since then > the field simply is not displayed. > > Also, on a related topic: is there a simple wa

Re: Limiting administration based on user settings

2009-07-17 Thread Shawn Milochik
On Jul 17, 2009, at 8:08 AM, Rune Bromer wrote: > > Hello. > > For a small webshop I have the following models: Product, Category, > Country and UserProfile. Each user have a country set with a FK, and > should only be allowed to see content in the administration assigned > to the same Country.

Re: how to alter (add/del cols) the tables from the existing models

2009-07-17 Thread Shawn Milochik
Look at south or evolution. I use south, personally. It does exactly this very easily. http://south.aeracode.org/wiki/Tutorial1 To add a column to the database with south, you add it to the model, then: ./manage.py startmigration appname migration_name --add-field model.field So, if your

Re: Current user in model.save() context

2009-07-17 Thread Shawn Milochik
I think you still have to pass the user, but you can tell if the item is modified or new by whether its id has a value. If it's brand new and has never been saved, then it won't have one. --~--~-~--~~~---~--~~ You received this message because you are subscribe

Re: looking for a clean, easy way to force user to change password on first login

2009-07-17 Thread Shawn Milochik
This isn't ideal, but it should work (or prompt someone to propose something better). Add a one-to-one table for the user, with a field containing the initial password (encrypted, of course, so it looks like the password in the auth_user table). When the user logs in, have the login page c

Re: Graphing (Pie Chart, Bar Graphs, Line Plots, etc) in Django?

2009-07-17 Thread Shawn Milochik
"Beginning Python Visualization" was recently published to fit exactly this need. (No disclaimer -- I have no association with the book other than having purchased it.) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google G

Re: looking for a clean, easy way to force user to change password on first login

2009-07-18 Thread Shawn Milochik
If I understand correctly, you can do this without having to re- implementing the login. You will have to make a (very simple) login template, and write a login view that contains these: from django.contrib.auth import login login(request, form.get_user()) Then you c

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 12:00 PM, mettwoch wrote: > > Hi, > > I'd like to implement a simple "create" & "update" form for my > "Partner" model using ModelForm. How can I make the difference in a > view "save" function whether the POST comes from a "creation" or an > "update" form? Unfortunately the

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 12:49 PM, mettwoch wrote: > > Sorry my old brain doesn't get it. Is there somewhere a complete CRUD > example using ModelForm? > > Thanks > Marc CRUD: If your modelform is called PartnerForm, then. CREATE and UPDATE: #on initial page load (no POST)

Re: Recommendations for a Django development book?

2009-07-21 Thread Shawn Milochik
"The Definitive Guide to Django," second edition. It was just published and was written by Adrian Holovaty and Jacob Kaplan-Moss. In case you don't know who they are, they're the co-creator and a lead developer of Django, respectively. --~--~-~--~~~---~--~~

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
> > This always creates a new partner! In fact, in the ModelForm > documentation is written that the save() method creates a new instance > unless an existing instance is passed to the ModelForm constructor. So > one has to differentiate if the POST comes from an initially empty > form or from a bo

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 3:39 PM, mettwoch wrote: > > Sorry to insist, but that's what I don't understand here. How can I > know that the partner that is 'posted' is new or not? I really become > crazy here. I can't believe after all the good things I've discovered > in Django that this can be so har

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 4:22 PM, Dan Harris wrote: > > What do you mean by having the ID "in" the form? I don't quite > understand what you are trying to do. > > On Jul 21, 4:15 pm, mettwoch wrote: >> Ok, I come back to what I wrote before. If the partner already exists >> it has an id (primary-key

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
To expand on what Dan said with a full (tested and working) example: In urls.py: (r'^partner/$', 'partner_page'), (r'^partner/(?P\d+)/$', 'partner_page'), In the form tag of your template: The view: @login_required def partner_page(request, partner_id = None): if par

Re: best approaches with render_to_response and large forms

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 5:21 PM, Juan Hernandez wrote: > Hi there, > > i have two questions in my mind. > > 1- Let's say that I have tens of views. Do I always have to use > render_to_response? I find it totally against DRY. My solution was > creating a wrapper that would take as arguments the te

Re: passing variable to objects.get

2009-07-23 Thread Shawn Milochik
Do you know for certain that indata contains a value before you try the objects.get()? If you are getting an error like "no value found," it sounds like you might not. If you're getting something like "no such object," then it would be a different problem. Is the field "word" in your model

Re: Automatic updating of open-high-low-close data

2009-07-23 Thread Shawn Milochik
Why not just use the automatic "id" field as the primary key? --~--~-~--~~~---~--~~ 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: Slugs, why would you ever need to store one in the database?

2009-07-23 Thread Shawn Milochik
My understanding of the slug field is that prettier URLs are the main point. "Slug" is a newspaper-industry term, and since Django has its roots there, it's now a Django term. Django does' in fact, contain a slugify function: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#slugi

Re: creating a list of sql that is executed

2009-08-06 Thread Shawn Milochik
Look for the post_save signal. Once you can attach your own function to that signal (make it listen for the signal and kick something off), you can probably have Django dump the raw SQL query that is created to a text file. I don't know the syntax for that, but check the django.db docs. Ha

Re: How to add basic text formatting to the message body of send_mail in django?

2009-08-21 Thread Shawn Milochik
On Aug 21, 2009, at 12:50 PM, Ray wrote: > > Hi, > I'm trying to do this: > > send_mail(subject='hey, Ray', >message='Hey ray, this is an automated message, \n heres a > link: yahoo.com or yahoo.com', >from_email='bl...@gmail.co', >recipient_list=['blan...@gma

Re: dump data using json

2009-08-21 Thread Shawn Milochik
On Aug 21, 2009, at 11:39 AM, ashish tiwari wrote: > hi Friends > > i heared about the json format > django provided utility of dumpdata, loaddata which dumps and loads > data in json format. > > but i dont know,how to use it.. > > i want to dumpdata...from my app > > name of iFriends > n

Re: Model Forms

2009-08-27 Thread Shawn Milochik
There are different options, depending on whether the instance of B is a required part of A's model. 1. You can add an "exclude" section to your ModelForm of A. Validate BForm, validate AForm, then take the resulting instance of A and set it's 'b' attribute to the resulting instance of BFor

Re-usable/pluggable app form question.

2009-09-03 Thread Shawn Milochik
I'm working on an existing project that I'm splitting up into multiple apps. My question is about how to use those apps together. Say I have an app called "main." Then two supporting apps which sit outside of that Django project folder. They are "foo" and "bar." They are not "installed" as

Re: Reading text files into mysql database

2009-10-01 Thread Shawn Milochik
On Oct 1, 2009, at 9:25 AM, Carlos Gustavo wrote: > > Hi All, > > I am a django newbie and so far it has been great. > > How do I populate a mysql database table with data from a text file? > > Also How do I dump results of a database query into a text file. > > I have already created my django

Re: Two Formset on the same page

2009-10-01 Thread Shawn Milochik
Are both Django forms being rendered in the same HTML form, or are they separate? If they're in separate HTML forms, that could be the problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group

Re: How to pass values between views/templates

2009-10-02 Thread Shawn Milochik
Your current approach makes sense. If you're concerned that you're storing too much data in the session, you could just maintain a session ID in the session and use that as a key for an sqlite3 database or something, or even a model in your app's database, if that makes sense. Is there any

Re: Extending Django's Flatpages

2009-10-02 Thread Shawn Milochik
If you're trying to add template tags, check this out: http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ Your custom tags go in a directory named "templatetags" in your app directory. Shawn --~--~-~--~~~---~--~~ You received this message because

Re: How to pass values between views/templates

2009-10-02 Thread Shawn Milochik
Remember that people often represent their best work, and I bet they only answer the questions they're most confident about their experience with. If you care that much about your code, you'll be fine -- once you have your 10,000 hours* in as a coder, people will be in awe of your code to

Re: iphone to website

2009-10-09 Thread Shawn Milochik
On Oct 8, 2009, at 9:33 AM, grant neale wrote: > > Well 1 problem I was thinking about was uploading photos. > Any suggestion. > > Grant While it's not Django-specific, it's easy to write a Python script that monitors an e-mail address and downloads and stores the attachments. You could sc

Re: Problems with custom Auth Backends: 'NoneType' object has no attribute 'DoesNotExist'

2009-10-09 Thread Shawn Milochik
The way to do what you're trying to do is to take advantage of the following: http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users In brief, you'll create another model, which will then be specified in your settings.py by AUTH_PROFILE_MODULE. From then

Re: iphone to website

2009-10-10 Thread Shawn Milochik
On Oct 8, 2009, at 9:33 AM, grant neale wrote: > > Well 1 problem I was thinking about was uploading photos. > Any suggestion. > > Grant While it's not Django-specific, it's easy to write a Python script that monitors an e-mail address and downloads and stores the attachments. You could sch

Re: efficiently deleting content based on how old it is

2009-10-10 Thread Shawn Milochik
Chris, I know this doesn't answer the hard part of your question, but here's a simple way I delete old stuff from a database via an external script that's run by cron: Item.objects.filter(date_updated__lte = datetime.now() - timedelta (days = 30)).delete() If you use timedelta, you can eas

Re: Problems with custom Auth Backends: 'NoneType' object has no attribute 'DoesNotExist'

2009-10-10 Thread Shawn Milochik
The way to do what you're trying to do is to take advantage of the following: http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users In brief, you'll create another model, which will then be specified in your settings.py by AUTH_PROFILE_MODULE. From then

Middleware to replace @login_required

2009-10-15 Thread Shawn Milochik
Middleware question: If 100% of an apps views require a logged-in user except for the login page, does it makes sense to have middleware check the URL and redirect to the login page rather than putting the @login_required decorator over all the views? I have to ensure that users' passwords expir

Re: Middleware to replace @login_required SOLVED, + PCI Compliance

2009-10-15 Thread Shawn Milochik
Ethan, Thanks for the feedback. I did create my own middleware, and it was ridiculously simple. I just looked at the django.middleware files and saw how easy it was. I only had to make exceptions for the pages pertaining to resetting a forgotten password (from django.contrib.auth.views) and the

Re: Regarding login functionality in page other than login

2009-10-17 Thread Shawn Milochik
On Sat, Oct 17, 2009 at 1:42 PM, Raashid Malik wrote: > I have a custom page e.g home and i want to have login functionality on this > page. I m using django registration module for django login and > registrations process. Now i m totally blank on how to implement this. Plz > help > > > Thanks,

Re: How to enforce uniqueness based on two model fields

2009-10-19 Thread Shawn Milochik
Guillermo, Please see the 'unique_together' syntax: http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this g

Re: Add Request Parameters

2009-10-19 Thread Shawn Milochik
Keith, Depending on what you're doing, it might be a good place to use a context processor. http://docs.djangoproject.com/en/dev/ref/templates/api/#writing-your-own-context-processors Also, if you're using (or can use) the session middleware, you can store these values in the session. Shaw

Re: foreign key to an abstract model

2009-12-03 Thread Shawn Milochik
Here's how to do a generic foreign key: http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1 -- 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

Re: How to show output from external process

2009-12-04 Thread Shawn Milochik
On Dec 4, 2009, at 12:10 PM, Philippe Clérié wrote: > I am working on an application that requires getting some data offsite, > process it and load the site database. This process can take up to five > minutes. I would like to be able to capture the output and present it to the > user so he kn

Re: How to show output from external process

2009-12-04 Thread Shawn Milochik
On Dec 4, 2009, at 1:34 PM, Philippe Clérié wrote: > Are you using a library or did you code it yourself? What would be a good > library to start with? > > -- > > > Philippe > I use jQuery, and that makes it simple. First, have a view that returns JSON. Basically, this is all you need in

Re: How to create multiple 'submit' buttons using 'forms' package

2009-12-05 Thread Shawn Milochik
Ken, You just put the submit buttons in the HTML form as you would normally. The submit button isn't part of a Django Model or Form. It really doesn't make sense there; there's no data there. Shawn On Dec 5, 2009, at 9:55 PM, Ken wrote: > I have the following form, which displays nicely

Re: How to validate a form field whose value can only increase?

2009-12-06 Thread Shawn Milochik
The easiest way I know of is this: In the __init__ of the model, create a variable: self.old_value = self.fieldname. In the save() function, you can check self.fieldname against self.old_value. Shawn -- You received this message because you are subscribed to the Google Groups "Django users

Re: How to validate a form field whose value can only increase?

2009-12-06 Thread Shawn Milochik
On Dec 6, 2009, at 11:01 PM, Continuation wrote: > What do you mean by the __init__ of the model? > Every models.Model object has an __init__ function, like any Python class. You need to override it. Add this into your model (in your models.py): def __init__(self, *args, **kwargs):

Re: browser input and strings

2009-12-07 Thread Shawn Milochik
What exactly are you trying to do? Can you give a little of the data in your model, and then exactly how you want it to look on the rendered page? I'm having some trouble understanding what your template and view are intended to do. Shawn -- You received this message because you are subscribe

Re: model design problem

2009-12-07 Thread Shawn Milochik
What kind of information will the database have to store about the ports themselves? How will you need to be able to filter querysets by information in the port fields, if at all? I'm going to throw this one solution out there, but depending on your needs it may not fit: Create a red_ports co

Re: insert into data field of model based on other data field values

2009-12-07 Thread Shawn Milochik
Easy to do: Just override the save() function of the model. class MyModel(models.Model): def save(self, **kwargs): #add your logic here super(MyModel, self).save(**kwargs) -- You received this message because you are subscribed to the Google Groups "Djang

Re: How to validate a form field whose value can only increase?

2009-12-07 Thread Shawn Milochik
On Dec 7, 2009, at 7:16 PM, Continuation wrote: > > I thought if form.is_valid() returns False, Django would send a list > of the errors to browser. But that's not what happened here. Do you have anything like these in your template? {{ my_form.errors }} {{ my_form.field_name.errors }} Shawn

Re: Format fields in list, but keep sortable?

2009-12-08 Thread Shawn Milochik
Bear in mind that the admin has a limited scope. This is intentional. It was meant to be a friendly replacement for having to hit the Postgres/mySQL command line interface, and that's about it. It's trivial to create your own form for dealing with your model which can be customized in any way yo

Re: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik
We'll need some more information. What error messages are you getting, if anything. How do you know the CMS works at all, if it hasn't been run locally? Have you followed the official tutorial to get a basic understanding of how Django works? If not, please do: http://docs.djangoproject.com/en/

Re: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik
If you run 'ifconfig' on the command line, you will get your IP address. Let's pretend that your IP address is 192.168.1.105. Try this: python manage.py runserver 192.168.1.105:8000 See if you can visit http://192.168.1.105:8000 instead. I don't know what the problem is, but maybe it's somethin

Re: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik
Sorry, I should have said 'ipconfig' instead of 'ifconfig' if you're running on Windows, and you mentioned IE so I guess you are. Unless you're running your Django server on one machine and trying to access it from another, which would definitely cause the exact problem you're seeing, but runnin

Re: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik
I don't think they can prevent you from using it locally. The fact that I can ping the IP address you provided means that it's publicly available. This either means that your machine has its own direct connection to the Internet, or ipconfig returned multiple addresses, including the address of

Re: New to Django, can't get it running on the web through http://127.0.0.1:8000/

2009-12-08 Thread Shawn Milochik
On Dec 8, 2009, at 11:38 AM, Jenn Hughes wrote: > I checked and no proxy is in place. I tried the other IPs, two > wouldn't let me assign it and the third went through but gave me the > same error that I began with. How odd. > I suspect there may be some other tiny but very important problem wi

Re: How to choose one row of data

2009-12-09 Thread Shawn Milochik
If you assign the output of the save() method, you'll get the created object. Instead of: form.save() do: current_order = form.save() Then you can do whatever you like with current_order, which will be an instance of whatever the class 'meta' is of your OrderForm, assuming that OrderForm is a

Re: How to populate the database

2009-12-10 Thread Shawn Milochik
There are different ways to do it, depending on how much data you have and how often you plan to do it. The fastest way for large files is to use sqlite3's .import command to directly import a file. However, this will bypass any validation done by your models. The way I do it is to read the csv

Re: question about changing model/table names and attributes ... (still learnin')

2009-12-10 Thread Shawn Milochik
The current best tool for this is South: http://south.aeracode.org/ You can do complicated data and database migrations smoothly, with the ability to roll-back changes. I don't know why you mention changing table names, since that should never be necessary. But anything is possible. If you're d

Re: How to populate the database

2009-12-10 Thread Shawn Milochik
Sure, here's a quick & dirty sample I put up on pastebin: http://pastebin.com/f651cf8de -- 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 ema

Re: How to execute linux command in django view

2009-12-11 Thread Shawn Milochik
The proper way to do that is to use the subprocess module. http://docs.python.org/library/subprocess.html If you don't want to do much reading, you'll just want to look at section 18.1.3.1, which gives the way to call a simple shell command the way you'd do with backticks in Perl. However, sin

Re: HTML text editing

2009-12-11 Thread Shawn Milochik
Look at safestring. from django.utils import safestring The docs will explain all, but basically you do this: the_html = safestring.mark_safe(your_html) The text in "the_html," if passed in your template, will not be escaped. The standard warning should be repeated here -- be sure you trust yo

Re: Error creating and saving a Django-object from the other script

2009-12-11 Thread Shawn Milochik
On Dec 11, 2009, at 4:51 PM, tezro wrote: > Seems like no clues... > > On Dec 10, 12:21 am, bruno desthuilliers > wrote: >> On 9 déc, 18:58, tezro wrote: >> (snip) >> >> >> >>> That throws an error: TypeError: 'slug' is an invalid keyword argument >>> for this function. >> >>> What am I do

Re: Error creating and saving a Django-object from the other script

2009-12-11 Thread Shawn Milochik
Why did you manually add a 'slug' field to your database after modifying the model? Django's syncdb does a lot more than just create the field; depending on which database you're using, it does a few other things and overrides some defaults. I wonder if there's a disconnect there. If this proje

Re: Passing data from view to template

2009-12-11 Thread Shawn Milochik
What kind of object are you trying to send? JSON pretty much looks identical to a Python dictionary, so if your object is a Python dictionary, list, or tuple you'll have no problem -- just convert the Python object using simplejson.dumps(). If this doesn't help much, please provide more detail

Re: Can I change the models.py of an existing django app?

2009-12-11 Thread Shawn Milochik
I feel like a broken record this week -- I've been recommending South in every other post I've made on this list. So, at risk of annoying people, check out South: http://south.aeracode.org It does exactly what you want it to do, and is the dominant (and nearly the only) solution used in the Dja

Re: Passing data from view to template

2009-12-11 Thread Shawn Milochik
You don't need to transfer this to JavaScript once it's in JSON, which is a JavaScript object. If you're using AJAX, it's dead easy. #use this in your view return HttpResponse(simplejson.dumps(employees), mimetype="application/json") Then, in your JavaScript, you can use JSON syntax to refer t

Re: Error creating and saving a Django-object from the other script

2009-12-12 Thread Shawn Milochik
On Dec 12, 2009, at 8:08 AM, tezro wrote: > Nope. Did it again on a clean project with the same models migrated > then by South. > > Same error. Any other clues? > > Thanks for replies. When you say "same error," do you mean this one: "Duplicate key name 'news_element_slug'"? If so, then it

Re: The best way to populate sqlite3 database

2009-12-12 Thread Shawn Milochik
The fastest way for large files is to use sqlite3's .import command to directly import a file. However, this will bypass any validation done by your models. You could end up with "bad" data, in that it doesn't conform to the rules of your models. Or, you can just write an external script to rea

Re: design question: storing history

2009-12-14 Thread Shawn Milochik
It sounds like, for auditing purposes, there should be a model for storing each "hours worked" entry. Also, the hours estimated should not be reduced in the database -- there should be a method of your model which returns the remaining hours by subtracting the sum of the worked hours from the e

Re: Parsing/decoding html content from textarea

2009-12-14 Thread Shawn Milochik
>>> urllib.unquote('%3Cp%3E+hello+world+%3C%2Fp%3E') '+hello+world+' -- 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-user

Re: Complicated Form "Workflow" - Need ideas/direction

2009-12-14 Thread Shawn Milochik
What you're trying to do is simple enough to write out in flowchart form on a sheet of paper. You should do that, then write some code, then ask for help with specifics when you get stuck, or are trying to decide between different approaches. What your e-mail sounds like, whether you intend it o

Re: Complicated Form "Workflow" - Need ideas/direction

2009-12-14 Thread Shawn Milochik
Okay, here are a few ideas: 1. If you hate pop-ups, but aren't opposed to a little AJAX, then you could do it that way. 2. You could do it with a multi-screen, 'wizard-like' set of templates. 3. You can keep state using session variables. 4. If you don't want to worry about keeping session va

South data migration problem.

2009-12-15 Thread Shawn Milochik
I added a new ManyToMany field to one of my models. The foreign key is to a model in a different Django application in our project. The migration to add the foreign key works perfectly. I did remember to add the --freeze otherappname.modelname to the command line. I also added the --freeze othe

Re: South data migration problem.

2009-12-15 Thread Shawn Milochik
Sorry to reply to my own post -- I just realized I left out a useful detail: I added a foreign key to the Study model to several tables, and a ManyToMany to Study to two tables. The data migration works flawlessly for the tables where I'm setting the foreign key to the Study instance -- it onl

Re: South data migration problem.

2009-12-15 Thread Shawn Milochik
Okay, okay. So I'm still replying to my own post. On the bright side, I figured it out. First point of interest: If I stop referrering to my model with orm.Message, and just use Message (as imported from my app at the top), everything works fine. Second point of interest (discovered AFTER

Re: Legacy Postgres Database and Sequencers

2009-12-15 Thread Shawn Milochik
If it's a legacy database, but the tables actually have a field named 'id' (which is Django's default primary key), maybe the Django ORM is assuming that that's the primary key. Does a field in your model have primary_key = True set? http://docs.djangoproject.com/en/dev/topics/db/models/#automa

Re: Extranet : Complete project behind login?

2009-12-16 Thread Shawn Milochik
You can do it easily with middleware. Here's what I wrote for this exact purpose: http://pastebin.com/f52e6ef04 You will have to add it to MIDDLEWARE_CLASSES in your settings.py. Shawn -- You received this message because you are subscribed to the Google Groups "Django users" group. To post

  1   2   3   4   5   6   7   8   9   10   >