|
I'm trying to filter objects by a foreign key. In my models.py I have: code:
What I'd like to do is get all entries added by this user, but code:
Filtering by slug works without trouble, so I'm guessing it has something to do with the field being a ForeignKey?
|
# ¿ May 12, 2008 16:47 |
|
|
# ¿ May 3, 2024 05:57 |
|
This is probably common knowledge, but I just couldn't find the right search terms. I'm basically following the Django book, but I'd like to know how I can include a, for example, login form in my base template and not having to repeat the code in every view that I want the user to be able to login from. Currently I just link users to a login page. Could anyone help me with this?
|
# ¿ Jul 8, 2008 17:32 |
|
Thanks for all the help I've gotten already (especially Bonus). I'd like to auto-populate the "user" field in a model (foreign key to User) with the current request.user when a ModelForm of this model is submitted. I've searched and found a couple of guides, but they're all from ye olde times before ModelForm. I don't really understand how to use the information in the docs, since I'm currently using generic views. Do I need to write my own form handling view for this, or is there an easy way to implement this using the update_object generic view?
|
# ¿ Jul 28, 2008 18:02 |
|
I saw that in the docs, but I have no idea where to put that code or if it's possible to use this in conjunction with generic views.
|
# ¿ Jul 28, 2008 18:36 |
|
Thanks, I thought it might be possible to subclass the generic views or that the snippet Bonus provided would redefine the save function in the forms file. I wrote my own view to handle the form and everything works perfectly now.
Zenobia fucked around with this message at 12:26 on Jul 29, 2008 |
# ¿ Jul 29, 2008 12:22 |