Re: Model "created_by"

2011-07-13 Thread Nick Serra
That error just means you didn't add that field to the database and it can't find it. Verify the user_id field is on that table. On Jul 13, 2:40 pm, Petey wrote: > Hi! > > I've made a model in news application:http://pastebin.com/49VkFT14 > > I want it to save user who created a message, however

I18n on, l10n off, but django still translating date field

2011-05-26 Thread Nick Serra
Hey everyone, thanks for looking. I am developing a site that has spanish translations. I18n is working properly, but when I switch to spanish, my form output that has dates is in spanish. This is a problem because I am sending out staff emails on some forms, which cannot have spanish in them. So I

Re: extend User Model for custom fields

2011-03-25 Thread Nick Serra
Andre's solution is out of date. Calvin is correct, use the user profile model that is built into django auth. OP, the link you found is correct. On Mar 25, 11:39 am, Andre Terra wrote: > This is the correct way: > > http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m... > > Sin

Override AdminAuthentication form for custom auth in Django Admin

2011-03-03 Thread Nick Serra
Hey everyone, thanks for looking. Running into a problem getting the Django Admin working with a custom auth system. Have everything working, but I cannot get the admin to use my custom auth app to login. I am not running a custom auth backend, but an entirely different auth app in my project. Bas

Re: Creating initial Security/Auth objects with syncdb

2010-12-22 Thread Nick Serra
Could just put the group in the initial data for sync db. Look up django fixtures. It will load data into the database from a json feed on syncdb. On Dec 21, 1:50 pm, "Mark (Nosrednakram)" wrote: > Hello, > > I would like to install an auth_group with my application and am > considering using the

Re: English translation for error message?

2010-12-22 Thread Nick Serra
http://translate.google.com/#auto|en|%20list%20index%20out%20of%20range On Dec 21, 6:10 pm, Bill Freeman wrote: > On Tue, Dec 21, 2010 at 5:53 PM, Jonathan Hayward < > > > > > > christos.jonathan.hayw...@gmail.com> wrote: > > [jhayw...@cmlnxbld01 invdb]$ python manage.py shell > > Python 2.7 (r27

Re: Problem with simple file upload.

2010-12-22 Thread Nick Serra
I'm too lazy to check, but i'm pretty sure the name of your file input needs to match the name of the form field. Also, try troubleshooting. Use print statements in the view to see if the file object is being posted, etc. On Dec 21, 11:54 pm, vivek_12315 wrote: > Awaiting reply! > > On Dec 22, 3:

Re: problem with saving a form

2010-09-27 Thread Nick Serra
You're just all around doing it wrong. A ModelForm is used so that you don't have to individually list all the fields you need, it is based off the model. What is the code for your Model? And also, I'd reread the form reference from the start. On Sep 26, 5:25 pm, Marc Aymerich wrote: > On Sun, Se

Re: Ordering in the admin

2010-08-16 Thread Nick Serra
trying to match the id. > > I'm going to read about filtering a little more, feels like it's > close... > (I also tried to put film_id in the parens after filter and got a "too > many values" error.) > So much to learn, thanks

Re: Ordering in the admin

