0
votes
0answers
13 views

Django FieldError and AttributeError exceptions after adding new field to model

I'm writing a multipurpose web application, and the data model is somewhat in flux. I have a class Client defined as class Client(models.Model): client = models.IntegerField(primary_key=True, ...
0
votes
2answers
27 views

Django model export on MySql server

I imported the external database into my project , thereby converting it to models.py file using python manage.py inspectdb > models.py command. Now I have edited the models.py file by adding ...
-2
votes
1answer
24 views

How to add django model fields after definition

I have a simple django model: class Country(models.Model): name=models.CharField(max_length=500) iso_alpha3=models.CharField(max_length=3) I need to add a new field 'default_city' after the ...
2
votes
1answer
37 views

Django Manual Debugging Process Flow

I am in the processing of developing a Django application. I had spent around 40-50 hours researching Django, and I am well on my way to making an application! However, I am starting to come across ...
0
votes
1answer
22 views

Django INNER JOIN with GROUP BY queryset

How can I get the following SQL queryset in Django? SELECT abbreviation, COUNT(tat_value) FROM t_tat INNER JOIN t_tests ON t_tat.test_id = t_tests.test GROUP BY test These are my class models: ...
0
votes
3answers
25 views

How to add a calculated field to a Django model

I have a simple Employee model that includes firstname, lastname and middlename fields. On the admin side and likely elsewhere, I would like to display that as: lastname, firstname middlename To ...
1
vote
3answers
26 views

django - 1. select 2. filter 3. then cut

I am trying to do this logic: 1. take all objects 2. filter them: all objs which has rate value >= 4 3. then take randomly 4 out of them. how can i take randomly 4 out of them? not just ...
-1
votes
0answers
23 views

How to put User label restriction in Django 1.3

I am developing a site in Django 1.3 where I have 2 kind of users i.e Superuser and Client. I am using Django's own user model, and I have also created a UserProfile model where I am storing user's ...
0
votes
1answer
23 views

Pagination works improper and creates error

I am making a Django Project, a Business Directory. Here I used the Pagination in the HTML page. But I am getting an error which says: KeyError at /crawlerapp/search/" I am following the ...
-2
votes
4answers
39 views

Alternative for Absolute Path in Django

I am making a Django Project, A Business Directory. Here I have used ABSOULATE PATHS for Template rendering, I thnk this might create problem in future. Please look into my codes and Suggest me how to ...
1
vote
1answer
30 views

Recursive Relationship with a Description in Django Models

My project involves sorting many images. As part of this sorting, I want to be able to manually (as the user) mark several images as duplicates of each other with a brief description of why each ...
-1
votes
1answer
15 views

Foreign Key not Responding while fetching, Django

I am making a Django Project, A Business Directory. In which while fetching data from DB, I am unable to fetch the data related to Foreign Key, Please help my models.py is:: from django.db import ...
0
votes
0answers
22 views

Sort objects by its one-to-many fields in django

I'd like get the newest thread of a given user. Currently, I query t_array = Thread.objects.filter(participants=user) Message.objects.filter(thread__in=t_array)[0].thread Is there a better way to ...
-1
votes
1answer
24 views

Directory Model not working

I need to make a project which says:: Crawl and Display Take this page - http://directory.thesun.co.uk/find/uk/computer-repair Write a crawler using Scrapy, that will extract all the businesses ...
0
votes
2answers
49 views

Relate image model with similar images

In a django application, I will have a database of images all classified under the image class in my models.py. Unfortunately there is a possibility that some of these images are duplicates of each ...
0
votes
1answer
13 views

Extract Image Metadata in Django

I am trying to extract EXIF and XML data from many different types of images- JPG, PNG, etc. I am defining a class named image in my models.py file as follows: class image(models.Model): image = ...
0
votes
1answer
42 views

Saving custom user model with django-allauth

