how to enforce uniqueness

2009-01-18 Thread Konstantin

Hello!

First of all I want to apologize for maybe very basic question, but I
newbie in django and web coming from c/c++ world.

I have two models:

class Box(models.Model):
description = models.CharField(max_length=250)
id = models.IntegerField(primary_key=True)

def __unicode__(self):
return self.description

class Item(models.Model):
title = models.CharField(max_length=500)
box = models.ForeignKey(Box)
label = models.IntegerField()

def __unicode__(self):
return self.title

What I want is to enforce in some way uniqueness of pair (label, box)
for every item. So there may be items with the same label but they
must belong to different boxes.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



what to use for search facility

2009-01-18 Thread Konstantin

Hello

In my project I'll need to implement search facility through user's
private pages (so google custom search is not available). What is the
best option for this kind of task in django ? I'd like to use postgres
(though it's not a strict requirement, mysql based solution will be
fine) with tsearch but not sure django supports it out of the box.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: what to use for search facility

2009-01-19 Thread Konstantin

On Jan 19, 10:29 am, krylatij  wrote:
> Sphinx
> Here 
> sampleshttp://softwaremaniacs.org/blog/2007/11/04/sphinx-search-in-cicero/
> (but in Russian)

Thank you very much! I'll have a look

(Being native Russian I'll have no problem reading this text :) )

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to clear form from wrong data

2009-01-30 Thread Konstantin

On Jan 30, 5:18 pm, Daniel Roseman 
wrote:
> Not certain I fully understand your flow here, but surely if in line
> 10 you just did:
>             form = MediaGetForm()
> that would solve your problem? You're passing in the POST dictionary
> each time - if you want a blank form, simply don't pass in the POST.

Thank you very much, it helps.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to clear form from wrong data

2009-01-30 Thread Konstantin

On Jan 30, 5:18 pm, Daniel Roseman 
wrote:>
> Not certain I fully understand your flow here, but surely if in line
> 10 you just did:
>             form = MediaGetForm()
> that would solve your problem? You're passing in the POST dictionary
> each time - if you want a blank form, simply don't pass in the POST.

Maybe you give me one more tip: how to display error message of
previous wrong input and show new empty form at the same time ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to clear form from wrong data

2009-01-30 Thread Konstantin

On Jan 30, 6:21 pm, Karen Tracey  wrote:
> > Maybe you give me one more tip: how to display error message of
> > previous wrong input and show new empty form at the same time ?
>
> Are you sure you want to do that?  As a user I'd find it very annoying for a
> web form to be re-displayed with errors telling me what I entered in some
> field was wrong, without giving me the opportunity to see what it was I had
> entered.  Even if "wrong" just means "does not exist in the DB" I'd like
> what I'd entered to be re-displayed so I can see whether I made a typo or
> actually did enter what I thought I had


So you think it would be better from UI to display both errors and
previous input ? Hmm... Anyway how to explicitly set custom error
message ('there are no data in DB' for example) ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: commit=False and m2m relations in forms

2009-02-01 Thread Konstantin

On Feb 1, 2:23 pm, Russell Keith-Magee  wrote:
> Yes. Read up on how to use the save() method in the modelforms docs.
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
>
> In particular, the second example in that section should answer your question.
>

Thanks, Russ, it works. I've overlooked that part of docs. But it
seems that this method is not transaction safe ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django + WSGI + CsrfViewMiddleware = ?

2013-03-08 Thread Konstantin

I am running Django 1.3  with Apache and mod_wsgi. I followed these
instructions, https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
to display a simple page, which contains a form, and which sends the
data back via POST.

Everything is fine with GET requests. However, when I do POST, I get
an error: Forbidden (403), "CSRF token missing or incorrect".

The django.middleware.csrf.CsrfViewMiddleware component is added to
the MIDDLEWARE_CLASSES list. The html form contains the {% csrf_token
%} tag. I can verify that in the form sent on GET, this tag is
replaced with the hidden input field:



I also use RequestContext in the django views code.

When the form is POSTed back, the CsrfViewMiddleware expects to find a
cookie with a specific name, and if found, it sets the csrf_token
variable:

  csrf_token =
_sanitize_token( request.COOKIES[settings.CSRF_COOKIE_NAME])

Then, for the POST request, it expects to find a specific data inside
request.POST:

  if request.method == "POST":
request_csrf_token =
request.POST.get('csrfmiddlewaretoken', '')

The error I am seeing happens when these two values are not equal.
Indeed, in my case, the csrf_token is set to the value above, and the
request_csrf_token is empty. Moreover, request.POST comes completely
empty when it reaches the CsrfViewMiddleware filter. It is known that
mod_wsgi sends POST data in request.META['wsgi.input'], which somehow
needs to be parsed.

Django documentation advises against accessing POST data in the
middleware (something breaks down the road), with CsrfViewMiddleware
being an exception. But even if I stick another custom component just
before CsrfViewMiddleware in the MIDDLEWARE_CLASSES list, which would
read and parse the request.META['wsgi.input'] data, I will not be able
to pass the value to CsrfViewMiddleware via POST because it is read
only.

So, my question is, how this is supposed to work? What am I missing?

Thanks.
Konstantin.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




How to clear form from wrong data

2009-01-30 Thread Konstantin S

Hello!

I believe this is a VERY basic question, that already covered
somewhere in the excellent django docs, but I couldn't find an answer
and therefor asking for some help.
In my view I have this request handler: http://dpaste.com/114650/. The
problem is that after wrong data input (i.e. no data was found) I get
the same form with previously entered wrong data. How do I get in that
case just new form without any data in it ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



__icontains in case of non ascii symbols

2009-02-01 Thread Konstantin S

Hello again :)

Am I right that __icontains relays on DB backend entirely to perform
case insensitive search ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



commit=False and m2m relations in forms

2009-02-01 Thread Konstantin S

Hello!

I couldn't add m2m relations in my form if I use delayed commit, i.e.
form.save(commit = False) and form.save() later on. See code at
http://dpaste.com/hold/115253/. Is there some common pattern to
workaround such issues ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



m2m field and forms

2009-02-10 Thread Konstantin S

Hello

I have a form created from forms.ModelForm and in my model one of the
fields is m2m field. Now when form is displayed for that m2m filed I'd
like to have something that looks like checkbox where user can select
several alternatives. I know that I can use widgets here and there are
some that can be used in my case, but I don't know how do I use them
in case of form being generated as ModelForm ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: m2m field and forms

2009-02-10 Thread Konstantin S

