This is probably an easy one, but I've tried what make sense to me with not success. What I want to do is in my admin pages, use the User module and enter the the user_id of whoever is logged in to add an entry in one of my foreign key tables.
How can set a field equal to the user_id to be entered into the db? Example: Models: from django.db import models from datetime import datetime from django.contrib.auth.models import User RATINGS = ( ('1','1'), ('2','2'), ('3','3'), ('4','4'), ('5','5'), ) class Recipes(models.Model): recipe_name = models.CharField(max_length=200) ingredients = models.TextField() instructions = models.TextField() image = models.ImageField(upload_to="/home/dave/dinnertools/image_upload",blank=True) entered_by = models.ForeignKey(User,blank=True) date_entered = models.DateTimeField(auto_now_add=True,blank=True) def __unicode__(self): return self.recipe_name class Rating(models.Model): recipe = models.ForeignKey(Recipes) rating = models.IntegerField(choices=RATINGS) user = models.ForeignKey(User) class DishCategory(models.Model): category_name = models.CharField(max_length=255) class RecipeCategory(models.Model): category_name = models.ForeignKey(DishCategory) recipe = models.ForeignKey(Recipes) class MyRecipes(models.Model): recipe_id = models.ForeignKey(Recipes) user = models.ForeignKey(User) ************************************************************* admin.py: from dinnertools.recipes.models import Recipes from dinnertools.recipes.models import Rating from django.contrib.auth.models import User from django.contrib import admin class RatingChoices(admin.StackedInline): model = Rating extra = 1 class RecipeAdmin(admin.ModelAdmin): fields = ['recipe_name','ingredients','instructions','image'] inlines = [RatingChoices] list_display = ('recipe_name','entered_by','date_entered') date_hierarchy = 'date_entered' admin.site.register(Recipes,RecipeAdmin) What I want to do is in RecipeAdmin add something like: entered_by = User.user_id So how can set a field equal to the user_id to be entered into the db? Thanks. David Godsey --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---