hi,
I have a model like this:
name - unique
slno - not null
mode - not null
If the instance does not exist and I give all three values to get_or_create,
it works
if the instance exists, and I give values for slno and mode which are different
from the existing ones - I get a programming error
DG, what you describe is the AJAX approach. I'd use jQuery to help
with this sort of thing. use jQuery.post()
you would have to define a url to handle the post request and a view
function to pass it to. from the view function, you could return an
HttpResponse() with the confirmation bit of html or
Hi all
Please see:
http://tinyurl.com/rdnjob2
for a job being advertised by NSW Rural Doctors Network in Newcastle,
NSW, Australia.
Employment is open to Australian citizens, permanent residents and other
applicants with the appropriate visa authorisation to work in Australia.
The person
Put another way, how do execute a django function that simply does something
with the data in my database? It seems that views are the only way to do
this but perhaps I'm missing something.
Thanks in advance for all the help.
Best,
DG
On Wed, Mar 24, 2010 at 6:26 PM, Django Grappelli <
I've been struggling with this literally for hours.
I'm trying to use a ModelForm with initial values being set as those
that are already in the DB for a user. This works marvelously for
every field that I have EXCEPT for the one manytomany field I have in
my model. For that one, I can submit the
Hello.
When I use formfield_for_manytomany in my admin, those fields do not
render with the filter_horizontal JS picker. For example:
# admin.py
class ProjectAdmin( admin.ModelAdmin ):
def formfield_for_manytomany( self, db_field, request, **kwargs ):
if db_field.name ==
Yup that was it
Thanks
Riley
On Mar 24, 7:12 am, Paulo Almeida wrote:
> Ok, that makes more sense. You probably can't import django from anywhere
> else because the django folder cannot be read. Try going to
> /Library/Python/2.6/site-packages and type 'ls -l' to
Hi Guys,
Thanks for your help. I was thinking of taking an AJAX approach, but
wondered if there were a simpler way. Basically, I'd like to have the user
click, e.g. a delete button. It would delete the selected record and
display a small confirmation popup but I don't want to redirect to
On Mar 25, 3:39 am, David Christiansen wrote:
> Dear fellow Django users,
>
> We're beginning to be at wits end with a particular problem that we're
> having that I suspect has to do with server configuration issues, but
> might be something else.
>
> Our Django processes (whether
I think this could all be simplified a bit if you used a UserProfile
model instead of subclassing auth.User.
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
Was there a specific reason you were subclassing auth.User?
--
You received this message
Djangoists:
I often want to assert that a given method call (possibly a
client.post() call) creates one or a given number of records. This
assertion samples the high-water-mark in the primary keys of a given
QuerySet, calls your block, and then asserts that it could find your
records:
On Mar 24, 2:08 pm, Shawn Milochik wrote:
>
> http://docs.python.org/library/functions.html#staticmethod
>
> It means that the method is function that, when you run it, doesn't
> specifically belong to any particular instance, but to the class itself.
>
> Shawn
Thanks
On Wed, Mar 24, 2010 at 5:49 PM, saxon75 wrote:
> I apologize if this is blindingly obvious, but suppose I want to have
> a template actually print the literal string "{{ url }}" in the page.
> How would I go about doing that?
I apologize if this is blindingly obvious, but suppose I want to have
a template actually print the literal string "{{ url }}" in the page.
How would I go about doing that?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group,
Yes, you nad Nuno have right. Now it is work wll
Thanks for help
On 24 Mar, 18:56, Shawn Milochik wrote:
> The verbose name options you show should work, but they should be in a meta
> class within the main model.
>
> Example:
>
> class Category(models.Model):
>
>
Le mercredi 24 mars 2010 16:53:12, Sandman a écrit :
> Hi Derek,
>
> One way to do this would be to create a proxy model that can be used
> throughout your project.
>
> Check out
> http://docs.djangoproject.com/en/dev/topics/db/models/#proxy-models for
> more info.
Hi,
This is what is said in
OK, so it seems what's happening is that the password is being stored
in `api_qotduser` plain text.
I *believe* Django expects a hashed password?
More strangeness: I switched to using check_password and NOW Django is
querying `api_qotduser`, where before it was querying `auth_user`.
New login
>
>> The problem is you are defining get_class as
>> an instance method and trying to call it is a class method (or static
>> method).
>
> Sorry, I have no idea what you're referring to here, and Googling for
> static vs. class methods is not turning up anything I can understand.
> Can you show
On Mar 24, 12:05 pm, Firat Can Basarir
wrote:
> Scot you need to learm Python.
Do you mean learn *more* Python? Great, I'm always game to learn more!
I've taken a Python class and read books and run several Django sites.
It's not like I don't know enough Python to be
Have your 'export' button make an AJAX call to a view, which creates the CSV
file and prompts the user to 'Save As.'
Details:
1. Use the same view you currently have, with an 'if' statement which
returns a standard (html) response or a CSV file based on a slug in your URL.
2.
I'm trying to simply export CSV, but have failed miserably. First I
perform a search and the query set is displayed in a template. I want
to have an export button that will export the data on the page, but
unfortunately, I lost the query set and even if I were to have it as a
parameter, it would
Hi,
I am writing a basic login routine using django users.
Here is the view:
def login_result(request):
username = request.POST['u']
password = request.POST['p']
logging.debug("look for user %s / %s" % (username, password))
user = authenticate(username=username,
I made a custom template tag.
On Mar 24, 7:45 pm, Federico Capoano wrote:
> Hello to all,
>
> I don't understand how I can retrieve the most recent comments for a
> given model, something like:
>
> {% load comments %}
> {% get_comment_list for post as comment_list %}
Scot you need to learm Python. The problem is you are defining get_class as
an instance method and trying to call it is a class method (or static
method).
On Wed, Mar 24, 2010 at 8:00 PM, Scot Hacker wrote:
>
> On Mar 23, 5:32 pm, Paulo Almeida
Hello to all,
I don't understand how I can retrieve the most recent comments for a
given model, something like:
{% load comments %}
{% get_comment_list for post as comment_list %}
By using this code I get an empty list..
:-S
--
You received this message because you are subscribed to the
On Mar 23, 5:32 pm, Paulo Almeida wrote:
> I don't have a working sample (never did this), but you may be looking for
> something like this:
>
> class Media:
> js = get_path()
>
> And in the class where you keep use_editor:
>
> def get_path(self)
> if
The verbose name options you show should work, but they should be in a meta
class within the main model.
Example:
class Category(models.Model):
#your stuff here
class Meta:
verbose_name = "Kategoria"
verbose_name_plural = "Kategorie"
Shawn
I think you need toput verbose_name(_plural) in the class Meta
http://docs.djangoproject.com/en/dev/topics/db/models/#id3
class Category(models.Model):
class Meta:
verbose_name = "Kategoria"
verbose_name_plural = "Kategorie"
Nuno
On Wed, Mar 24, 2010 at 5:49 PM, serek
Hi
I use Django 1.1 and I would like to display in admin panel different
model name.
For example from code:
class Category(models.Model):
in admin panel I receive
'Categorys' instead of Categories
I googled for this and try:
class Category(models.Model):
verbose_name = "Kategoria"
Russell Keith-Magee wrote:
> Interesting idea! Thanks for sharing.
http://www.oreillynet.com/ruby/blog/2008/01/assert_efficient_sql.html
> I've just spent a bunch of time hunting down a performance regression
> that was caused by someone tweaking a database index, so I'd love to
> see something
Ok, I managed to fix it with LOCALE_PATHS.
Example: LOCALE_PATHS = ('', '/locale')
I hope it helps someone :)
On Mar 24, 4:22 pm, filias wrote:
> Hi,
>
> I have a project with several applications. The translations to
> another language are located in /locale
>
> I
On 24 mar, 16:50, ALJ wrote:
> Hi again Paulo,
>
> Ok. I'll also have a look at that.
>
> I agree that the business logic should be in the views. However, it
> feels that we need a little more flexibility with the templates when
> things are truely just a presentation
On Mar 24, 4:23 pm, mwebs wrote:
> Hello,
>
> I have a more complex dialog within the django admin, which requires a
> redirect to an intermediate page, when a certain model is saved. It
> seems as the django ModelAdmin does not provide any hooks for this
> purpose.
>
>
On Mar 24, 5:23 pm, mwebs wrote:
> But it this doesnt work for me, as I definitvely need the id of the
> object that just has been saved.
> So what I need is:
> - after model save --> redirect to another view
>
> Any ideas?
>
> Thanks
> - Toni
Take a look at the
Dear fellow Django users,
We're beginning to be at wits end with a particular problem that we're
having that I suspect has to do with server configuration issues, but
might be something else.
Our Django processes (whether it be Apache when running mod-python or
independent daemons when running
derek
i want to do the same thing.
first, the site below mentioned about filtering.
http://patrickbeeson.com/blog/2008/aug/11/how-create-user-specific-admin-Django/
in this time, you have to give country_id as a request parameter by
changing link url.
link url is like this:
Hello,
I have a more complex dialog within the django admin, which requires a
redirect to an intermediate page, when a certain model is saved. It
seems as the django ModelAdmin does not provide any hooks for this
purpose.
I found a workarround here:
Hi,
I have a project with several applications. The translations to
another language are located in /locale
I used the makemessages command (run from the project directory) to
generate the .po file and all the marked strings from code and
templates appear in the file.
I used the compilemessages
These are the additions to urls.py
js_info_dict = {
'packages': ('cui.translations',),
}
urlpatterns += patterns('',
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog',
js_info_dict),
)
Cheers,
John
On Mar 23, 6:10 pm, Rolando Espinoza La Fuente
wrote:
>
Hi Derek,
One way to do this would be to create a proxy model that can be used
throughout your project.
Check out
http://docs.djangoproject.com/en/dev/topics/db/models/#proxy-models for
more info.
Take care,
Rajiv.
On 3/24/10 7:44 AM, Derek wrote:
> I am currently using UserProfile to create
Hi again Paulo,
Ok. I'll also have a look at that.
I agree that the business logic should be in the views. However, it
feels that we need a little more flexibility with the templates when
things are truely just a presentation problem. When you have to start
constructing your own dictionaries /
Sorry, I hadn't understood your original problem, now I see why the nested
ifs wouldn't work.
Regarding your last question, I think a list of lists would be easier than
dictionaries. You can append the product as the first item in each sublist
and then iterate the list to get the rows and columns
I am currently using UserProfile to create additional fields that are needed
for my users.
I would like to be able to alter the existing User model to use the same
fields, but make some of them "required" (show up as bold on the form) e,g,
the first name and last name. How would I do that?
On Wed, Mar 24, 2010 at 9:16 PM, jrs wrote:
> I'm using 1.1.1 now. Any idea when there will be a 1.1.2 release? Is
> the current branch considered stable?
1.1.2 will be released at the same time as 1.2; current estimate is mid April.
We only ever backport bugfixes from
Hi list,
I need to save spatial data (latitude and longitude) in 2 fields in
the db (float). not that big deal, BUT
as representation in the admin, i would like to make kind of a
modelfield/formfield/widget with the googlemaps api. my problem is to
save it in the end in 2 fields in the db. i
> Sorry to have to say the last part is pure nonsense. Preserving data
> integrity is of course the only sane default behaviour. How could NOT
> preserving data integrity be "dangerous" ??? looonng query ? And ? So
> what ? You are supposed to know your data model, don't you ?
Bruno, I'm
Just as a matter of interest ... is there a 'best way' of formatting
the data if you do decide to process it all in the view and then pass
to the template? I seem to have dictionaries coming out of my ears if
I construct the data myself.
--
You received this message because you are subscribed to
Hi Dalore,
Thanks for that. I changed it a bit because it was still within that
{% for sale in sales %} loop. It works. But it really makes the raw
html pretty ugly with loads of spaces in it. Never mind. I suppose no-
one is going to see it.
{% for rate in rates %}
{{
What about something like this?
It gets you your text field, empty if no data, but with data if it
matches your if clause.
{{ rate.cost_item.name }}
{% for appointment in appointments %}
{% for sale in sales %}
{% endfor %}
{% endfor
I'm using 1.1.1 now. Any idea when there will be a 1.1.2 release? Is
the current branch considered stable?
Thanks Russ.
On Mar 23, 8:12 pm, Russell Keith-Magee
wrote:
> On Wed, Mar 24, 2010 at 5:01 AM, jrs wrote:
> > Thanks Preston.
>
> > I'm not
Ok. I thought it was more simple. I don't know the ORM in deep and
forgot about the extra() method. Thanks for the explanation.
On Mar 23, 5:15 pm, James Bennett wrote:
> On Tue, Mar 23, 2010 at 10:21 AM, Vinicius Mendes | meiocodigo.com
>
> wrote:
> >
Dear Dave
Thanks, that does look useful. Seeing Ian's solution I was wondering
if I could manage.py in some way.
Best wishes
Ivan
On Mar 23, 4:55 pm, Dave Murphy wrote:
> On Mon, Mar 22, 2010 at 12:26 PM, Ivan Uemlianin wrote:
>
> > I'm now thinking a
When I run all tests, tests for django.contrib.auth. I tried googling
it and found information, that django.contrib.sites is required, but I
have this app installed. I was also advised to use
TEMPLATE_CONTEXT_LOADERS, but this didn't help. Have anyone
encountered this problem and know, how to
Hi Paulo,
The 'if' test has to fall within the "for sale in sales" loop, because
it's testing the values of the the sale. However, if there is no
match, then the default is triggered. Therefore I will get as many
defaults as there are sales (-1 if there is a match). Nesting {% if %}
's won't
Hello
I have made a custom db.field - WeekdaysField wich allow me to split
week days into four groups. Also I create forms.field and widget to
display it as seven SELECTs. All works fine, but when I have tried to
use it with inlinadmin...
When editing object Foo wich have TablularInline with
I don't understand why is it obvious that an 'else' won't work. If a single
{% else %} is not what you want, you can nest {% if %} clauses. But if you
are doing this it can also mean that you should move this logic to the view
and just pass the final table to the template.
- Paulo
On Wed, Mar
In python, dictionaries have a get method that will return None if you
call it on a dictionary key that doesn't exist. get() can also take an
optional default parameter that returns it's value if the key doesn't
exist.
If you use the indexing method, i.e. [], it invokes the dictionaries
I have a template that shows a matrix table of form text input boxes.
When the form is new, then it should be just empty text boxes. If data
already exists, then the form gets repopulated with data.
What I am looking for it this:
PRODUCTS | DAY1 | DAY2 | DAY3
POLO | Empty text box | 3 | 3
You are right. I understand now. I must have misread the original
request, because I now see that describes multiple instances in memory
wouldn't work properly.
On Mar 24, 12:52 am, Graham Dumpleton
wrote:
> On Mar 24, 12:53 pm, Tim Shaffer
Ok, that makes more sense. You probably can't import django from anywhere
else because the django folder cannot be read. Try going to
/Library/Python/2.6/site-packages and type 'ls -l' to see the permissions. I
presume you don't have e(x)ecute permission in the django folder. These
commands might
Hi All, still trying to get my head around the multi db stuff in 1.2
release.
Here is my problem that I have hit upon.
I have a model in my default db...
class Set1(models.Model):
create_date = models.DateTimeField(auto_now_add='True')
last_update = models.DateTimeField(auto_now='True',
Daniel Roseman @ 24-03-2010 11:43:
But what do you mean, 'without changing the HTML'? In order to run a
view, the user must make a page request. That will result in new data
I guess he is talking about AJAX.
--
Omer Barlas
omer.bar...@gmail.com
--
You received this message because you are
On Mar 24, 3:21 am, Django Grappelli
wrote:
> Hi Everyone,
> Django noob here. How do I write a view function that can modify
> database records without changing the html on the screen? Also, from
> a best-practices standpoint, is there any reason I shouldn't be
>
On 23 mar, 21:57, jrs wrote:
> Russ and Javier,
>
> Just to be clear... the reason for my initial note was due to my
> already having a work queue which performs cleanup and maintains data
> integrity. It is precisely due to this that I'm surprised the ORM has
> cascading
On 24 mar, 06:39, Daniel wrote:
> Hi there,
>
> I'm reading the django book and they say that you can validate a form
> like this in one line, checking for missing keys and missing data:
>
> if not request.POST.get('subject', ' ')
> errors.append('enter a subject')
On Wed, Mar 24, 2010 at 2:57 PM, Henrik Genssen
wrote:
> Hi,
>
> thanks for your answer!
>
Now is there a way to force select_related tables any way in a count?
>>
>>select_related() is an optimization for data retrieval. It allows you
>>to expand a select row to
On Mar 20, 1:09 pm, cool-RR wrote:
> Hey Russ,
>
> At this point I'll just do a brief list, so I think I'll do it on the wiki.
> I don't want to invest too much time into it, but I'll be happy if someone
> else will want to expand it and put in in the documentation. (I think
Hi,
thanks for your answer!
>>>Now is there a way to force select_related tables any way in a count?
>
>select_related() is an optimization for data retrieval. It allows you
>to expand a select row to include related objects in a single query.
>
>It only follows the "1" side of "1-N" relations.
On Tue, 2010-03-23 at 23:14 -0700, Daniel wrote:
> Hi,
>
> Are these statements equivalent? I want to say no, but I can't see
> why.
Nope. If the key 'foo' doesn't exist, request.POST.get('foo') will
return None, while request.POST['foo'] will blow up with a KeyError.
Using the get() method on
Hi,
Are these statements equivalent? I want to say no, but I can't see
why.
Thank you
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send
This is a Python question, not a Django question. The Python
dictionary get() function accepts a second, optional value to use as
the default for what would otherwise raise a KeyError.
Shawn
Sent from my iPhone
On Mar 24, 2010, at 1:39 AM, Daniel wrote:
Hi there,
71 matches
Mail list logo