0
votes
1answer
23 views

User.DoesNotExist - catch exception value

I am trying to write a confirm function to confirm the registration by a user. Simple logic: A user registers and gets an email. During registration I create hash value to make sure all users have ...
1
vote
4answers
36 views

Returning a Unicode string vs. Returning a normal string encoded as UTF-8?

On the tutorial page for the Django web framework, the author explains why adding a __unicode__() method is preferred than a __str__() with the following reason: Django models have a default ...
0
votes
0answers
15 views

Django unique_together breaks group_by with annotate(Count('column'))

I'm using Django 1.5 and my Django model looks something like this: class MyModel(models.Model): other_model = models.ForeignKey(OtherModel, related_name='%(class)s_set') number = ...
1
vote
1answer
28 views

django integrity error, i know why, but dont know how to solve

I changed my former user model so that now it inherits from django's user model. from django.contrib.auth.models import User class UserProfile(User): #fields.. but other models were pointing to ...
0
votes
0answers
20 views

user_id not in auth_user table after changing UserModel

I have had normal custom user model. I have many users also in database and other models pointing to this user model. Now i changed the user model so that it inherits from django's user model. I did ...
0
votes
0answers
26 views

Django-Grappeli: Maximum recursion depth exceeded

I have installed Grappelli Cms of Django.As https://django-grappelli.readthedocs.org/en/2.4.5/quickstart.html#installation After that installation,when I call the admin page the error is: ...
0
votes
1answer
35 views

Django datetime primary key doesn't constrain unique

So, here's my model: class MyModel(models.Model): timestamp = models.DateTimeField(primary_key=True) fielda = models.TextField() When I call syncdb, django doesn't add a constraint to ...
0
votes
1answer
30 views

checkbox checked on pageload and form post

forms.py class SearchKeyword(Form): status = forms.BooleanField(widget=forms.CheckboxInput(attrs={'onclick':'this.form.submit();','id':'status'}),required=False,initial=True,label="Status") ...
0
votes
0answers
31 views

Not able to show all reports for limited account holder

models.py class Members(models.Model): user = models.ForeignKey(User, related_name = 'user_list' ) member = models.ForeignKey(User, related_name = 'memer_list' ) views.py ...
0
votes
0answers
22 views

Admin Site Customisation using many-to-many recursive models in Django 1.4 and querying questions

I have this in models.py of accounts app, I have a UserProfile class so that I can add more fields to the normal User class. I also create a UserFollowing class(table) which stores the user_id of the ...
2
votes
4answers
38 views

Integer field prefix zero not displaying

forms.py class PhoneForm(forms.ModelForm): number1 = forms.IntegerField(required=False,error_messages={'invalid':'Enter a valid phone number'}) number2 = ...
2
votes
1answer
27 views

Loading fixture with many-to-one relations in Django

The Django tutorial on djangoproject.com gives a model like this: import datetime from django.utils import timezone from django.db import models class Poll(models.Model): question = ...
1
vote
1answer
19 views

Editing the model object with update view django by excluding fields

I am trying to Edit/Update a model object(record) using django Updateview model.py from django.db import models from myapp.models import Author class Book(models.Model): author = ...
0
votes
2answers
111 views
+50

Ajax succesfull call show div with form data