I have django custom user model MyUser with one extra field: # models.py from django.contrib.auth.models import AbstractUser class MyUser(AbstractUser): age = ...
0
votes
0answers
35 views

How can I get all models filtering by tag name in Django?

Basically I want to get a list of Post models, filtering them by the Tag objects contained in Post.tags Here's my dumbed-down code: def post_list(request, **kwargs): posts = ...
0
votes
1answer
32 views

How to query multiple Django models describing denormalized tables

I'm trying to extract information from a number of denormalized tables, using Django models. The tables are pre-existing, part of a legacy MySQL database. Schema description Let's say that each ...
0
votes
0answers
23 views

Fixing Memory Leak in Django + Scikit-learn

How do you diagnose and fix memory leaks involving Django and Scikit-learn? I'm working on a Django management command that trains several text classifiers implemented using scikit-learn. I'm using ...
0
votes
1answer
27 views

Prepairing list from a django query

I have a table where 5 columns are present, lets say col_a, col_b, col_c, col_d, col_e. In that table I have 20 records. I want to write a django query which will return me 2 separate lists which will ...
0
votes
1answer
27 views

what about saving extra variable in a QuerySet?

for example i have a queryset say folder=Folder.objects.all(). what about saving some extra variable in it say for i in folder: i.fcount = 33 so that i can use it in templates easily like: ...
2
votes
3answers
30 views

Django execute task on time specified in model datetime field

got a simple question, I believe, but it got me stuck anyways. Say I have a simple model: class myModel(models.Model): expires = models.DateTimeField(...) and I want, say on the specified time ...
0
votes
2answers
30 views

Making portable Nodes in Django and using them to make Trees

What I am trying to make is something that can be done quite simply using pointers in C++. The idea is this, I have an object, and it is called a Node. This node will have a couple of characteristics: ...
0
votes
2answers
38 views

evaluate list to Object attributes in python / django

I just started with python and django and looking for a possibility to iterate through an objects attribute, to realize a search function over all fields. The diff object classes an inheriting from ...
0
votes
1answer
42 views

Django users can only login if Boolean is set to true

I currently have a Poster model which is a ForeignKey to the Django user model. class Poster(models.Model): user = models.OneToOneField(User, primary_key = True) bio = ...
1
vote
0answers
24 views

Django: Cannot resolve keyword on generic relationship

I want to filter my generic relationship by user i.e. Entry.objects.filter(content_object__user=request.user) But I get this message: Cannot resolve keyword 'content_object' into field. Choices ...
1
vote
2answers
40 views

How to create Password Field in Model django

i want to create password as password field in views. Please can someone help me? Thanks in advance **models.py** class User(models.Model): username = models.CharField(max_length=100) ...
1
vote
2answers
30 views

Django annotate() performance - is it supposed to be super slow?

Is it normal for annotate() to make things slow to a crawl? Using annotate like this: post_list = j.post_set.all().annotate(num_comments=Count('comment')).order_by('-pub_date') Made it take four ...
1
vote
2answers
43 views

Why does Django's User Model set the email field as non-unique? [duplicate]

I am using Django's default User model and the email is not unique, now I have multiple users with the same email address. You can have User_A with email address [email protected], and then a new ...
1
vote
2answers
35 views

Where to put helper functions when not using models and an ORM?

I have to use PyMongo in a Django project, althought I have always used either Django's ORM or Mongoengine. With the old setup, every model had its own method which did some actual work. This time, ...
1
vote
2answers
134 views

menu tab highlighting issue in Django

views.py def edit_report(request, report_id): """Edit report navigation from action needed screen """ user = request.user if 'report_id' in request.session: del ...
0
votes
0answers
17 views

Django formfield_overrides for ForeignKey

I want to set custom widget for a certain model in admin panel. I have a following structure: class ChildForeignKey(ForeignKey): pass class Question(Model): category = ...
1
vote
0answers
41 views

Store files in database as base64 encoded string

