class Book(models.Model):
title = models.CharField(max_length=255)
text = models.TextField()
class Images(models.Model):
book = models.ForeignKey(Book, related_name='book_images')
image = models.ImageField(upload_to=file_uploads_to)
alt = models.CharField(max_length=255)
class Book(models.Model):
title = models.CharField(max_length=255)
text = models.TextField()
class Images(models.Model):
book = models.ManyToMany(Book, related_name='book_images')
image = models.ImageField(upload_to=file_uploads_to)
alt = models.CharField(max_length=255)
Images.filter(pk__in=[id1, id2,...]).detele()
<form>
{% csrf_token %}
{{ model_form_user }}
{{ model_form_profile }}
<button type="submit">
Расширять auth.User не предлагатьтогда мучайся дальше такими вопросами
элигатнногоhttps://ru.wiktionary.org/wiki/%D1%8D%D0%BB%D0%B5%...
if settings.MEDIA_ROOT:
user_send_last_msgs = Message.objects.\
filter(user_sender=token.user_id).\
order_by('-send_date', 'user_receiver').\
distinct('user_receiver')
# distinct('user_receiver') postgres only
user_receive_last_msgs = Message.objects.\
filter(user_receiver=token.user_id).\
order_by('-send_date', 'user_sender').\
distinct('user_sender')
for message in last_msgs:
print message.user_sender
print message.user_receiver
print message.send_date
print message.message
print message.status
[dbag]
chdir = /home/dbag/dbs/mtest
virtualenv = /home/dbag/venv/
socket = /home/dbag/dbs/dbs.sock
vacuum=True
max-requests=10000
harakiri=60
daemonize=/home/dbag/dbs/uwsgi.log
master = True
workers = 8
module = mtest.wsgi:application
uid = dbag
gid = dbag
chmod-socket = 600
#myuserapp/models.py
class MyUser(AbstractUser):
....
#app1/models.py
from myuserapp.models import MyUser
class MyThingInApp1(models.Model):
user = models.ForeignKey(MyUser)
....
#app2/models.py
from myuserapp.models import MyUser
class MyThingInApp2(models.Model):
user = models.ForeignKey(MyUser)