This is a pretty simple django patterns question. My manager code usually lives in models.py, but what happens when models.py is really huge? Is there any other alternative pattern to letting your manager code live in models.py for maintainability and to avoid circular imports?
A question may be asked as to why models.py is so huge, but...
I have errors raised in the form's clean method (not tied to a field).
How do I display them in the template?
I tried {{ forms.errors }} and {{ form.non_field_errors }} but neither worked.
...
In my Django webapp, in one location users can upload a text file where each line contains a string which will be operated on - the file isn't being stored on the server or anything like that.
My code looks like this:
roFile = request.FILES['uploadFileName']
ros = roFile.read().strip()
ros = ros.split('\n')
ros = [t.strip() for t in ro...
My plan is to collect data from websites in batches (lawyer bios from each firm's website; since they are all different, I will use a modified spider for each site) and convert each batch into a csv file; then to json; and then load it to database. So I will need to append each new file to the existing database. Please let me know how to...
I'm using django-notification to allow my users to opt out of certain alerts I generate in my web-application.
By default when I create a new notice type it is enabled rather than disabled In the users notification interface (checked)
I'd like to make some alerts opt-in rather than the default of opt out. I've looked through the docs ...
I created a "fixtures" folder in the app directory and put data1.json in there.
This is what is in the file:
[{"firm_url": "http://www.graychase.com/kadam", "firm_name": "Gray & Chase", "first": " Karin ", "last": "Adam", "school": "Ernst Moritz Arndt University Greifswald", "year_graduated": " 2004"} ]
In the command line I cd to t...
After reading monokrome's answer to Where should Django manager code live?, I've decided to split a large models.py into smaller, more manageable files. I'm using the folder structure
foodapp/
models/
__init__.py #contains pizza model
morefood.py #contains hamburger & hotdog models
In __init__.py, I import the mode...
is python exception slow?
I'm kind using python exceptions to structure programm follow in my web application, and I'm wondering how throwing exceptions will affect performance of my application. what is your thoughts?
which one of the following statements is less expensive in terms of memory and cpu?
try:
artist = Artist.objects....
I have a model User which appears as a ReferenceProperty in another model, Group.
When I create a form for Group, using Meta, the form's values contain lots of generated strings. I'd like to stop this, and use the username field of User instead.
I already define a key_name. However, str(user.key()) still gives a generated string. I cou...
So I have installed the new Messages Framework. The documentation mentions using a css class called "messages" in the template. But I can't seem to find any such css class in any of the files in the trunk.
What I want to do is, in the Django Admin, have a red cross, instead of a green v, when displaying an error.
http://docs.djangoproj...
I am new to web development and everything involved with it. Im finishing my website in django and i will soon have to find a hosting and deploy it. I heard there are vps or shared hosting types. So here are the questions:
1. How many visits/clicks per day make it worth choosing vps? shared?
2. How hard is it to tune and maintain a vps o...
I'd like to generate a dynamic Excel file on request from Django. The library pyExcelerator does this, but I haven't found any way to use the contents of the Excel file without generating a server-side temporary Excel file, reading it, using its contents and deleting it.
The problem is that pyExcelerator only way to extract the contents...
In my Django application, I repeatedly run the same query on my database (e.g. every 10 seconds).
I then create an MD5 sum over the queryset I receive and compare that to the MD5 sum I created in the previous run. If both are equal, the data has not changed and the web page does not need updating.
While I do this, the data in the DB mig...
Recently i have implemented django-sphinx search on my website.
It is working fine of each separate model.
But now my client requirement has changed. He wants to display result as
"Title" first from matching query then description and soon.
But i think sphinx give result specific to each model but not gives combine
result of all models...
Suppose I have:
ds = datetime.datetime.now
dd = Entry.objects.get(pk=id).pub_date
How to compare 2 objects above? I want to get the time difference between them.
Please help me solve this problem. Thank you very much !
...
I have five nodes behind a load balancer and I'm trying to determine the optimal configuration for a Django based site.
Each node has access to Postgres, mod_wsgi, Apache, Lighttpd, memcached, pgpool2 (for database replication) and glusterfs(for media file replication) and is running Ubuntu 8.04LTS.
So far, the setup is four nodes runn...
hi,
I'm using Django pagination with jQuery. I can serialize the objects list of the pagination object, but I'd like to serialize the whole object to get more data (page number, total number of pages...).
How can I serialize the whole pagination object?
Thanks
javascript
function getRestaurants(query) {
$.post("/getRestauran...
I having issues getting Django to work with settings.py at different location
I have a folder setting with test.py as copy of settings.py
Folder laid out as
models.py
settings.py
setting/
test.py
this one works with default location
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
python manage.py syncdb --settings="...
What is the best way to skip the delete confirmation page in the Django admin and go straight to deleting the objects?
Thank you!
...
Hello,
I am writing a python website built on the back of the django framework, I am looking for a way to highlight the current link the user is on depening on what the URL, I thought doing some thing like this would work.
What I have done is create a new application called nav and built some templatetags, like so,
from django impor...