in my settings.py my middleware is MIDDLEWARE_CLASSES = [ "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.
i am getting error django model like this when i try to makemigrations: You are trying to add a non-nullable field 'person' to owner without a default; we can't do that (the database needs something to populate existing rows). Please select a fix: 1)
I have two models in my Django app class Product(models.ModelField): name = ... class Discount(models.ModelField): product_id = models.OneToOneField(Product) Basically, each product can have an optional discount.Now, assume I have only one product p
I am trying to create a form where users will be allowed to upload any image file + SWF files. Django's ImageField does not support SWF so I need to override it. What I want to do is to check if the file is SWF, if True, return it. If it's not SWF, c
So I have a model that looks like this def create_invite_code(): return str(uuid.uuid4())[0:8] class InviteCodes(models.Model): id = models.CharField(max_length = 36, primary_key = True, default=build_uuid) code = models.CharField(max_length=8, uniqu
How to do syncdb in django 1.4.2? i.e. having data in database, how to load the models again when the data schema is updated? Thanks in advance --------------Solutions------------- As you're using an older version of django you'll need to install the
I am trying to figure out how to create Person model from the data I get from a small application I created called "survey". The survey application uses a SessionWizardView which splits a survey over multiple pages. I keep getting this error Fil
I have a filter to list method that works, and can be used, but when i try to make and order_by on the list, in can't be done. How can i do this and keep the queryset to make a order_by after the filter is applied, I don't know of there is a better w
Looking for a way how to assign a ModelAdmin instance to a different then a default application label, even in latest Django 1.8 . Django project schema: <root>/appone/models.py # class ModelOne(django.db.models.Model) <root>/appone/admin.py #
I'm trying to make User based instances for blog posts but all my tries keep showing all the posts for every user. For example, I make a new post and publish it. All the posts show up for every user instead of only the user that is logged in. models.
I'm trying to update my django model which is an extension of User (OneToOne relation). The update form is redirecting me to the user form and says that all user fields are required. Here is my code: Models.py class Client(models.Model): """
I have model with two fields: class Event(models.Model): date = models.DateField(_(u'Date')) time = models.TimeField(_(u'Time')) I need to find all objects where date&time is in 24 hours from now. I am able to do this when using DateTime field, but I
i have a model patient and another one exam, now i want to retrieve patient's exams based on the name, but i am stuccoed with the error invalid literal for int() with base 10: 'John Doe' ValueError at /labtech/John Doe/see_exam invalid literal for in
Is there a way to do some CRUD operations on Django ORM models using different language, with or without some kind of REST API, and some examples? A REST API is what comes to mind, but I wonder if there alternatives to REST.
I have three vaiables first_name, last_name and middle_name. To filter the result I am doing Q(contact__first_name__icontains=query) | Q(contact__last_name__icontains=query) | Q(contact__middle_name__icontains=query) I instead want to be able to sear
I understand the role of Managers in Django when listing or filtering data. However, when it comes to saving data on the model I often see the following two ways used... Using a Manager: class Project(TimeStampedModel): stuff def save(self, **kwargs)
In Django 1.7, I am trying to make a user panel in which userprofile info (like avatar, country, etc.) are to be displayed along with their topics. Here is the view: def topic(request, topic_id): """Listing of posts in a thread.""
sorry for my poor english, my problem is: I try to update the PK in Django with the method .save() but when i save the object Django duplicate the object withe the same data but differetn PK, example: from gestion_empleados.Models import Empleados >>
I have a model class ' Newsletters'. in which there is a choice for send to like student, teacher etc. I want to get all email of student or teacher whatever the user selected, then after save button is pressed, get the id of currently saved newslett
I implemented my own User class from scratch in Django. But when I log in I have this error: The following fields do not exist in this model or are m2m fields: last_login I really don't want the field last_login. I do some reasearch and the problem i