On Feb 10, 5:51 pm, Sergey Koval  wrote:
> On Tue, Feb 10, 2009 at 1:21 PM, Konstantin S  wrote:
>
> > Hello
>
> > I have a form created from forms.ModelForm and in my model one of the
> > fields is m2m field. Now when form is displayed for that m2m filed I'd
> > like to have something that looks like checkbox where user can select
> > several alternatives. I know that I can use widgets here and there are
> > some that can be used in my case, but I don't know how do I use them
> > in case of form being generated as ModelForm ?
>
> If you want to show multiple checkboxes, use CheckboxSelectMultiple widget.
>
> Sample code:
>
> class MyForm(forms.ModelForm):
>     my_field = fields.ModelMultipleChoiceField(queryset=your_query_set,
> widget=forms.CheckboxSelectMultiple)
>

Thanks, that's exactly I was looking for. I didn't know that fields
may be overwritten if the form is derived from a forms.ModelForm class
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



load huge dataset through fixtures

2009-02-16 Thread Konstantin S

Hello!

I am trying to load really huge dataset (contains millions of records)
into database through fixtures and it seems that django loads entire
data into memory before commiting it into db so python process dies
out of memory. Am I right that the only possible solution in my case
is not to use fixtures at all and upload data by script ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird problem in url resolving after restarting django dev. server

2009-05-26 Thread Konstantin S

On May 20, 2:02 pm, Konstantin S  wrote:
> Hello!
>
> I have a very strange problem and really don't know where to start in
> hunting it down. My app uses django-registration, all works fine but
> if I been logged in restart django dev. server I immediately get
> TemplateSyntaxError:
>
> Caught an exception while rendering: Reverse for
> 'myapp.add_media_action' with arguments '()' and keyword arguments
> '{}' not found.
>
> It seems like after restarting django couldn't resolve url's names. I
> know this is a very vague and incomplete description but may be it is
> a very well known problem that you can identify on the spot ?

Continue my story...

I've changed a bit template code:

was: Add new
now: Add new

Error message also changed, now it is:

Caught an exception while rendering: Reverse for
''
with arguments '()' and keyword arguments '{}' not found.

I have no idea how to fix this problem, please help if you can.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird problem in url resolving after restarting django dev. server

2009-05-27 Thread Konstantin S

On May 26, 9:28 pm, Steve Howell  wrote:
>
> From the docs you might want to take advantage of the name= parameter
> in your URLS setup and do something like {% url 'add_media_action'
> %}.  Not sure about the quoting, as the docs are vague about quoting
> literals.
>
> '''
> New in Django 1.0: Please, see the release notes
>
> If you're using named URL patterns, you can refer to the name of the
> pattern in the url tag instead of using the path to the view.
> '''
>
> It seems like the login_required method may be confusing you:
>
> url(r'^add/$', login_required(views.add_media),
>         name = 'add_media_action'),
>
> I am guessing the login_required method returns another method that
> gets set up into the url data structure, so the reverse code has no
> way of knowing about views.add_media anymore.   Does that make sense
> to you?
>
> Perhaps you can try to step through the code in the debugger.  The top-
> level method involved in reversing URLs are not super complicated.
> You can set a breakpoint in django/core/urlresolver.py to see what's
> happening.

Steve, thanks for your suggestion to trace django code, I've finally
found what was the problem. Don't know how to fix it yet so I disabled
some fancy ajax-based functionality. But at least I am no getting this
mysterious 500 errors any more.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to use django ORM in standalone script ?

2009-02-23 Thread Konstantin S

Hello!

I need to postprocess some data in my models and the most natural way
of doing this would be to run periodically standalone script. But on
the other hand I want to use framework ORM just because it would much
more handy than raw sql. What should I import to plug in django in
standalone script that runs from command line ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Join unrelated models

2009-03-24 Thread Konstantin S

Hello!

I have two unrelated models that have one common field.

class Media(models.Model):
title = models.CharField(max_length=500)
...

class Link(models.Model):
title = models.CharField(max_length=500)
...

Now I want to select those objects from the Media model that do not
exist in the Link model if we compare them only by 'title' field. In
raw SQL it looks like this:

select * from Media left join Link on Media.title=Link.title where
Link.title is null;

Is it possible to make the same thing by Django ORM only ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Join unrelated models

2009-03-24 Thread Konstantin S



On Mar 24, 11:13 pm, Alex Gaynor  wrote:
> On Tue, Mar 24, 2009 at 4:05 PM, Konstantin S  wrote:
>
> > Hello!
>
> > I have two unrelated models that have one common field.
>
> > class Media(models.Model):
> >    title = models.CharField(max_length=500)
> >    ...
>
> > class Link(models.Model):
> >    title = models.CharField(max_length=500)
> >    ...
>
> > Now I want to select those objects from the Media model that do not
> > exist in the Link model if we compare them only by 'title' field. In
> > raw SQL it looks like this:
>
> > select * from Media left join Link on Media.title=Link.title where
> > Link.title is null;
>
> > Is it possible to make the same thing by Django ORM only ?
>
> So to be clear you want all items from Media for which there isn't a link
> with that title, in the ORM that would look like:
>
> Media.objects.exclude(title__in=Link.objects.values('title'))
>

Yes, but I want to be sure that it uses JOIN syntax.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



request.user in forms.py

2009-03-26 Thread Konstantin S

Hello!

I know this a very stupid question but nevertheless how can I get
request.user object in forms.py file ? I am trying  to do something
like:

class ItemGetForm(forms.Form):
box = forms.ModelMultipleChoiceField(
queryset=Box.objects.filter(owner=request.user),
widget=forms.RadioSelect)
label = forms.IntegerField()

Where:

class Box(models.Model):
owner = models.ForeignKey(User)
description = models.CharField(max_length=500, blank=True, null=True)

def __unicode__(self):
return self.description


But constantly get an error 'Caught an exception while rendering: name
'request' is not defined'.

If am completely wrong here what is a preferable way of doing such things ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



pagination

2009-03-30 Thread Konstantin S

Hello!

