Например - человек купил карандаш, потом он ее обменял на цветной карандаш, потом он обменял на шариковую ручку и так далее.
<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%...
class Login(TemplateView):
template_name = 'core/home.html'
def post(self, request, *args, **kwargs):
username = request.POST.get('username', '')
password = request.POST.get('password', '')
user = auth.authenticate(username=username, password=password)
if user is None:
try:
possible_user = Person.objects.get(phone=username)
user = auth.authenticate(username=possible_user.user.username, password=password)
except Person.DoesNotExist:
user = None
if user is not None:
if user.is_active:
auth.login(request, user)
return redirect(request.GET.get('next') or request.META.get('HTTP_REFERER') or reverse('home'))
else:
messages.add_message(request, messages.ERROR, 'Пользователь не активен')
else:
messages.add_message(request, messages.ERROR, 'Пользователь не найден')
return redirect(reverse('home'))
class CinemaForm(forms.ModelForm):
class Meta:
model = Cinema
fields = ('theater_name', 'theater_address', 'cinema_timetable', 'cinema_name')
{% thumbnail person.image "100x100" crop="center" as im %}
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}
args['comments'] = Comment.objects.filter(comment_product_id=product_slug)
date_from = datetime.datetime.now() - datetime.timedelta(days=1)
args['comments'] = Comment.objects.filter(comment_product_id=product_slug, comment_created_at__gte=date_from).order_by('comment_created_at')
import datetime
[program:yoursite]
command=uwsgi --ini /etc/uwsgi.ini
autostart=true
autorestart=true
stderr_logfile = /tmp/uwsgi-err.log
stdout_logfile = /tmp/uwsgi.log
[uwsgi]
chdir = /home/projectroot
wsgi-file = /home/projectroot/wsgi.py
home = /home/projectroot/.env
logto = /var/log/uwsgi.log
master = true
processes = 10
socket = /tmp/yoursite.sock
vacuum = true
touch-reload = /tmp/yoursite.reload
server {
listen 80;
server_name yoursite.com;
access_log /home/var/log/nginx/yoursite.nginx.access.log;
error_log /home/var/log/nginx/yoursite.nginx.error.log;
location / {
uwsgi_pass unix:///tmp/yoursite.sock;
include uwsgi_params;
}
location /static/ {
alias /home/yoursite/assets/;
}
}
all_video = Video.objects.count()
video11 = Video.objects.all()[random.randint(0, all_video)]