2
votes
3answers
23 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
27 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
33 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
38 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
20 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 ...
0
votes
2answers
32 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
27 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
40 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, ...
0
votes
0answers
49 views
+50
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
25 views
Implementing Exclusionary algorithm with Django querysets
Given two models
class Client(models.Model):
client = models.IntegerField(primary_key=True, db_column = "client_id")
client_name = models.CharField(max_length=100L, unique = True)
parentorg = ...
0
votes
0answers
16 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
29 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
40 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
22 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 = ...
-2
votes
0answers
22 views
Querying Models in Django Two Levels Deep [closed]
I am trying to apply a filter on a Django model with three related tables.
This example helped me out. But I am looking for (in this example) the houses in the street in the town.
models.py
class ...
0
votes
0answers
44 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-{{ ...
0
votes
0answers
44 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
19 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
19 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
35 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
20 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
41 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
52 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
32 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
112 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 ...
3
votes
0answers
57 views
Change model to inherit from abstract base class without changing DB
I have a simple model for a product that looks like this:
class Product(models.Model):
name = models.CharField(max_length=80)
# other attributes
We already have this rolled out, and have a ...
0
votes
1answer
69 views
Count within a count, in Django ORM
Hi I am the following structure
class Vegetable(models.Model):
vegetable_name = models.Chafield(max_legnth = 100)
class Buyer(models.Model):
buyer_name = models.Chafield(max_legnth = 100)
...
0
votes
1answer
33 views
Creating a New OneToOneField for Django Postgres App Using SQL Commands
I have an app with several django/python data models and associated postgres database tables. In this case the important ones are User and Feed.
I need to create a one to one relationship between a ...
-2
votes
1answer
33 views
How do I pass a parameter to views and access all objects?
I'm using the slug as the access point for the url.
http://127.0.0.1:8000/category/blah/ -> blah is the slug.
This is my url code.
url(r'^category/(?P<category>[A-Za-z]\w*)/$', ...
0
votes
2answers
25 views
Django unique, null and blank CharField giving 'already exists' error on Admin page
I've been getting the most weird error ever. I have a Person model
class Person(models.Model):
user = models.OneToOneField(User, primary_key=True)
facebook_id = ...
0
votes
1answer
43 views
How can I create a script where it will print all email addresses of my Django users into a small .txt file?
I have about 6000 users using my Django app. I recently discovered Mailchimp and I would like to push out a message to all of these users about the website going down for a few days.
Instead of ...
0
votes
2answers
25 views
Create a Django model with referencing Models in Manager class
Using Django 1.5 and Python 2.7 and these example models:
class Company(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
class Showroom(models.Model):
...
0
votes
1answer
17 views
How to Update a Many-Many Field in Django [duplicate]
In my django app, my model looks like:
class Tag(models.Model):
title = models.CharField(max_length=50,)
class Publication(models.Model):
title = models.CharField(max_length=200,)
tags = ...
1
vote
1answer
43 views
Is there a way to specify abstract functions which take in values for __init__
I was not sure how to specify this completely in the title, so please forgive me. Essentially, I want to define a method a get_object() method, like the one described here
...
1
vote
3answers
42 views
django user model - when do i need it?
I have one understanding probem:
I want to create user profile for my page, which will have many attributes. But since I am new to User Model of django's auth, i dont know if i can extend that model ...
0
votes
3answers
33 views
Django, retrieving database news items promoting a certain author
I have a database model like this:
class RssNewsItem(models.Model):
title = models.CharField(max_length=512)
description = models.TextField()
image_url = models.CharField(max_length=512)
...
0
votes
2answers
29 views
Changing lookup parameters for Django object query
Two of the models in my Django project are
class ContractPlans(models.Model):
cp_id = models.CharField(primary_key = True, db_column = "ContractPlanId", max_length = 100L)
parentorg = ...
0
votes
1answer
22 views
django Model.objects.raw returns SUM field as Decimal
I have a django model defined as follows:
class Foo(models.Model):
bar = models.IntegerField(null=True)
baz = models.ForeignKey(Baz)
class Baz(models.Model):
bat = ...
2
votes
1answer
32 views
Django Admin Bulk Edit on Many to Many Relationship
In my Django app, I have two models: Publications and Tags. These two models have a many to many relationship:
class Tag(models.Model):
title = models.CharField(max_length=50,)
class ...
0
votes
1answer
30 views
check user credentials in django
I have a Student model which has a one to one field with the default user model.
I have a url like example.com/studentid where student id is an integer value.
I want to know how I can check whether ...
1
vote
2answers
52 views
Sum all values of database column with Queryset Model.objects.aggregate(Sum(***))
So I'm creating an expense sheet app in Django and I'm trying to get the total sum of all the expense costs, which I then want to display in my template.
My Model:
class Expense(models.Model):
...
0
votes
1answer
33 views
save date in one format in database - Django [duplicate]
forms.py
INPUT_FORMAT = (
('%d/%m/%Y','%m/%d/%Y')
)
class ReportDatetimeForm(forms.ModelForm):
date = forms.DateField(input_formats = INPUT_FORMAT,
widget=forms.DateInput()
class Meta:
model = ...
2
votes
2answers
32 views
Django send mail from admin panel
I want to sent email to user's from django admin panel and store the sent mail in database too.I have two usertypes 1.Staff 2. Students. When I select staff and give email, it'll sent email to all the ...
0
votes
0answers
45 views
Django admin issues with empty translated values and unique=True
I'm trying to use django-modeltranslation but I can't get it working well. I'm suffering because Django admin crashes with empty translated values and unique=True. This appears as a closed issue, but ...
1
vote
2answers
53 views
post_save signal and relations
I am applying the post_save signal to apply user rights per object, and then filter the queryset accordingly.
My model is like this:
class Project(models.Model):
# Relations with other entities.
...