I've have a VIEW, which can return either a JSON file or an html template.
Does anybody know how I can use javascript, so the browser can determine
whether the response is either JSON or html text?
I presume that there is something in javascript that can determine the
content-type of the respo
I have a model "OFFER" that has has many to many relationship with a
model "TERMS".
Class OFFER:
terms=models.ManyToMany(Terms)
Assuming I have the following value for 3 records in Term
term1=2
term2=5
term3=8
I want to return ONLY those offers which have ALL three of these terms .
I have the following model:-
class Rank_Advert(models.Model):
advert = models.ForeignKey(Advert)
brand = models.ForeignKey(Brand,verbose_name="brand_owner")
rank= models.IntegerField(default=1,blank=True)
def __unicode__(self):
return self.advert
class Admin:
Just what I was looking for - many thanks
MerMer
Matt McClanahan wrote:
> On Aug 13, 2:11 pm, Merric Mercer <[EMAIL PROTECTED]> wrote:
>
>
>> Is there anyway to trap the debug information - so it is logged - but
>> not visible to users?
>>
>
> A g
I'm very occasionally getting errors reported to me on our production
site by our members. However, we cannot replicate the problem ourself
and because debugging is turned off the members are not giving me any
real clues.
Is there anyway to trap the debug information - so it is logged - but
I want to change the Cache-Control on the HTTP header. Can anybody
advise how I do this. Currently my view returns
a render_to_response like so:-
return render_to_response(template_name,{'code': code
},context_instance=RequestContext(request))
Thanks
MerMer
--~--~-~--~~
I have a model called REWARD, which has a one-to-one relationship with a
model called PROMOTION
I seem to be able to access the attributes of REWARD via PROMOTIONS but
I can't seem to update them.
promo=Promotion.objects.get(id=10)
promo.reward.user_visits
>> 10L
However:-
promo.reward.us
We've taken the approach using cookies. The value of the cookies is
returned to the template via a simple context processor. Each
cookie then simply refers to a stylesheet, which can change the whole
look and feel of the site. Very straightforward.
MerMer
James Bennett wrote:
> On 6/20/07
I am having real problems with IE6 and HttpResponseRedirect, IE keeps
showing a blank page, while Firefox works absolutely fine.
Has anybody else come across this issue ?
Thanks
MerMer
--~--~-~--~~~---~--~~
You received this message because you are subscribed
Does anybody know if it is possible to set up Dreamweaver CS3 to edit
web pages, dynamically created by Django.Dreamweaver works with PHP
and various other scripting tags - anybody have any experience with it
and Django?
MerMer
--~--~-~--~~~---~--~~
You rec
I have a template that has 3 non-contiguous areas. I need to display
the results of a query set across these three areas.
My initial solution was to split up the query set in the template using
"slice". For example:
{% for object in object_list|slice:"1:6" %}area one {% endfor %}
{% for objec
I'm have the following three Models.
1.Category Model
2. Promotion Model
- Has a many to many relationship with Category.
- Is the Parent of the Cash Model.
3.Cash Model
- Has one to one relationship with Promotion.
I want to create a query set of Cash Objects, filtered by a speci
The line of my previous post
" print i.name" should read "print i.firstname
This is just a correction to my post, not to my problem! Thanks
MerMer
Merric Mercer wrote:
> I'm getting, what seems to me, an inconsistency.
> Here's a simplified example:
>
>
&
I'm getting, what seems to me, an inconsistency.
Here's a simplified example:
>>qs=Mymodel.objects.all()
>>for i in qs:
setattr(i,"firstname","merric")
This works on:-
>>qs[0].firstname
>>merric
It also works in the template:-
{% for i in qs %} {{ i.firstname }} {% endfor
The above should read
data=serializers.serialize('json',qs)
If I do qs[0].firstname I get the value of firstname, but this doesn't seem to
be bundled in 'data'
MerMer
Merric Mercer wrote:
> First Question:-
>
> In my view if I do:-
>
> qs=Model.obje
First Question:-
In my view if I do:-
qs=Model.objects.all()
for i in qs:
setattr( i, "firstname", firstname ) # add a new attribute
("firstname") with correponding value
import django.core serializers
data=serializers.serialize('json',data)
render_to_response(template,{'data':data,'qs
Being a relative newbie I don't really understand how to create a
fixture for the testing framework. Could someone provide an example of
the format of a
fixture ?
I tried to run the dumpdata command because I'd read that this did much
of the work for me but I received the following error mes
Bennett wrote:
> On 4/9/07, Merric Mercer <[EMAIL PROTECTED]> wrote:
>
>> The official documentation on MySQL 5.1 "Using Replication for
>> ScaleOut" is explicit and states that it is the application (Django)
>> that needs to send the writes to the Master a
d slaves S1 and S2
> are configured. Application asks M for row id 15. M sends query to S1.
> S1 answers to M who answers to application. Application asks for row
> id 20. M sends to the next slave, S2, and so on. As new queries keep
> coming, so M keeps rotating between its slaves.
>
Julio,
In this scenario am I right in thinking that in MySQL the Master
automatically acts as a load balancer and that I therefore don't need
any other software
to automatically delegate reads between slaves and MySQL knows to send
all writes to the Master?
I'm slightly confused, I've been
tp://www.onlamp.com/pub/a/onlamp/2006/04/20/advanced-mysql-replication.html
MerMer
kemuri wrote:
> hey Merric,
>
> On Apr 9, 4:10 am, Merric Mercer <[EMAIL PROTECTED]> wrote:
>
>> The django book's chapter on deployment mentions the use of Database
>> replication
The django book's chapter on deployment mentions the use of Database
replication as a means to scale using MySQL.
My understanding with Database replication is it uses a MASTER DB and a
number of SLAVES.
The master updates the slaves, asynchronously. This means that the
slaves are used for
I am currently creating a query set of a Model. I'm then iterating
through the query set to create a calculation called "total".
At the end of each loop I am adding "total" to the query set. Example:-
qs= Cash.objects.all()
for i in qs:
# calculate total
i.total = total
Note: The Cash
Can somebody provide some guidance for how to use limit_choices in a
Model. I am trying to
only display the records in the related field that contain 4.
I've tried a number of ways but keep getting a syntax error.
MerMer
promotion=models.OneToOneField(Promotion limit_choices_to={
'promo_ty
Another observation after more investigation.
I decided to do the following:-
1. Drop the table (again) from the DB.
2. Alter the Model in Django. This time I deleted one of the original
fields named "rrp".
Then:-
1. I re-ran syncdb. This confirmed the creating of a new table in the db
2.
When I want to add a new field to a database, with existing data, I
normally don't have a problem as long as I follow these steps.
1. Alter the django model.
2. Manually adjust the database table ( mySQL)
3. Run syncdb
However, I used these steps this morning and it has not worked. The new
I have view that returns a whole bunch of different variables and
boolean flags.The state of these flags determine what the user
actually sees on their screen.
From a design perspective I seem to have two options:-
1. Design a template with lots of {% if %} conditional statements to
I have a template that loops through a simple query set and displays the
data in a table.
I now need to add another column to my table. However, the data in the
new column is a calculation based on two of the other fields
in that record.
I presume that this can be done using a template ta
I may be wrong but I believe that the you cannot use the If statement
inside a template to evaluate a specific value. You use it to
determine whether the object or value exists ( has been returned by the
view).
I think that this is because the developers wanted to maintain a
distinction be
Apologies, for wasting time the problem was with the line. Couldn't see
the wood for the trees!
debit = credit + i.debit
should read
debit = debit + i.debit
MerMer
Benedict Verheyen wrote:
> Merric Mercer schreef:
>
>> Benedict,
>>
>> Unfortunately, t
the PointTransaction query set.
MerMer
Benedict Verheyen wrote:
> Merric Mercer schreef:
>
>> Help! I have a function that is provided below. When I try the
>> individual lines of the function through the interpretor (Ipython)
>> everything work
Help! I have a function that is provided below. When I try the
individual lines of the function through the interpretor (Ipython)
everything works as expected. For example:-
>> qset=PointTransaction.objects.filter etc this works fine!!
However, when I try to run the function as a
By using TEMPLATE_ CONTEXT_PROCESSOR (by adding a path to a function,
example - Function X) I understand that I can access the variables of
Function X in any template.
What I would like to know is does this function get run in every
template - even if I don't need it in a template.
For examp
I'm still a little uncertain of how to put a wrapper around a generic
view. Given the following code below how does one handle pagination and
other
work that generic views does automatically.
from django.views.generic.list_detail import object_list
def generic_wrapper(request):
qs = Ar
Very helpful and instructive. Thanks.
MerMer
Jay Parlar wrote:
> On 11/10/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
>
>> On 11/10/06, Merric Mercer <[EMAIL PROTECTED]> wrote:
>>
>>> Jay, that works! Many thanks. Though I don't quite unde
Jay, that works! Many thanks. Though I don't quite understand why - or
where 'values' come from. Could you explain.
MerMer
>
> {% for item in campaigns.values %}
> {{item.id}}
> {% endfor %}
>
> >
>
>
>
--~--~-~--~~~---~--~~
You received this message beca
Jay,
Many thanks for this. As a recent newbie to Django and Python could you
give me a steer what I would need to do to make this tag. (I familiar
with making tags and filters, but can't see how I can use a tag to solve
this problem.)
MerMer
Jay Parlar wrote:
> On 11/10/06, Jay Parlar <[EMA
odels.campaign".
As mentioned, I can access theese values directly in the template using
the following syntax {{ campaigns.. }}. For
example, {{ campaigns.0.id }} works fine for that particular instance.
However, I can't seem to iterate through the whole dictionary.
MerMer
> {%
As part of my render_to_response I have returned the following:-
'campaigns':dict1 - where dict1 is a dictionary of objects from a model
called "Campaigns".
In my template I can do things like {{ campaigns.0.id }} and {{
campaigns.1.id }} to access the dictionary.
But, how do I iterate over
Starting with specific record in a child table I need to do the the
following.
1. Access a related field 'Brand Name' in the parent table. ( No problem)
2. Retrieve a query set of records in the Parent table that match the
'Brand Name'. (No Problem) BUT I want to exclude the initial reco
particularly as
Django seems to have many different ways to achieve a particular task.
Cheers
MerMer
James Bennett wrote:
> On 11/2/06, Merric Mercer <[EMAIL PROTECTED]> wrote:
>
>> Assuming I have a generic view. Can I used the "extra_context"
>> parameter
Assuming I have a generic view. Can I used the "extra_context"
parameter to pass a request object to a function elsewhere or resolve
request.path directly?
Example of what I am trying to do is below:-
from django.http import HttpResponse, HttpRequest
from jmyapp.blog.views import test
info_
I am thinking of using an Inclusion Tag on each of my generic views, as
a log on form, visible only to unauthenticated users.
It's very straight foward to create an inclusion tag that returns a
bland login form, but is it possible to create one that can uses the
manipulators/validators that Dj
As a newbie to Python, I can't see how one can nest two loops within a
template. Taking the template below, I have an additional list which I
need to iterate over in order to display a single figure for the last
cell in each table row.
Currently, if I add a for loop to the last cell (eg. {%
I'm am having a problem with the DateTimeField when I save the data
through the related class.
Example
class Transaction:
user =
ForeignKey(UserProfile,edit_inline=models.TABULAR,num_extra_on_change=0)
DateTimeField(auto_now_add=True, blank=True)
When I add data to Transaction, through the Ad
Is it possible to pass a variable to a Customer Model Manager?
I want to pass a variable to the Customer Manager and then use this
Manager within an inclusion Tag. Example below.
class UserPoint(models.Manager):
def get_query_set(self):
return super(UserPoint,self).get_query_s
Many thanks Don. I figured it out, but because of issues with google
have had problems posting back.
It turns out that I don't even have to use get_profile. Something like
{{ user.userprofile.postcode }} works fine, where userprofile is the
name of the one-to-one class.
MerMer
> On Oct 26
Thanks for all your points. I'm having real problems with Google
groups. I figured out what was wrong - but was not able to post in.
Now, these posts are obviously coming in - 24 late.
MerMer
>
> Karen
>
> p.s. Is google groups acting up? I just got a bunch of old mails
> (like this one),
exact model-definition?
> where is "core=True"?
>
> patrick
>
> Am 27.10.2006 um 14:15 schrieb Merric Mercer:
>
>
>> I'm having a problem which is causing me real concern.
>>
>> When I try to save a new record to a table, via the Admin (editing
>
posts via the web are not appearing on the board,
so I tried to
email directly.
MerMer
Merric Mercer wrote:
> I'm having a problem which is causing me real concern.
>
> When I try to save a new record to a table, via the Admin (editing
> inline), ALL of the records within that t
I'm having a problem which is causing me real concern.
When I try to save a new record to a table, via the Admin (editing
inline), ALL of the records within that table are being deleted!
Here's a brief description of what I have:-
class A # This is a user profile table that extends USER
OneT
51 matches
Mail list logo