Category "django"

Fetch Data from DB in base template Django Python

I am developing an application (simple online store) with Python Django I have created a base.html file in templates and then all other html files extends from

Getting a JSON request in a view (using Django)

I am trying to set up a view to received a JSON notification from an API. I'm trying to figure out how to get the JSON data, and I currently have this as a star

Getting Error with django - Field 'id' expected a number but got '{}'

I'm coding a book store and on the single product page above the title of the book I have a link that directs the customer to the author profile page. The link

Django, show ValidationError in template

I create a registation app, where users can register providing a username, email and a password. What I did is make sure that the email field is unique(as you c

ImportError : cannot import name 'ugettext_lazy'

I'm trying to install suit, I entered this command : pip install https://github.com/darklow/django-suit/tarball/v2 and wrote this code : from suit.apps import D

Why can't I add a ManyToMany relation to an object in Django?

I've got an api made in Django which has two models linked by a ManyToMany relation. class Type(models.Model): name = models.CharField(max_length=64) ap

Change a Django form field to a hidden field

I have a Django form with a RegexField, which is very similar to a normal text input field. In my view, under certain conditions I want to hide it from the use

'choices' must be an iterable containing (actual value, human readable name) tuples

Having an error when trying to set choices on model field. Here's the code: TICKET = 'TICKET', TICKET_HISTORY = 'TH' TICKET_RATE = 'TR' PASSWORD_CHANGE = 'PASS

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(