2010-08-16 Thread Nick Serra
gt;                         {% for filmmaker in filmmakers %} >                            {% if filmmakers|length > 2 and not forloop.first > %}, {% endif > %} >                            {% if forloop.last and not forloop.first %}and {% > endif %} >                               {{filmmake

Re: Ordering in the admin

2010-08-16 Thread Nick Serra
mple going, I guess I'll try the inline solution as well, if it's > > the pretty way to do it...  It'll be good for me to actually see what > > they both do. > > W > > > On Aug 16, 12:28 pm, Nick Serra wrote: > > > > The inline solution is th

Re: Ordering in the admin

2010-08-16 Thread Nick Serra
rap the many to many relationship.  (there are lots of > films that have multiple filmmakers and vice versa, and I'd like to be > able to list them on both ends)  I'm still trying to wrap my head > around how I could do that with this example. > > If anyone has anything else

Re: How to check for m2m orphans before deleting an object?

2010-08-13 Thread Nick Serra
Look into the clear() method on many to many relations. Calling .clear() before a delete will remove all relations between the models and allow you to delete the category only. You might be fighting the django admin on this though, so this would be best implemented in a custom solution. Not sure if

Re: Ordering in the admin

2010-08-13 Thread Nick Serra
You can go two directions with this. First, you could use a intermediate model for the many to many join, which would allow you to specify extra field on the join, in this case the order. Read up on this here: http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relat

Re: Saving objects that have foreign key fields using the pk instead of an instance of the foreignkeyed object

2010-05-12 Thread Nick Serra
Exactly what I was looking for, thanks! On May 12, 11:50 am, Daniel Roseman wrote: > On May 12, 4:34 pm, Nick Serra wrote: > > > Thanks for the response. I actually will already have the PK, and am > > trying to avoid grabbing an instance of the actual item object. > >

Re: Saving objects that have foreign key fields using the pk instead of an instance of the foreignkeyed object

2010-05-12 Thread Nick Serra
Thanks for the response. I actually will already have the PK, and am trying to avoid grabbing an instance of the actual item object. On May 12, 11:26 am, Daniel Roseman wrote: > On May 12, 4:04 pm, Nick Serra wrote: > > > > > > > Sorry for the confusing title. Her

Saving objects that have foreign key fields using the pk instead of an instance of the foreignkeyed object

2010-05-12 Thread Nick Serra
Sorry for the confusing title. Here is a simple example to illustrate my question: class Item(models.Model): name = models.CharField() class Manager(models.Model): item = models.ForeignKey(Item) On a POST I have the PK of the Item I want to link to a new instance of the Manager object.

Re: Django 1.2 release candidate available

2010-05-06 Thread Nick Serra
Awesome! Thanks so much! On May 6, 3:32 am, Federico Capoano wrote: > I've been using the beta for a while and it works pretty good for what > I've seen. > > On May 6, 6:40 am, James Bennett wrote: > > > > > > > Tonight we're proud to announce, finally, the first Django 1.2 release > > candidate

Re: override a form field, to allow usernames with '@'

2010-05-04 Thread Nick Serra
I just implemented this and it's a hassle. There are heated discussions about it. I ended up modifying the auth app and completely eliminating the 'username' field and just using email. Then I modified the admin app to allow the login, and am basically just completely overriding both. Good luck! O

Re: grabbing request while overriding save or in a signal

2010-04-30 Thread Nick Serra
Yeah, I realize this now hah. Instead I am now passing request into a ModelForm for what I need. Basically I have a comment system, and on each comment post I wanted to run it through Akismet, which required the IP and User Agent. So I just passed request into my form.save() method on comment adds.

Re: following reverse relationship of an extended model

2010-04-28 Thread Nick Serra
Yeah, that is going to be my fallback, I was just curious on an actual reverse relationship solution to the situation. Thanks for the input! On Apr 28, 4:12 pm, zinckiwi wrote: > > class Account(models.Model): > >     name = CharField > > > class Entry(models.Model): > >     account = ForeignKey(

following reverse relationship of an extended model

2010-04-28 Thread Nick Serra
Hey, quick query question. I know there has to be an answer for this one, just don't know the syntax. I need to follow the reverse relationship for an extended model. class Account(models.Model): name = CharField class Entry(models.Model): account = ForeignKey(Account) class Page(Entry):

grabbing request while overriding save or in a signal

2010-04-28 Thread Nick Serra
Hey everyone. I'm trying to access the request object while overriding the save or tapping into the post_save on a model. I need request info when someone posts a comment. But I don't just want to handle this in my view, I would like it to be cleaner than that, so that functionality would remain ev

Re: adding foreign key attributes to the admin editing screen

2010-04-26 Thread Nick Serra
Are you trying to interface django with an existing table? Why do you have the StandardCode class foreign key-ing to the table, instead of just making a model that references the table exactly? On Apr 26, 2:43 pm, Jesse wrote: > Table LOINCCode has loinc_obr4 (a number) and a description field >

Re: M2M Manager -- how to get primary key of join table?

2010-04-26 Thread Nick Serra
You could create a model that references the join table itself. class ArticlePublicationsJoin(models.Model): id = models.AutoField() publicaiton_id = models.IntegerField() article_id = models.IntegerField() class Meta: db_table = 'article_publications' then just query on

Re: How to return an audio file in django

2010-04-26 Thread Nick Serra
Interesting. If the file is an mp3, maybe try: file = open("/path/to/my/song.mp3", "rb").read() response['Content-Disposition'] = 'attachment; filename=filename.mp3' return HttpResponse(file, mimetype="audio/mpeg") On Apr 26, 1:20 pm, Dexter wrote: > Hi there, > > I want to send an audio file v

Re: difficulty with 1.2 CSFR processing

2010-04-26 Thread Nick Serra
Include request context: from django.template import RequestContext ...and then pass it in with the render. That should include the token in the template. return render_to_response('add_pair.html', {}, context_instance=RequestContext(request)) On Apr 26, 12:45 pm, jeff wrote: > so i have some

Re: feed decorator

2010-04-26 Thread Nick Serra
Seems very odd how you're trying to implement this. Unless your pseudocode has me confused. Can you give us the view functions too? Seems like you're trying to use a decorator function on two views. Why don't you just bail on the decorator, and just check for request.GET.get('format') == 'rss', and

Re: Many-To-Many issue; trying to find a way around conditional id

2010-04-26 Thread Nick Serra
Can you be more clear on the exact result you're trying to achieve? Do you want to see, for a given high school, how many recruit objects are foreign keyed to it? On Apr 26, 7:38 am, Nuno Maltez wrote: > Are you saying that: > > collegelist = > college.current_objects.filter(collegechoices__scho

Re: Track "before" and "after" state of an object when editing in the Admin?

2010-04-26 Thread Nick Serra
There are a couple ways to do this. You can either override the model methods like save and init, or you can use signals and tie into the pre_save, post_save, etc. Signals are here: http://docs.djangoproject.com/en/dev/ref/signals/ If using signals, you will have an instance of the object being s

Re: Performing an action on model.save() but not on update

2010-04-26 Thread Nick Serra
:) On Apr 26, 9:48 am, Jim N wrote: > Nick, > > Thanks very much.  That worked!  I can't work out why my code didn't > though (or rather, worked twice). > > -Jim > > On Apr 23, 6:37 pm, Nick Serra wrote: > > > > > > > Try this out and see

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Nick Serra
w, it increments TWICE! > > Is there some glaring error in my logic above? > > On Apr 23, 4:50 pm, Nick Serra wrote: > > > > > I didn't even think of that. It's not very common to be specifying > > pk's on create anyway, so yours would probably

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Nick Serra
efined rather than > auto-incrementing pk. > > On Apr 23, 4:21 pm, Nick Serra wrote: > > > > > > > A post save signal seems better suited for this. The post save signal > > has an attribute 'created' that will be true or false depending on if >

Re: Performing an action on model.save() but not on update

2010-04-23 Thread Nick Serra
A post save signal seems better suited for this. The post save signal has an attribute 'created' that will be true or false depending on if the object is being created or updated. Check out the post_save documentation: http://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.post

Re: New with Django

2010-04-23 Thread Nick Serra
Whenever I use django on my windows box, i use XAMPP, which is a all in one installer that gets apache and mysql. So I: - install XAMPP - install python - svn checkout django in the site-packages folder - install mysql bindings for python - install python image library and I think you need to add

Re: import request ? - django debugsqlshell

2010-04-23 Thread Nick Serra
Request is an object that django passes view functions that includes post data, meta data, and data about the request taking place. Not sure what your test function is doing, but to start, python is complaining because you are referencing the variable before it has been declared. You need to define

Re: temp url with time limit

2010-04-23 Thread Nick Serra
Just create a model that stores the url and the expiration time. If the url is hit past the expiration time, delete it, if it's still within the time limit, display whatever you want to display. Obviously this is for a small system, since you would be waiting to delete until the url is hit, but its

Re: Email Field

2010-04-21 Thread Nick Serra
I think i ran into this issue before. I don't think they define a max_length anywhere, the restriction is just on the database. Just increase the field size in the database and you should be good. On Apr 21, 2:20 pm, Tom Evans wrote: > On Wed, Apr 21, 2010 at 6:22 PM, CrabbyPete wrote: > > Yes,

Re: overriding model save(), is an instance available?

2010-04-21 Thread Nick Serra
Ahh, that'll do it. I'm used to the save() where you call super last. Works perfect, thanks for the solution! On Apr 21, 1:19 pm, Shawn Milochik wrote: > You should probably call that super __init__ first thing. Otherwise the > object won't really know how to behave like a Django model. > > Shaw

Re: overriding model save(), is an instance available?

2010-04-21 Thread Nick Serra
Thank you, that seems like a clean way to do it. I'm getting a weird error when overriding init though. When I simply do this: class Entry(models.Model): title = models.CharField(max_length=255) slug = models.SlugField(max_length=255) body = models.TextField() user

overriding model save(), is an instance available?

2010-04-21 Thread Nick Serra
Hey everyone, thanks for looking. I'm overriding a model save(), and was wondering if there is an instance of the model being passed in that i can access. My situation is that i have a title and a slug. I only want to change the slug when the title is changed. So in my save i want to check: if s

Re: How to ordered comments by date ???

2010-04-16 Thread Nick Serra
Those *links! Hah. On Apr 16, 12:08 pm, Nick Serra wrote: > You would order them on the model level or on the view level. In the > model, you can set ordering with the Meta class 'ordering' parameter. > In the view, you would just add .order_by() to your query. Check out >

Re: How to ordered comments by date ???

2010-04-16 Thread Nick Serra
You would order them on the model level or on the view level. In the model, you can set ordering with the Meta class 'ordering' parameter. In the view, you would just add .order_by() to your query. Check out these thinks: http://docs.djangoproject.com/en/dev/ref/models/options/#ordering http://do

Re: querying on a field equal to a manytomany object

2010-04-12 Thread Nick Serra
ref/models/querysets/#in > > Item.objects.filter(genre__in=some_video.genre.all()) > > On Apr 12, 10:03 am, Nick Serra wrote: > > > > > Hey everyone, thanks for looking. I couldn't think of a good title for > > this one. I have a question on queries on

Re: determining if a one-to-many relation exists

2010-04-12 Thread Nick Serra
l) On Apr 12, 1:32 pm, Jim N wrote: > Yes!  That's it!  Thank you. > > On Apr 12, 1:21 pm, Nick Serra wrote: > > > > > You could query like this: > > > Question.objects.filter(answer__isnull=False) > > > This would give you a set of questions where

Re: determining if a one-to-many relation exists

2010-04-12 Thread Nick Serra
You could query like this: Question.objects.filter(answer__isnull=False) This would give you a set of questions where an answer exists. Setting it to True would give you a set where answers don't exist. On Apr 12, 12:20 pm, Jim N wrote: > Just to clarify, I'm trying to filter questions that hav

querying on a field equal to a manytomany object

2010-04-12 Thread Nick Serra
Hey everyone, thanks for looking. I couldn't think of a good title for this one. I have a question on queries on manytomany relations. Here is an example: class Item: genre = models.ForeignKey(Genre) class Genre: name = models.CharField() class Video: genre = models.ManyToManyField(G