What is a "slug" in Django?

When I read Django code I often see in models what is called a "slug". I am not quite sure what this is, but I do know it has something to do with URLs. How and when is this slug-thing supposed to...

Problems with contenttypes when loading a fixture in Django

I am having trouble loading Django fixtures into my MySQL database because of contenttypes conflicts. First I tried dumping the data from only my app like this: ./manage.py dumpdata escola >...

Django: add image in an ImageField from image url

please excuse me for my ugly english ;-) Imagine this very simple model : class Photo(models.Model): image = models.ImageField('Label', upload_to='path/') I would like to create a Photo from...

model not showing up in django admin

I have ceated several django apps and stuffs for my own fund and so far everything has been working fine. Now I just created new project (django 1.2.1) and have run into trouble from 1st...

Overriding _get_url() from ImageField

I'm looking to the best way to overriding the _get_url method from ImageField, I need to customize the url since I don't want the default returned url (I distribute this image trhough a view to...

Is there a python implementation to .net automapper?

Automapper is a object-object mapper where we can use to project domain model to view model in asp.net mvc. http://automapper.codeplex.com/ Is there equivalent implementation in Python for use in...

Django Unique Together (with foreign keys)

I have a situation where I want to use the Meta options of unique_together to enforce a certain rule, here's the intermediary model: class UserProfileExtension(models.Model): extension =...

Django search multiple filters

Lets say I have a model models.py class user: name = models.CharField(max_length=25) class job: job_name = models.CharField(max_length=25) class user_job: user =...

Override update method for a queryset - Django

How can we change the default process of the update method for a queryset in django as it does not call save method for each object. And since I have overridden the save method, I need it to be...

django - comparing old and new field value before saving

I have a django model, and I need to compare old and new values of field BEFORE saving. I've tried the save() inheritance, and pre_save signal. It was triggered correctly, but I can't find the...

Catch exception on save in Django admin?

I have a pre_save signal handler on a bunch of models, which write to a different database. If something goes wrong, I'd like to abort the whole save, or failing that give a message to the...

Django 1.9 tutorial __str__ () not working

I am trying Django 1.9 tutorial with Win 10 os and Python 3.5 and Django version is 1.9. I have successfully created and stored values in "Question" and "Choice". After this when i have changed...

django 1.9 not creating table for custom user model

My project name is timecapture Here is relevant portion of timecapture/settings.py INSTALLED_APPS = [ # 'django.contrib.admin', 'django.contrib.auth', ...

How to create factory-boy factories for Django models with the same foreign key

I keep running into issues with my factories when two or more models have a common foreign key, and each one creates their own object when they should have the same. To illustrate the problem,...

This QueryDict instance is immutable

I have a Branch model with a foreign key to account (the owner of the branch): class Branch(SafeDeleteModel): _safedelete_policy = SOFT_DELETE_CASCADE name =...

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. (django 2.0.1)(Python 3.6)

It's my first time trying to deploy a Django app(django 2.0.1)(Python 3.6) to pythonanywhere, it is a simple portfolio app with no models, no bootstrap. Just Django, HTML, CSS & Javascript. After...

Django or Django Rest Framework

I have made a certain app in Django, and I know that Django Rest Framework is used for building APIs. However, when I started to read about Django Rest Framework on their website, I noticed that...

django postgresql tests.py RuntimeWarning error

I have a Django app that adds and displays stuff to my postgresql database online at elephantsql.com. My project file setup looks like this: website/ website/ music/ playlist/ ...

How to reassign a model to a different app for display only purposes in Django Admin

I know I can change the display title for a model in Django Admin using class Meta: verbose_name='Custom Model Name Here' However, is there a way to display which app heading a model...

celery with django error when doing a db query via task: DatabaseWrapper objects created in a thread can only be used in that same thread

Stack: Django 3.0.2 python 3.8.1 celery 4.4.0 redis 3.2.0 command to start celery: celery -A app_project worker -l info I am using celery to run background tasks in my django project. On...

Django stubs interrupt Pycharm autocompete

I have a django app with several models. Here is autocomplete when I filter objects Then I install django-stubs for MyPy pip install django-stubs Now my autocomplete looks like this When I...

How to use date widget in django-import-export?

I'm new to programming so please bear with me in case I ask silly questions. I'm working on my first project which will gather data from Excel file. I'm trying django-import-export for that...

Storing factory-boy RelatedFactory Object on Parent Factory

I have two Django models (Customer and CustomerAddress) that both contain ForeignKeys to each other. I am using factory-boy to manage creation of these models, and cannot save a child factory...

sending images using Django Channels

I have a common chat message model in my Django project. The Message model looks like this: class Message(models.Model): writer = ... chatroom = ... body =...

Aggregate number of likes for each day within period

I am building a REST Api on Django RF which represents a very basic social network. I have a model Post that has a value Likes which is related to a User by many to many through a Like model. My...

Exception Value: (1054, "Unknown column 'social_auth_usersocialauth.created' in 'field list'")

When trying to implement Django Social, I think i missed a migration somewhere and now when I get a twitter redirect to the site I get the following error. Exception Value: (1054, "Unknown column...

Django channels: Save messages to database

I'm a newbie to channels and I made a chatroom application by following their official documentation. Now I'm trying to save the chat messages. All I know is I can create a model but Idk how to...

Django-modeltranslation ValueError: Error adding translation field. Model already contains the field

I'm trying to implement localisation in a Django project by using django-modeltranslation. The documentation is pretty clear and straightforward and I've followed it to use it in my project. The...

I changed the session cookie name in my django project and I am unable to login

I want to change the SESSION_COOKIE_DOMAIN because it's set incorrectly on a production server. Due to this, I also need to change the SESSION_COOKIE_NAME to something else. Otherwise, there'll be...

Django TypeError - TypeError: issubclass() arg 1 must be a class

I want to migrate my config in django application, but below console isn 't working. python3 manage.py migrate python3 manage.py makemigrations Traceback (most recent call last): File...