I noticed that there are two paginations 'engines' available for
django. The first one is in django distribution itself
(http://docs.djangoproject.com/en/1.0/topics/pagination/), and the
second one I found at code.google.com. (Url is
http://code.google.com/p/django-pagination/). Which one would you
recommend ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



customization of the form

2009-04-21 Thread Konstantin S

Hello!

In my model I have dynamically generated checkbox fields that look like this:

boxes = forms.ModelMultipleChoiceField(queryset=Box.objects.all(),
widget=forms.CheckboxSelectMultiple)

The problem is that in the web-interface I've got a long flat list of
checkboxes and it doesn't look very nice from a design point of view.
What I want is to split it into two or more columns, but I am not a
web developer and my knowledge in html and css is very limited. I'd
try to find a solution for this problem if I were given some hints
where to start. Please give me such hints.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: customization of the form

2009-04-22 Thread Konstantin S

On Apr 22, 9:29 am, zayatzz  wrote:
> I wish i could see the html output of your program. But you have to
> use either divs or ul&li elemnts to wrap that list and make it look
> nice in template.
>
> But i think the problem is that your widget output is just a list of
> checkboxes, that you cant iterate in a template, so wrapping them is
> impossible?
>

Yes, you are right. Generated html looks like this:

 Boxes:

 Box 1
...
 Box 30


I can't iterate through individual  and mark them in some way or
split this single  into two lists.

I don't want to create a great design, I am neither an experienced
web developer nor a web-designer, I just want it to look not so
awkward.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: customization of the form

2009-04-22 Thread Konstantin S

On Apr 22, 11:33 am, Konstantin S  wrote:
> I can't iterate through individual  and mark them in some way or
> split this single  into two lists.

Just to be clear: I can't do it because it's generated as a single not
iterable entity.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: customization of the form

2009-04-22 Thread Konstantin S

On Apr 22, 1:51 pm, Tom Evans  wrote:
> On Tue, 2009-04-21 at 21:20 +0400, Konstantin S wrote:
> > Hello!
>
> > In my model I have dynamically generated checkbox fields that look like 
> > this:
>
> > boxes = forms.ModelMultipleChoiceField(queryset=Box.objects.all(),
> > widget=forms.CheckboxSelectMultiple)
>
> > The problem is that in the web-interface I've got a long flat list of
> > checkboxes and it doesn't look very nice from a design point of view.
> > What I want is to split it into two or more columns, but I am not a
> > web developer and my knowledge in html and css is very limited. I'd
> > try to find a solution for this problem if I were given some hints
> > where to start. Please give me such hints.
>
> Write your own widget class to output the required inputs in the manner
> you want. Check out how CheckboxSelectMultiple.render() is implemented
> in django/forms/widgets.py
>

Thanks, Tom!

Your advise really seems to be a solution for my problem. BTW is there
any official documentation for writing custom widgets ? Couldn't find
any :(

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: customization of the form

2009-04-22 Thread Konstantin S

On Apr 22, 3:31 pm, zayatzz  wrote:
> This css should do it:
>
> ul {list-style-image:none;list-style-position:outside;list-style-
> type:none; float:left}
> ul li {width:50%;display:block;float:left}
>
> What this does, is that it gives every list element 50% of available
> width (if you want 3 columns then put it to 30%), display block is
> actually not necessary, i just added it to be sure it works in IE too
> - i tested it in firefox.
>
> If you want to see all the markup & css go here 
> :http://www.frukt.ee/public/alan/test/test.html
>
> If you want the elements to be sorted in different way - first 10 in
> one column and next 10 in another, then css cant do and you have to
> follow advice given by Tom.
>

Wow, great! I don't even need to write my custom widget! Thank you
very much!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Offtopic: MySQL or PostgreSQL for a limited VPS ?

2009-04-24 Thread Konstantin S

Hello!

I am planning to deploy django based site on a limited VPS and want to
know which database is more suitable for this ? If I've had a 'normal'
hardware I'd vote for the PostgreSQL but maybe in case of limited
resources MySQL would be a better choice. What do you think ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



setting.py and deployment

2009-05-15 Thread Konstantin S

Hello

First of all sorry if this question was asked and answered many time
before. I want to know what are the best practices you use for
deployment django sites in production.  I mean how do you separate
setting.py into development and production part and how do use choose
which one to use without much editing

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Weird problem in url resolving after restarting django dev. server

2009-05-20 Thread Konstantin S

Hello!

I have a very strange problem and really don't know where to start in
hunting it down. My app uses django-registration, all works fine but
if I been logged in restart django dev. server I immediately get
TemplateSyntaxError:

Caught an exception while rendering: Reverse for
'myapp.add_media_action' with arguments '()' and keyword arguments
'{}' not found.

It seems like after restarting django couldn't resolve url's names. I
know this is a very vague and incomplete description but may be it is
a very well known problem that you can identify on the spot ?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird problem in url resolving after restarting django dev. server

2009-05-20 Thread Konstantin S

On 20 май, 14:02, Konstantin S  wrote:
> Hello!
>
> I have a very strange problem and really don't know where to start in
> hunting it down. My app uses django-registration, all works fine but
> if I been logged in restart django dev. server I immediately get
> TemplateSyntaxError:
>
> Caught an exception while rendering: Reverse for
> 'myapp.add_media_action' with arguments '()' and keyword arguments
> '{}' not found.
>
> It seems like after restarting django couldn't resolve url's names. I
> know this is a very vague and incomplete description but may be it is
> a very well known problem that you can identify on the spot ?

I've tried it in a django shell.  'myapp.add_media_action' really does
not resolve, but 'add_media_action' resolves fine. That makes it even
more puzzling. Why am I getting 'myapp.add_media_action' instead of
'add_media_action' ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird problem in url resolving after restarting django dev. server

2009-05-20 Thread Konstantin S

On 20 май, 17:41, Karen Tracey  wrote:
> There's got to be some difference between your server
> environment and the shell environment you are using that is causing that.
>

All works fine until I restart django dev. http server. If at that
moment I was logged in into my site then next hit after restarting
would cause that NoReverseMatch error. May it be a problem that almost
all my views wrapped into login_required decorator like that: url
(r'^add/$', login_required(views.add_media), name =
'add_media_action'). And if it so how to fix it ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird problem in url resolving after restarting django dev. server

2009-05-20 Thread Konstantin S

On 20 май, 19:43, Steve Howell  wrote:
>
> To elaborate on Karen's suggestion, one way to see which URLs are
> among the candidates for resolving the reverse match is to
> deliberately hit a bad URL like the following:
>
> http://localhost:8000/something_that_does_not_match_urls
>
> If you have appropriate debug settings, you should then get back a
> list of all the patterns that django knows about in your browser.  If
> you don't see the URL for add_media_action, then you probably have
> some issue with the environment, as Karen suggests.

Yes, there is URL for 'add_media_action'. As I said before all works
as expected till I restart dev. server.

>
> If you do see the URL for add_media_action, then you probably want to
> focus on other theories, such as the wrong number of arguments or
> something similar.
>

I've checked it several times and found nothing wrong. Again, problems
occur just after I restart dev. server, before that moment I don't get
any errors. That's why I am so frustrated with this problem

> Obviously, more information would help people help you figure this
> out.  At the very least you should provide the line of code from
> urls.py that establishes the mapping for add_media_action.

It's very simple (from myapp/urls.py)

url(r'^add/$', login_required(views.add_media),
name = 'add_media_action'),

And my project urls.py looks like this:

urlpatterns = patterns('',
url(r'^$', 'views.index', name="index"),
(r'^data/', include('myapp.urls')),
(r'^accounts/', include('registration.urls')),
(r'^admin/(.*)', admin.site.root),
url(r'^ajax/autocomplete/$', 'views.ajax_autocomplete_action',
name='ajax_autocomplete_action'),
url(r'^about/$', 'django.views.generic.simple.direct_to_template',
{'template': 'misc/about.html'}, name="about"),
)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird problem in url resolving after restarting django dev. server

2009-05-20 Thread Konstantin S

On 20 май, 22:48, Steve Howell  wrote:
> On May 20, 10:49 am, Konstantin S  wrote:
>
>
>
> > On 20 май, 19:43, Steve Howell  wrote:
>
> > > To elaborate on Karen's suggestion, one way to see which URLs are
> > > among the candidates for resolving the reverse match is to
> > > deliberately hit a bad URL like the following:
>
> > >http://localhost:8000/something_that_does_not_match_urls
>
> > > If you have appropriate debug settings, you should then get back a
> > > list of all the patterns that django knows about in your browser.  If
> > > you don't see the URL for add_media_action, then you probably have
> > > some issue with the environment, as Karen suggests.
>
> > Yes, there is URL for 'add_media_action'. As I said before all works
> > as expected till I restart dev. server.
>
> Just to be clear, I'm suggesting that you try the technique above
> after you restart the dev server.

Yes, of course I tried it after restart the dev. server

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



bug? cannot urlencode() after storing QueryDict in session

2011-08-14 Thread Konstantin Sushenko
hello,

I store request.GET in session:

request.session['query_string'] = request.GET

then I retrieve the value in another page and try to urlencode the
QueryDict:

context['query_string'] = request.session['query_string'].urlencode()

in my context I get the python's string representation of the
QueryDict object instead of the expected key0=value0&key1=value1&...
string.

If, instead of QueryDict, I store the urlencoded string in the
session, everything works of course:

request.session['query_string'] = request.GET.urlencode()

a bug?

thanks

konstantin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: custom template tag. success message after form-submit in the same .html file

2011-08-15 Thread Konstantin Sushenko
hello,

you can just add a context variable 'submitted' to your context in
your view's get_context_data

konstantin

On Aug 15, 4:06 am, doniyor  wrote:
> Hi There,
>
> I am heading well now, but have still some confusing things here..
>
> this is my html file, where i want to get a success message after the
> form is submitted:
>
> __
> 
>         {% load forms %}
>         {% if submitted %}
>                 {{ success }}
>         {% else %}
>              
>         {% endif %}
>         Clear cache:  Cache leeren  a>
> 
> -
> this is my def  in templatetags folder:
> 
> success = 'Cache erfolgreich geleert'
>
> def submitted(self):
>     if request.method == 'GET':
>         return True
>
> register.tag('submitted', submitted)
> 
>
> BUT i dont see anything after submission of the form. where is my
> mistake, can you please help ?,
>
> thanks in advance..
>
> Doni

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Changing App/Model Names and Sort Order in index.html

2011-08-15 Thread Konstantin Sushenko
hello,

your question indicates that you have a limitedknowledge of django
templates and template tags. python code is ot supported in templates,
so your string.replace won't work.

to change the order: 
https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by

konstantin

On Aug 14, 8:27 pm, Lee  wrote:
> Is there an easy way to change "Auth" to "My Authentication App Name"
> in index.html? I tried changing {{ name }} to
> {{ string.replace(name,'Auth','My Authentication App Name') }} but it
> just kills the label completely -- hopefully just a syntax problem.
>
> How about changing the order that the models are list in on this page?
>
> Thanks for any help or ideas.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: For loop problem in template..Is this correct

2011-08-15 Thread Konstantin Sushenko
hello,

as a result of this you will have a series of 'data[i] = ...'
assignments in your output. where 'i' would be undefined.

konstantin

On Aug 15, 7:45 pm, Adam Zedan  wrote:
> Hi i am getting a problem with my for loop which i used in my template.Could
> you kindly let me know what is going wrong in here.
> The for loop is in a jquery function
>
> $(function() {
>             var data = [];
>
>                {% for x in range(len(content)) %}
>                 data[i] =
>                 {
>                     roll_no: {{content[x].roll_no}},
>                     cell_no: {{content[x].cell_no}},
>                     nationality:{{content[x].nationality}},
>                     e_mail:{{content[x].e_mail}}
>
>                 };
>                 {% endfor %}
>
>             grid = new Slick.Grid("#myGrid", data, columns, options);
>
>             $("#myGrid").show();
>         })

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: For loop problem in template..Is this correct

2011-08-15 Thread Konstantin Sushenko
I would just write a template tag that outputs the whole JS function.
templates are too limiting in what you can use in {{}} brackets.

konstantin

On Aug 15, 8:38 pm, Landy Chapman  wrote:
> You may be right.  I am out of my element (pardon the pun). However,
> assuming your "content" was this:
>
> content = [ { 'roll_no':1, 'cell_no': 1, 'nationality':'nation1'},
> { 'roll_no':2, 'cell_no': 2, 'nationality':'nation2'},
> { 'roll_no':3, 'cell_no': 3, 'nationality':'nation3'},
>
>  the django template renderer will turn this (note quotes around
> nationality and email):
>
> > > $(function() {
> >               i = 0;
> > >             var data = [];
> > >                 {% for x in content %}
> > >                 data[i] =
> > >                 {
> > >                     roll_no: {{x.roll_no}},
> > >                     cell_no: {{x.cell_no}},
> > >                     nationality: '{{x.nationality}}',
> > >                     e_mail: '{{x.e_mail}}'
> > >                 };
> >                     i +=1;
> > >                 {% endfor %}
>
> into this:
>  $(function() {
>                i = 0;
>              var data = [];
>
>                  data[i] =
>                  {
>                      roll_no: 1,
>                      cell_no: 1,
>                      nationality: 'nation 1',
>                      e_mail: 'email1'
>                  };
>                    i +=1;
>                  data[i] =
>                  {
>                      roll_no: 2,
>                      cell_no: 2,
>                      nationality: 'nation2',
>                      e_mail: 'email2'
>                  };
>                    i +=1;
>                  data[i] =
>                  {
>                      roll_no: 3,
>                      cell_no: 3,
>                      nationality: 'nation3',
>                      e_mail: 'email3'
>                  };
>                  i +=1;
>
> My JS guy has left for the day... maybe someone else can help out.
> Also the 'autoescaping' should be on, in case some nationality
> contains a (')  Ex: "G'ermany"
>
> HTH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template html works when double clicked but empty when accessed through server

2011-08-15 Thread Konstantin Sushenko
what is the source code for the blank page?

On Aug 15, 8:50 pm, Adam Zedan  wrote:
> Hi my html works properly when i double click it.
>
> The code is
>
> 
> 
>     
>         
>         Demo
>          href="file:///D:/Django-1.3/django/bin/SlickGrid/slick.grid.css"
> type="text/css" media="screen" charset="utf-8" />
>          href="file:///D:/Django-1.3/django/bin/SlickGrid/css/smoothness/jquery-ui-1.8.5.custom.css"
> type="text/css" media="screen" charset="utf-8" />
>          href="file:///D:/Django-1.3/django/bin/SlickGrid/examples/examples.css"
> type="text/css" media="screen" charset="utf-8" />
>
>          src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js";>
>          src="file:///D:/Django-1.3/django/bin/SlickGrid/lib/jquery-1.4.3.min.js">
>          src="file:///D:/Django-1.3/django/bin/SlickGrid/lib/jquery.event.drag-2.0.min.js">
>
>          src="file:///D:/Django-1.3/django/bin/SlickGrid/slick.core.js">
>          src="file:///D:/Django-1.3/django/bin/SlickGrid/slick.grid.js">
>
>         
>         var grid;
>         var columns = [
>             {id:"title", name:"Title", field:"title"},
>             {id:"duration", name:"Duration", field:"duration"},
>             {id:"%", name:"% Complete", field:"percentComplete"},
>             {id:"start", name:"Start", field:"start"},
>             {id:"finish", name:"Finish", field:"finish"},
>             {id:"effort-driven", name:"Effort Driven", field:"effortDriven"}
>         ];
>
>         var options = {
>             enableCellNavigation: true,
>             enableColumnReorder: false
>         };
>
>         $(function() {
>             var data = [];
>             for (var i = 0; i < 500; i++) {
>                 data[i] = {
>                     title: "Task " + i,
>                     duration: "5 days",
>                     percentComplete: Math.round(Math.random() * 100),
>                     start: "01/01/2009",
>                     finish: "01/05/2009",
>                     effortDriven: (i % 5 == 0)
>                 };
>             }
>
>             grid = new Slick.Grid("#myGrid", data, columns, options);
>
>             $("#myGrid").show();
>         })
>
>         
>
>     
>
>     
>
>          
>         
>             
>                  style="width:600px;height:500px;display:none;">
>             
>         
>         
>
>     
> 
>
> however when i run it the proper way i.e run the server "manage.py
> runserver" and enter the url i just get a blank screen ?? Does anyone know
> why this happens??

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template html works when double clicked but empty when accessed through server

2011-08-15 Thread Konstantin Sushenko
I can see the markup that you published in your original post. :) what
does the browser show when you look at the page source?

konstantin

On Aug 16, 12:04 am, Adam Zedan  wrote:
> Its at the top most post..
> have a look 
> athttp://groups.google.com/group/django-users/browse_thread/thread/8a50...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template html works when double clicked but empty when accessed through server

2011-08-16 Thread Konstantin Sushenko
you do not see anything because the style on your root element is set
to "display:none" and the browser does not run scripts because they
are loaded from local URLs. as it says: it is a insecure to execute
scripts from local URLs. suppose you publish this page on your
production server, where would your visitors get there scripts? they
are not on their machines in "d:/django-1.3...". basically, it is
unclear to me what you are trying to achieve.

konstantin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Weird hyperlink issue with Office and Django authentication

2011-08-16 Thread Konstantin Sushenko
as the article says, their sessions are independent of these used by
the web server. the cookies are not shared between office sessions and
web sessions. I think django has nothing to do with it.

On Aug 16, 4:04 am, Michel30  wrote:
> Hmm the workaround MS suggests actually works, so I have a
> workaround :-)
>
> But understanding why Django's authentication backend doesn't support
> this would be good
>
> On Aug 16, 9:10 am, Michel30  wrote:
>
>
>
>
>
>
>
> > Addidtionally I found this kb article that I believe describes what is
> > going on:http://support.microsoft.com/kb/899927/en-us
>
> > On Aug 16, 8:59 am, Michel30  wrote:
>
> > > I have made a CMS-like application to store and retrieve documents
> > > using Django 1.3, mysql and Apache.
>
> > > One requirement was that only authenticated users could use it and
> > > that after closing the browser the session should be expired.
> > > So, I implemented an LDAP authentication backend, set the
> > > "SESSION_EXPIRE_AT_BROWSER_CLOSE" to True and added an @login_required
> > > decorator to functions that need it.
> > > And it is working great, just like it should.
>
> > > Until using one feature that involves clicking on a hyperlink that is
> > > supposed to open a document within the application in a browser.
> > > This again works perfectly with every browser (firefix, chrome, IE) in
> > > several flavors of versions.
> > > With working I mean the document view opens, and this is important, as
> > > long as the user was already logged in to the application he/she
> > > doesn't have to log in again.
>
> > > It is working until trying this from any office (2000/2003)
> > > application. Then suddenly logging in is required every time
> > > regardless if an session exists or not.
> > > I did some investigating and found that clicking a hyperlink in an
> > > Office application triggers three requests, and it looks like the
> > > first one is missing the session cookie.
> > > Apache log for a hyperlink in Open office:
>
> > >     172.16.3.51 - - [15/Aug/2011:11:27:29 +0200] "GET /cgi-bin/DocDB/
> > > ShowDocument?docid=20916&version=8 HTTP/1.1" 200 3603 "-" "Mozilla/5.0
> > > (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/5.0"
>
> > > and the same document from Word:
>
> > >     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /cgi-bin/DocDB/
> > > ShowDocument?docid=20916&version=8 HTTP/1.1" 302 496 "-" "Mozilla/4.0
> > > (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR
> > > 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> > > 3.5.30729; .NET4.0C; .NET4.0E)"
>
> > >     172.16.3.51 - - [15/Aug/2011:11:26:09 +0200] "GET /login/?next=/
> > > cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> > > 3269 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/
> > > 4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR
> > > 3.5.30729; .NET4.0C; .NET4.0E)"
>
> > >     172.16.3.51 - - [15/Aug/2011:11:26:10 +0200] "GET /login/?next=/
> > > cgi-bin/DocDB/ShowDocument%3Fdocid%3D20916%26version%3D8 HTTP/1.1" 200
> > > 3278 "-" "Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20100101 Firefox/
> > > 5.0"
>
> > > Note the different status '200 = OK'  for OO and '302 Found' for Word.
> > > Also the length of the first returned object differ: 496 vs 3603.
>
> > > I am not sure where to point the finger to, or how to proceed and
> > > resolve it... So I'd appreciate some help a lot.
> > > Thanks,
> > > Michel

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Translation of class names

2007-05-03 Thread Konstantin Pavlovsky

hi all

I am working with administrative interface. and want to make it
"speak" russian
if it possible to translate names of Classes using i18n things?

ive translated field lables with lazy gettext

[code]
manager = models.ForeignKey(User,verbose_name=_("Manager"))
ordertext = models.TextField(_("Order contents"))
order_date = models.DateTimeField(_("Order date"))
client_name = models.CharField(_("Client"),maxlength=255)
order_state = models.ForeignKey(OrderStates,verbose_name=_("Order
state"))
[/code]

i see them in russian.it works
now i want modules to be called in russian.
i added
[code]
class Meta:
verbose_name = _('Order')
verbose_name_plural = _('Orders')
[/code]

Now a have module called Oders in index page of administrative
interface
I have ran make-messages , then putted nessesary frazes for Order and
Orders (which appeared after i added those 2 lines above) and ran
compile messages, but still no russian words appeared. i still have
Orders instead of translation. And again - Descriptions for fields are
working fine.
i have this import above all
[code]
from django.utils.translation import gettext_lazy as _
[/code]

I need some advice here:) thanx
P.S.
I have svn trunk from 26 of april this year.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Translation of class names

2007-05-07 Thread Konstantin Pavlovsky

up!
nobody used i18n things?


On 3 май, 16:05, Konstantin Pavlovsky <[EMAIL PROTECTED]>
wrote:
> hi all
>
> I am working with administrative interface. and want to make it
> "speak" russian
> if it possible to translate names of Classes using i18n things?
>
> ive translated field lables with lazy gettext
>
> [code]
> manager = models.ForeignKey(User,verbose_name=_("Manager"))
> ordertext = models.TextField(_("Order contents"))
> order_date = models.DateTimeField(_("Order date"))
> client_name = models.CharField(_("Client"),maxlength=255)
> order_state = models.ForeignKey(OrderStates,verbose_name=_("Order
> state"))
> [/code]
>
> i see them in russian.it works
> now i want modules to be called in russian.
> i added
> [code]
> class Meta:
> verbose_name = _('Order')
> verbose_name_plural = _('Orders')
> [/code]
>
> Now a have module called Oders in index page of administrative
> interface
> I have ran make-messages , then putted nessesary frazes for Order and
> Orders (which appeared after i added those 2 lines above) and ran
> compile messages, but still no russian words appeared. i still have
> Orders instead of translation. And again - Descriptions for fields are
> working fine.
> i have this import above all
> [code]
> from django.utils.translation import gettext_lazy as _
> [/code]
>
> I need some advice here:) thanx
> P.S.
> I have svn trunk from 26 of april this year.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Wiki or Blogs done with django

2006-05-29 Thread Konstantin Shaposhnikov
Hello,

Do not count this post as self promotion but you can also check my
personal site :) Here is how it looks like:
   http://step-inside.org
And here you can browse sources:
   http://step-inside.org/projects/stepinside/browser/trunk

Though it is not ported to the latest version (post magic-removal) of Django.

Regards,
Konstantin

On 5/29/06, Patrick <[EMAIL PROTECTED]> wrote:
>
> Another is:
> http://socialistsoftware.com/ and here you can find the source
> http://source.socialistsoftware.com/sssource/
>
> ciao ciao
> Patrick
> >
> > Possibly the quickest blog to get up and running is by Ross Poulton -
> > http://www.rossp.org/ - his code has not had the magic removed yet
> > though...
> >
> > Paul Bissex - http://e-scribe.com/news/171 - has done a *very* small
> > Wiki implementation.
> >
> > Cheers,
> > Tone
> >
> >
> > >
> >
>
>
>
> >
>


-- 
http://step-inside.org

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: auto_now_add bug with MySQL

2006-05-29 Thread Konstantin Shaposhnikov
Hello,

On 5/29/06, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED]> wrote:
> Andy,
>
> On 5/8/06, Andy Dustman <[EMAIL PROTECTED]> wrote:
> > Try the patch on this bug:
>
> The 2nd patch didn't work for me, as I noted in the ticket.
>
> The initial save with DateField(auto_now_add = True) is correct, it
> has the date as it should. But using it in conjunction with
> FileField() will cause an automatic UPDATE statement to happen and,
> 'lo and behold, the DateField is now None and thus violating the
> constraint.
>
> I can understand the logic of doing an UPDATE, but I wonder what to do
> with the date. Perhaps make sure the value of the date stamp is kept
> and passed in the UPDATE again?

I suggest you to not use auto_now_add at all if you are using current
(post magic-removal) version of django.
Instead declare your field like this:

  import datetime
  ...
  date_field = DateField(default = datetime.datetime.now, editable = False)

It has the same effect as auto_now_add and work with FileFields perfectly.

If you what to implement auto_now field, just override save() method
and set field value to current time before calling models.Model.save()

I am not really sure, but I seen somewhere that auto_now and
auto_now_add are going to become deprecated and it makes sense taking
into account that it is possible to achieve given functionlaity in
other way and code that supports auto_now[_add] is full of hacks.

> --
> Jeroen Ruigrok van der Werven
>
> >
>

Reagrds,
Konstantin
-- 
http://step-inside.org

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: auto_now_add bug with MySQL

2006-05-29 Thread Konstantin Shaposhnikov
On 5/29/06, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED]> wrote:
> Hi Konstantin,
>
> On 5/29/06, Konstantin Shaposhnikov <[EMAIL PROTECTED]> wrote:
> > I suggest you to not use auto_now_add at all if you are using current
> > (post magic-removal) version of django.
>
> I am using the SVN trunk yes. (It would be great if someone could
> finally fix trunk's setup.py to reflect what manage.py states about
> versioning.)
>
> [snip excellent suggestion]
>
> > I am not really sure, but I seen somewhere that auto_now and
> > auto_now_add are going to become deprecated and it makes sense taking
> > into account that it is possible to achieve given functionlaity in
> > other way and code that supports auto_now[_add] is full of hacks.
>
> I couldn't find such statement quickly, so if anyone can please update
> the list on this issue, thanks.

I've seen it here http://code.djangoproject.com/ticket/1056 (see the
first comment by jacob)
Though I am not sure how actual this statement is. Ticket seems to be quite old.


> Thanks Konstantin, I will play around with that.
>
> --
> Jeroen Ruigrok van der Werven
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: get_next_by_FIELD and alternate managers

2006-09-03 Thread Konstantin Shaposhnikov

Hi Nate,

You can pass additional filter arguments to get_next_by_pub_date
method like this:
entry.get_next_by_pub_date(is_published = True)

Regards,
Konstantin

On 9/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> In my blog I take advantage of get_next_by_FIELD (pub_date in this case)
> for navigation to older and newer stories in my entry detail view.  I
> also have a flag in my entry model that says whether or not a blog entry
> is published.  I defined an alternate manager called "published" to make
> it easier to pick out only published entries.
>
> My problem is that my older/newer navigation that uses
> entry.get_next_by_pub_date also picks up unpublished entries.  Is there
> a way to tell get_next_by_pub_date to use the manager "published"
> instead of "objects?"
>
> Nate
>
> >
>


-- 
http://step-inside.org

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: get_next_by_FIELD and alternate managers

2006-09-04 Thread Konstantin Shaposhnikov

On 9/4/06, Nate Straz <[EMAIL PROTECTED]> wrote:
>
> On Sun, Sep 03, 2006 at 11:26:22PM +0100, Konstantin Shaposhnikov wrote:
> > On 9/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > > My problem is that my older/newer navigation that uses
> > > entry.get_next_by_pub_date also picks up unpublished entries.  Is there
> > > a way to tell get_next_by_pub_date to use the manager "published"
> > > instead of "objects?"
> >
> > You can pass additional filter arguments to get_next_by_pub_date
> > method like this:
> > entry.get_next_by_pub_date(is_published = True)
>
> Is there a way to do this inside a template?
>
> I ended up defining new functions on the Entry model to keep calling
> get_next_by_pub_date until it got to a published entry.

It is possible to use keyword arguments to implement such method more
efficiently (and with less code) :

   def get_next_published(self):
   return self.get_next_by_pub_date(is_published = True)

In this case only one SQL query will be executed.


> Nate
>
> >
>


-- 
http://step-inside.org

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: view on site

2006-03-02 Thread Konstantin Shaposhnikov
On 3/2/06, Mary Adel <[EMAIL PROTECTED]> wrote:
>
> I did that but their is something that is very strange happened when i
> click on the view on site button it goes to microsoft site which is
> strange for me :(

You should edit details about your Site object in Admin application.
By default  domain of site is set to example.com and I think that your
borwser (IE I guess) redirecting you to the MSN search page.

> On Thu, 2006-03-02 at 18:00 +0530, Amit Upadhyay wrote:
> > Hi Mary,
> >
> > Put (r'^r/', include('django.conf.urls.shortcut')), in your URLConf.
> >
> > On 3/2/06, Mary Adel <[EMAIL PROTECTED]> wrote:
> >
> > i created my website using flatpages and they are amazing for
> > me and i on it goes
> > am very happy for that but their is a button on the page on
> > the right
> > hand side called (view on site) and when i clicked on it it
> > gave meing that is very starange
> > error says page not found what should i do to make this button
> >     work
> >
> >
> >
> >
> > --
> > Amit Upadhyay
> > Blog: http://www.rootshell.be/~upadhyay
> > +91-9867-359-701
> >
>
>

Regards,
Konstantin

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Django 2.1.1 creating CharField in a Form in Django on a Raspberry pi

2018-10-09 Thread konstantin Heinrich
I declared in views.py variable called frm so I have to use it
in my html file to have access to that file.?



Am Di., 9. Okt. 2018 um 13:54 Uhr schrieb Joel :

> instead of  {{ frm }}, try:
>
>  {{ form }}
>
> I think you'll understand what you did wrong.
>
> On Tue, 9 Oct, 2018, 5:07 PM ,  wrote:
>
>> hello,
>>
>> I've tried to create a simple CharField in a Form and show it in my
>> webbrowser
>> but I didn't see anything on my webbrowser?
>>
>>
>> Below my code:
>>
>> *forms.py*
>> from django import forms
>>
>>
>>
>> class  menuForm(forms.Form):
>> image = forms.CharField(initial = 'Your Name')
>> date = forms.DateField()
>>
>>
>>
>>
>>
>> *urls.py*
>> from django.urls import path
>> from . import views
>>
>> urlpatterns = [
>> path('', views.menu),
>>
>> ]
>>
>> *Views.py*
>> from django.shortcuts import render
>> from django.http import HttpResponse
>> from .forms import menuForm
>>
>> def menu(request):
>> frm = menuForm()
>>
>> return  render(request, 'base.html',  {' form ': frm} )
>>
>>
>>
>> *html-file*
>>
>> 
>>
>> 
>>  Menu
>>
>> 
>> 
>> Hallo
>> {{ frm }}
>>
>> 
>> 
>>
>> I can only see "Hallo" on my webbrowser but no input for a CharField?
>>
>> Can anybody help?
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/abc9ba3c-1d3b-4d84-9915-16c4fc02a27e%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAA%3Diw_9w2hC5sEUOyvWgC%2BPOysiptQTJizdVp1acS91dra_gHQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHKy%2BPnYcLS8M3ZPp-G3gT%2BmYgaxo6z2U1jay3OvmpwKJ7UhQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
from django.shortcuts import render
from django.http import HttpResponse
from .forms import menuForm

def menu(request):
frm = menuForm()

return  render(request, 'base.html',  {' form ': frm} )


Re: Django 2.1.1 creating CharField in a Form in Django on a Raspberry pi

2018-10-09 Thread konstantin Heinrich
I replaced code with {{ form }} but nothing changed.?

Am Di., 9. Okt. 2018 um 14:19 Uhr schrieb Joel :

> You passed form to template, so you have to refer to that.
>
> On Tue, 9 Oct, 2018, 5:33 PM konstantin Heinrich, <
> kheinrichdja...@gmail.com> wrote:
>
>> I declared in views.py variable called frm so I have to use it
>> in my html file to have access to that file.?
>>
>>
>>
>> Am Di., 9. Okt. 2018 um 13:54 Uhr schrieb Joel :
>>
>>> instead of  {{ frm }}, try:
>>>
>>>  {{ form }}
>>>
>>> I think you'll understand what you did wrong.
>>>
>>> On Tue, 9 Oct, 2018, 5:07 PM ,  wrote:
>>>
>>>> hello,
>>>>
>>>> I've tried to create a simple CharField in a Form and show it in my
>>>> webbrowser
>>>> but I didn't see anything on my webbrowser?
>>>>
>>>>
>>>> Below my code:
>>>>
>>>> *forms.py*
>>>> from django import forms
>>>>
>>>>
>>>>
>>>> class  menuForm(forms.Form):
>>>> image = forms.CharField(initial = 'Your Name')
>>>> date = forms.DateField()
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *urls.py*
>>>> from django.urls import path
>>>> from . import views
>>>>
>>>> urlpatterns = [
>>>> path('', views.menu),
>>>>
>>>> ]
>>>>
>>>> *Views.py*
>>>> from django.shortcuts import render
>>>> from django.http import HttpResponse
>>>> from .forms import menuForm
>>>>
>>>> def menu(request):
>>>> frm = menuForm()
>>>>
>>>> return  render(request, 'base.html',  {' form ': frm} )
>>>>
>>>>
>>>>
>>>> *html-file*
>>>>
>>>> 
>>>>
>>>> 
>>>>  Menu
>>>>
>>>> 
>>>> 
>>>> Hallo
>>>> {{ frm }}
>>>>
>>>> 
>>>> 
>>>>
>>>> I can only see "Hallo" on my webbrowser but no input for a CharField?
>>>>
>>>> Can anybody help?
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to django-users@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-users/abc9ba3c-1d3b-4d84-9915-16c4fc02a27e%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/abc9ba3c-1d3b-4d84-9915-16c4fc02a27e%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAA%3Diw_9w2hC5sEUOyvWgC%2BPOysiptQTJizdVp1acS91dra_gHQ%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAA%3Diw_9w2hC5sEUOyvWgC%2BPOysiptQTJizdVp1acS91dra_gHQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.c

Re: Django 2.1.1 creating CharField in a Form in Django on a Raspberry pi

2018-10-09 Thread konstantin Heinrich
Hi Michal,

yes that was the error.
Thank you so much.
Strange that no error was shown.

Am Di., 9. Okt. 2018 um 14:39 Uhr schrieb Michal Petrucha <
michal.petru...@konk.org>:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA512
>
> Hi,
>
> On Tue, Oct 09, 2018 at 02:28:25PM +0200, konstantin Heinrich wrote:
> > I replaced code with {{ form }} but nothing changed.?
>
> There's one more error in your code, and it's right here:
>
> > return  render(request, 'base.html',  {' form ': frm} )
>
> As you can see above, you're passing a context variable by the name of
> “ form ” with a leading an trailing space to the template engine. As
> far as I know, context variables cannot contain spaces, because there
> is no way to actually refer to them from the template itself.
> Honestly, I'm surprised that doesn't raise an error.
>
> Regardless, you should remove the spaces around “form”, and then
> you'll be able to refer to the form as, well, “form” in your template.
>
> Good luck,
>
> Michal
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1
>
> iQIcBAEBCgAGBQJbvKE4AAoJEHA7T/IPM/klQToP/0+5qNMWutLRDIkvYdXAz/iQ
> rTfPg36VcKJzgdHz2ncRvl9wYNhxyeyGqYS/FjQr8ZyqkMFsL89UfamSEDdwkJiP
> BOVm4IWrVdPoANRqtaklmChBHMbFCAsDrj+RY6UH9nZDTb5yiKraRHfKNFadJ4GA
> LimrIXMbcPJ/2hzC+imv68qsR81WOeIdSSNrY4TnyJrzVp0qgZaiWdQ8YCmG0Tbc
> S71nNvUUfbNCp2kCiu/pH0wLscMXBJlSVJ5BtzGN99gK9LusSUKWJ/mqLm7w9DCS
> k2Z0xCgQ8NwaNRvtkRsl3TEHIpAfac3vf92/VEuWsOGWpCb8d8KYCwVzsf57J9Kf
> 6QCP9pw9RP8B3JMIm3I0djiakA3UTZNfbog3aQGzLVROmuQjUyWwvxVw2vaqUhj2
> moL/Eq/M6eahcfYn3CFYfLojqukXDS0pL1Qgj+Njqng2qiG5DKAIF1iMFZZoREs4
> OOZC+dJg3Vos/ebY/vZBYdAxO92UsKYXod5WCqNaoyyKuwWaufoHhNZoteVZ5hjj
> F6GGcGP6ugdswmZDT1E3+RnLgFsmB8G8+w3uAi8obFDhFjkldgfVxEnw0Ki2JcTB
> UWkD1KCur9f7hYo+34vNNfiCtXlxACaMdVNdb3X1R5aCMvh5VjvBJI/31ja6Yw9Z
> K3cucs2jnkLdbf9KiSZD
> =aClS
> -END PGP SIGNATURE-
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20181009123816.GE18928%40konk.org
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHKy%2BP%3D6ghn_JJGz_F6rRqpR1A6LBPCECpyWNSHt%3D2e%3DCL1tbQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: register_converter doesn't work with ASGI

2021-06-21 Thread Konstantin Kuchkov
Thanks for the explanation!

To get it working, I will replace my model converters with basic converters 
and do corresponding lookups in the views.

On Sunday, 20 June 2021 at 16:16:58 UTC-7 Andrew Godwin wrote:

> Ah yes, that's because the URL parsing/conversion all happens in the main 
> (async, in ASGI mode) thread - and because to_python is a a synchronous 
> function interface, there is literally nothing you can do to make it work.
>
> The only real way of fixing this would be for Django to patch the URL 
> converters and run them all in a synchronous mode unless they were 
> decorated as "safe" somehow, much like we do for middleware. It's not a 
> terribly hard patch to make, but it does mean you don't have an immediate 
> solution. There are ways of trying to work around it, but they will all 
> result in you blocking the async thread while the ORM query runs, which 
> would be disastrous in production.
>
> My apologies for not getting this in for the original async view patch - I 
> had forgotten converters ran in the URL resolver.
>
> Andrew
>
> On Sat, Jun 19, 2021, at 12:31 AM, konstanti...@gmail.com wrote:
>
>
> I'm trying to switch from WSGI to ASGI and I'm having issues with my model 
> id to model converters.
> I define my converters like this
> def to_python(self, primary_key):
>  try:
>   return self.model.objects.get(pk=primary_key)
>  except self.model.DoesNotExist:
>   raise ValueError
> When I go to a url where a converter is used I get a 
> SynchronousOnlyOperation.
> Seems like converters are executed in an async context.
> If I use sync_to_async, I get a coroutine in my view instead of a model 
> instance. Awaiting it here would defeat the purpose of having a converter.
>
> Any ideas how to fix this?
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/ef60ed71-7f4f-482d-b540-bdf89e249aa4n%40googlegroups.com
>  
> 
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c130ef88-4dbf-42b9-a7b3-f0ba0b174a0an%40googlegroups.com.


ORM migration index name mismatch. Can't drop existing index.

2022-05-16 Thread Konstantin Kuchkov
Context:
In an app called "exams", I have a model named Capture which has a unique 
CharField named "uuid". I was trying to convert this field to a UUIDField 
and I was getting this error:
django.db.utils.ProgrammingError: operator class "varchar_pattern_ops" does 
not accept data type uuid

Looking at the postgres table I found this index
"exams_capture_uuid_4a3af4ea353edaa5_like" btree (uuid varchar_pattern_ops)
However, the migration was trying to drop an index by a different name
DROP INDEX IF EXISTS "exams_capture_uuid_0c20e2c2_like";
Works correctly if I add a RunSQL migration to remove the culprit.

So I'm wondering where did the other index name come from? We never mess 
with postgres schema without going through Django ORM.
Originally, the table was created in Django 1.11, and, currently, we're on 
Django 4.04. Did something change between versions that caused index naming 
to be different? I checked the initial migration with sqlmigrate and even 
that shows the new index name.

Is there a way to work around this without hardcoding index name in raw sql?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7e854d78-2b24-4e52-b385-239ea9b8d288n%40googlegroups.com.