I use following model to store files in database in django app: class Data(BaseModel): _data = models.TextField( db_column='data', blank=True) def set_data(self, ...
0
votes
0answers
42 views

Why is this Django model method not added to the model class?

I have a simple model named Ingredient which multiple profiles (instances of the class IngredientProfile) can be linked to. class Ingredient(models.Model): name = ...
0
votes
1answer
24 views

Django Admin: when displaying an object, display a URL that contains one of the fields

Here is an abstract base class for many of my "Treatment" models (TreatmentA, TreatmentB, etc): class TreatmentBase(models.Model): URL_PREFIX = '' # child classes define this string code = ...
0
votes
0answers
47 views

calling single save function on two button click

who.html <form method="post" class="treatment-form" id="{{ report_person.report_person.id}}" > {% csrf_token %} <table width="100%" id="list"> <tr id="head-{{ ...
-1
votes
0answers
48 views

How to debug English datetime formats on an otherwise fully French website?

I have a fully working French website. All the apps I use are in French (for instance, django-cms). I do not need anything in English (viz. it is a monolingual site). The Problem Datetime formats ...
-1
votes
1answer
23 views

Django Image file upload default to random images

My use-case wants that if a user does not upload an Image I choose an image randomly from a pool of images created by the administrator. That pool of images contain the ones uploaded by admin using ...
0
votes
1answer
20 views

how do i alter an uploaded file in django before its saved to “uploaded_to”?

i have a form like this: from django import forms from manupulators import Replacer class ContentForm(forms.Form): csvfile = forms.FileField( label='Select content file') txtfile = ...
1
vote
1answer
34 views

compare datetime with DateField for equivalency?

import datetime as dt dt.datetime.strptime( '2000', '%Y' ) creates a date object, which I can put into a django models.DateField( ) but, once the DateField is committed to the database, I am not ...
0
votes
2answers
31 views

Can we resize an ImageField from inside a validation function in Django?

Is it legal to modify data from inside a validation function in Django? I need to autoresize images from ImageFields. In the docs it says that these kind of functions should raise ValidationError, ...
0
votes
0answers
14 views

Issue with multisite setup django

I made a setup for the multiple sites in django. Sites were working absolutely fine a few days back .But there is a issue now that while I try to open a specific site the template designs mix up . ...
0
votes
0answers
38 views

Error while creating a model in Django

I am currently reading The definitive guide to Django, and came across an unexpected error. I set my database as sqlite3 and tested it. So far so good. First, I created the an app with the following ...
1
vote
2answers
25 views

counting self referencing many to many field

I have the following self referencing model that gives who this profile supports. supports = models.ManyToManyField('self', blank=True, symmetrical=False, ...
1
vote
1answer
22 views

Django foreign key model is not saving reference

I am having an issue on saving my model, my UserProfile reference on a foreign key to a Customer, and I have gotten sure that my form in sending the needed info and the customer object is being ...
1
vote
2answers
42 views

Django: Iterating over multiple instances of a single model in a view

I'm relatively new to Django and face a problem that I couldn't solve yet: I have two models which look like: class Item(models.Model): char1 = models.CharField(max_length=200) char2 = ...
0
votes
0answers
53 views

DJANGO: Multiple models of same type

As the question states, I want to create multiple models of same type. Let's say I've got this simple class for sensor data: class Sensor_data(models.Model): value = models.FloatField() ...
0
votes
1answer
40 views

search and export the data in .csv format using django

In my application i am using a search function which search and display the output.I include search for fromdate and todate,Keyword search etc. I want to export the searched result in a .csv ...
2
votes
4answers
125 views

How to restrict Foreign Key choices to another Foreign Key in the same model

I'm making a django application and I'm facing an issue. I am trying to define a model where one ForeignKey would be depending on another ForeignKey. Description part My application is about making ...

1 2 3 4 5 43
15 30 50 per page