On 16/09/2014 2:02 PM, Pitchblack wrote:
Is there a way to add the user to the data model, so it knows who
created the record and who updated it last?

You need to establish a couple of foreign key fields in your model (eg created and updated) which both link to auth.user. Then grab request.user at the appropriate time and do <model>.created = request.user and <model>.updated = request.user just before saving.

This can be done in the admin https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

In your own forms it is the same as updating any other fields.

hth


On Sunday, October 20, 2013 5:24:22 PM UTC-7, Ideo Rex wrote:

    Hello,
    I'm relatively new to Django. So I have a working (local) web
    application. I can create new model objects from the admin site, but
    I would like my users to be able to create their own objects and
    save them to the database. I'm really confused on the over arching
    process on how this is down and I would appreciate it if someone
    could lead me in the correct direction.

    I want to allow my users:
    1. fill in information on a page
    2. submit this page to the database
    3. redirect them to a page that reflects their input ("You
    successfully submitted this {{title}}")

    Thanks

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to django-users@googlegroups.com
<mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/e5e91694-3637-4fd9-8c3e-0edb4606477e%40googlegroups.com
<https://groups.google.com/d/msgid/django-users/e5e91694-3637-4fd9-8c3e-0edb4606477e%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/541841E5.3010703%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Reply via email to