ajax: $('.openDiv').click(function (e) { e.preventDefault(); var csrf_token = $("#csrf_token").val(); var id = $(this).closest('td').attr('id'); var firstname = ...
0
votes
1answer
34 views

issue in if condition loop

template.html In django is it possible to check condition like this,I am getting error in this line (incident.other_location or location). {%if newreport_tab and reportperson and ...
0
votes
1answer
29 views

How to open a form in editable mode

models.py class UserProfile(models.Model): user = models.OneToOneField(User) phone_daytime = models.CharField(max_length=50, null=True, blank=True) class User(models.Model): first_name = ...
0
votes
1answer
51 views

django - Use foreign key for multi-table inheritance

I am stuck in an odd position in my database design, and I would appreciate some comments. We are using django-shop for an e-commerce platform. There is a base class defined for products: from ...
0
votes
1answer
30 views

django user_passes_test decorator is_superuser

Initially i was restricting the permission for all user with the help of is_superuser flag,and i used @user_passes_test(lambda u: u.is_superuser) decorator.Now i am not using is_superuser flag and ...
0
votes
1answer
24 views

In Django is it possible to default an integer field based on a float field?

Looking to create default based on another field, something along the lines of: class Track(models.Model): distance = models.FloatField() timeout = ...
1
vote
1answer
42 views

Django Query only one field of a model using .extra() and without using .defer() or .only()

I'm using django ORM's exact() method to query only selected fields from a set of models to save RAM. I can't use defer() or only() due to some constraints on the ORM manager I am using (it's not the ...
2
votes
1answer
25 views

Passing np.array indexes into functions

I have a Django model which provides access to numpy array. I want to create a generator which accepts two arguments: A Queryset of the model I just mentioned, and A numpy array slice/index syntax ...
3
votes
1answer
24 views

Django filter on related field using annotate

I want to filter using annotate. Here is my code: class Blog(models.Model): name = models.CharField(max_length=100) class Reader(models.Model): name = models.CharField(max_length=50) ...
0
votes
2answers
120 views

create row of date while creating superuser

models.py TITLE = ( ('Classroom', 'Classroom'), ('Playground', 'Playground'), ('Staff Room','Staff Room'), ) class Location(models.Model): user = models.ForeignKey(User,null=True) ...
2
votes
1answer
38 views

Django User Sessions, Cookies and Timeout

I'm working with a Django application and my current goal is to keep track of the user session with cookies. I have a feeling that, as always, my understanding is a bit off with regards to how I do ...
1
vote
1answer
34 views

Is it possible to add a datetime column to a manytomany field?

I was wondering if there was a way to add a datetime auto_now_add=True column to a manytomany field. I have the following model. class Photographer(models.Model): user = ...
1
vote
1answer
20 views

Trigger An Action Based on value change of DateTimeField in Django

I would like to fire an event immediately at/after a certain DateTimeField in a certain model equals the value of datetime.now(). It is a field that marks expiration of a product, so as soon as it ...
1
vote
1answer
32 views

convert database object to string in django

models.py class UserProfile(models.Model): user = models.OneToOneField(User) security_question = models.CharField('Question', max_length=255, null=True, blank=True) security_answer = ...
0
votes
0answers
37 views

from django.db import models is broken in a django standalone crontab script

Before posting this, i'ved tried a wide variety of possibilities for getting this custom script to work (with no success). I have a script in a /lib directory which is being run in the crontab every X ...
0
votes
0answers
22 views

Load dropdown onchange of anyother value inside modelform class

Can we load values of a dropdown dynamically onchange of an event. Let me explain through an example: I am using a model form to dislplay a certain form, below is my form class class ...
2
votes
1answer
47 views

Django admin encoding error

I am trying to add new user with admin interface and get this error: IntegrityError at /admin/main/customuser/add/ ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ: INSERT ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ UPDATE ๏ฟฝ๏ฟฝ ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ๏ฟฝ "django_admin_log" ...
1
vote
1answer
26 views

issue in search and display the report

views.py def search(request): """"""" if 'search' in request.POST: search_keyword = request.POST.get('search_keyword') reports = ...
0
votes
1answer
32 views

Django save or update model

I am using Django 1.5.1 and I want to save or update model. I read the django document and I met the get_or_create method which provides saving or updating. There is a usage like; ...
0
votes
2answers
37 views

how to set username in user model to a random string

views.py def index(request): registerform = UserRegisterForm() if request.method == 'POST': if 'password' in request.POST: registerform = UserRegisterForm(request.POST) ...
0
votes
3answers
56 views

Django .is_superuser field permission

By default from project directory by running manage.py createsuperuser command I am able to create a superuser, but the .is_superuser flag is the default django flag to differ superuser or other user. ...
0
votes
2answers
37 views

Django Model Class Missing in Admin

For some reason, the classes archive and album show all of their fields in the django admin panel, but image isn't showing an album field when I go to add an image to the image panel. If I open a ...
0
votes
0answers
29 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, ...
1
vote
2answers
36 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
28 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
46 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
27 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
38 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
32 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
26 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
25 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
53 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
36 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
23 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
25 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
28 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
52 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 ...

1 2 3 4 5 43
15 30 50 per page