Category "django"

Django - Adding initial value to a formset

I have a many-to-many relationship between two classes (Lesson and Student), with an intermediary class (Evaluation). I am trying to set up a form which will a

scoped_session(sessionmaker()) or plain sessionmaker() in sqlalchemy?

I am using SQlAlchemy in my web project. What should I use - scoped_session(sessionmaker()) or plain sessionmaker() - and why? Or should I use something else?

Why is cleaned data returning an exceeded value length from the registration form?

I have a custom user model that has a username field with a max_length=50. Under the custom registration form, it throws me an error when the value of the usern

Django ModelAdmin Fieldset within fieldset

What I've been asked create is an admin page with the following layout: Fieldset 1 name Section 1 name field 1 field 2 Fieldset 2 name Section 2 name field

should changes of translations in django rosetta propagate automatically to frontend?

When I make or alter translations in Rosetta in Django backend, the po and mo files get updated. However, I don't see them directly show up in the frontend. T

How to test a Django form with a ModelChoiceField using test client and post method

How do I use Django test client.post to test a form that has a ModelChoiceField? How should the data dictionary passed to the post method be written? The way I

Heroku Foreman errors on 0.0.0.0:5000

I am trying to debug this issue using Heroku's Foreman app. My issue is that Foreman is trying to run the process on port 5000 and at ip address 0.0.0.0. It s

Heroku Foreman errors on 0.0.0.0:5000

I am trying to debug this issue using Heroku's Foreman app. My issue is that Foreman is trying to run the process on port 5000 and at ip address 0.0.0.0. It s

django manytomany - get value from through

I have a manytomany field between 2 models: class userProfile(models.Model): boughtCoupons = models.ManyToManyField(Coupon, through='UserCoupons') class U

Remove or expire cache from Django queryset

I have a Django project that have a large amount of transactions. Much queries. When using Django querysets they get cached, if I have understood it correctly.

django filter by datetime on a range of dates

I have a model with field "created_at", and I have a list of dates. So, I want to get all the models that are created in the date range. How ? I know that w

How to make a query on related_name field?

I have to models connected by a ForeignKey class User(AbstractUser): ... and class PrivateMessage(models.Model): user_from = models.ForeignKey(

Create several instances out of a related model in Django

In university as a part of a project we have to develop a liga system with Django. I have my basic app running and also my models are already set up. from djang

Trouble setting cache-cotrol header for Amazon S3 key using boto

My Django project uses django_compressor to store JavaScript and CSS files in an S3 bucket via boto via the django-storages package. The django-storages-relate

Trouble setting cache-cotrol header for Amazon S3 key using boto

My Django project uses django_compressor to store JavaScript and CSS files in an S3 bucket via boto via the django-storages package. The django-storages-relate

How to get the objects from child model to a django template?

I have created child ('Bid') model related to a parent(Post) model in my Django project. I also created a BidForm which I have added in my B_Bid.view so that ty

Can I make a django model object immutable?

There are places in my code where I want to temporarily change some of the attributes on a model object without changing the data in the database. Obviously Dja

Django Rest framework, how to include '__all__' fields and a related field in ModelSerializer ?

I have two models, one with M2M relation and a related name. I want to include all fields in the serializer and the related field. models.py: class Pizza(mode

django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed

After migrating my django and userena packages like below Django 1.8 to Django 1.9.7 django-userena 1.4.1 to django-userena==2.0.1 After running the

ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication'

I am trying to deploy a django app on GCP but when i try to make migrations it gives me this error: ImportError: Could not import 'rest_framework_simplejw