Category : django

I am trying to start a new django project and I have decided to split my settings into production, staging and development following this tutorial https://simpleisbetterthancomplex.com/tips/2017/07/03/django-tip-20-working-with-multiple-settings-modules.html On running python manage.py runserver –settings=mysite.settings.development,I get this error File "/home/user/crosspoint/crosspoint-venv/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/home/user/crosspoint/crosspoint-venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 61, in execute super().execute(*args, **options) File "/home/user/crosspoint/crosspoint-venv/lib/python3.6/site-packages/django/core/management/base.py", line 398, ..

Read more

i have option that allow user to change email in his profile but without confirm new email so when he enter new email i want activate email to save it in his profile , how to add confirm i am using UserCreationForm models.py : from django.db import models from django.contrib.auth.models import User from django.db.models.signals import ..

Read more

/tmp/8d9010f9ad09a86/antenv/lib/python3.7/site-packages/django/core/handlers/exception.py in inner response = get_response(request) … ▶ Local vars /tmp/8d9010f9ad09a86/antenv/lib/python3.7/site-packages/django/core/handlers/base.py in _get_response response = self.process_exception_by_middleware(e, request) … ▶ Local vars /tmp/8d9010f9ad09a86/antenv/lib/python3.7/site-packages/django/core/handlers/base.py in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) … ▶ Local vars /tmp/8d9010f9ad09a86/antenv/lib/python3.7/site-packages/django/views/generic/base.py in view return self.dispatch(request, *args, **kwargs) … ▶ Local vars /tmp/8d9010f9ad09a86/antenv/lib/python3.7/site-packages/django/utils/decorators.py in _wrapper return bound_method(*args, **kwargs) … ▶ Local vars /tmp/8d9010f9ad09a86/antenv/lib/python3.7/site-packages/django/views/decorators/cache.py ..

Read more

I get KeyError when I post and I don’t write either email or telephone. In my code, either email or telephone are required but not both of them. Why is this happening? This is the serializer: class OrderSerializer(serializers.ModelSerializer): class Meta: model = order fields = ‘__all__’ extra_kwargs = { ’email’: {‘required’: False}, ‘phonenumber’: {‘required’: False}} ..

Read more

I have a problem, probably in my design. In my Django project I have a ‘Flow’ object with ‘event_reason’ field in it, Foreign key to ‘Event’ object, therefore I need to import Event object, (otherwise I get the error: Cannot create form field for ‘event_reason’ yet, because its related model ‘Event’ has not been loaded ..

Read more

I have to fetch the total wrote posts number by each user @staff_member_required def counter(request): posts = Post.objects.all().count() users = User.objects.all() for user in users.iterator(): num = user.username written_posts = Post.objects.filter(author=user).count() context = {‘users’: users, ‘written_posts’: written_posts, ‘posts’: posts, ‘num’: num} return render(request, ‘account/counter.html’, context) But it returns me for all users the same user’s ..

Read more