Recreation of foreign key constraints when changing type of referenced primary key
Hi, I have a question regarding Django version 3.2.12. When I change the DEFAULT_AUTO_FIELD to BigAutoField and create&apply migrations, the foreign keys of auto-generated through tables are dropped. This can be observed by running sqlmigrate which drops foreign key relations but never recreates them. I noticed this is already fixed in Django 4.0.3 (Refs #32743 -- Fixed recreation of foreign key constraints when alter… · django/django@3d9040a · GitHub 1) but not in 3.2.x branch. Can I expect this commit will in time be applied to Django 3.2.x branch? I would like to migrate to BigAutoField to be future-proof, but would prefer not to write migrations by hand. Regards, Gregor -- 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/5821193.lOV4Wx5bFT%40delko.
Missing ORDER BY in subselect?
Hi! I am experiencing a weird Queryset behavior. Let the variable treatments refer to an ordered (and sliced) queryset. The first query Service.objects.filter(treatment__in=treatments).distinct() returns different objects than the second one Service.objects.filter(treatment__in=list(treatments)).distinct() , but I would expect both results to be the same. Service model declares treatment field as ForeignKey. The results given by the first query are incorrect. Further SQL code inspection reveals that ORDER BY clause (from treatments QuerySet) is missing in subselect. The results of the second query are correct, since subquery is evaluated first (with ORDER BY clause included). It actually looks similar to an old bug #12328, which was marked as fixed long time ago and I am using Django 1.6. Am I missing something? Many Thanks, Gregor -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4696202.A3ANhoRLR9%40gregor. For more options, visit https://groups.google.com/d/optout.
Using Google Fusion tables as database
Hi, Is it possible to use Django with Google Fusion Tables http://code.google.com/apis/fusiontables/ as the backend? -- 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 email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
formsets management_form
Hello, I may do something, what the formsets are not intended for. I have forms which assort data of several different Models. This is because of aggregating data in logical blocks in the UI. Additionally I have some fields, which have to be filled dynamically. There is as well the possibility for the user in the UI, to generate new blocks of data (Javascript). The thing goes as follow. Having for each logical data group a form,because there can be blocks from 1 to n, using a formset for each. Because I have a bunch of different set of those blocks, I have several formsets. Example: The form: class F(forms.Form): foo = forms.CharField(choices=()) bar = forms.ChoiceField(choices=()) def __init__(self,*args,**kwargs): foo = None bar = None if kwargs.has_key('foo'): foo = kwargs.pop('foo') if kwargs.has_key('bar'): bar = kwargs.pop('bar') super(F,self).__init__(*args,**kwargs) if foo and bar: self.fields['foo'] = forms.ChoiceField(choices=foo) self.fields['bar'] = forms.ChoiceField(choices=bar) class BaseFS(formsets.BaseFormSet): def __init__(self,*args,**kwargs): if kwargs.has_key('foo'): self.foo = kwargs.pop('foo') if kwargs.has_key('bar'): self.bar = kwargs.pop('bar') super(BaseFS,self).__init__(*args,**kwargs) def _construct_forms(self): self.forms = [] for i in xrange(self.total_form_count()): self.forms.append(self._construct_form(i,foo=self.foo, bar=self.bar)) The view: def newd(request): foo = [ (x,x) for x in Foo.objects.all() ] bar = [ (x,x) for x in Bar.objects.all() ] NFS = formset_factory(F,formset=BaseFS) OtherFS = formset_factory(OtherF,formset=BaseOtherFS) if request.method == 'POST': fs = NFS(request.POST,foo=foo,bar=bar) ofs = OtherFS(request.POST,foo=foo,bar=bar) if fs.is_valid(): # get the data,distribute to the right model return HttpResponse("valid really") else: return render_to_response('error.html',{'fs' : fs,'ofs' : ofs}) else: fs = NFS(foo=foo,bar=bar) ofs = OtherFS(foo=foo,bar=bar) return render_to_response('newd.html',{'fs' : fs,'ofs' : ofs}) This seems generally to work.But now comes the twist. May be there are other twists in (my) code, which I do not see. But this is one is a detail. In the template: {{ fs.management_form }} {{ ofs.management_form }} which produces So,regrettably, therefore I can't differentiate between the count of different formset data, which I have to. I can't even prefix the values of the id. There is no idea of this in,e.g. django.forms.formsets.BaseFormSet._management_form: else: form = ManagementForm(auto_id=self.auto_id, prefix=self.prefix, initial={ TOTAL_FORM_COUNT: self.total_form_count(), INITIAL_FORM_COUNT: self.initial_form_count(), MAX_NUM_FORM_COUNT: self.max_num }) I hope the structure of my setup and the problem is clear to understand... Maybe someone has some hints in any direction. gfk -- 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 email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: accessing pk of an existing object in ModelForm
Daniel Roseman wrote: > On Nov 23, 2:57 pm, hg7581 wrote: > >> Hello there, >> For doing some sanity checks, I need the primary key (pk) of an >> (already existing) object in a ModelForm. >> >> What works for me in the meantime, ist the following (admin interface): >> >> class NF(ModelForm): >> def __init__(self,*args,**kwargs): >> self._args = args >> self._kwargs = kwargs >> super(NF,self).__init__(*args,**kwargs) >> >> class NA(ModelAdmin): >> form = NF >> >> and deeper in the underground in a method >> I use the following for the checks. >> self._kwargs.has_key('instance'): >> pk = self._kwargs['instance'].pk >> >> Now the question. Is there a more canonical form of accessing >> this data ? >> >> thanks >> gregor >> > > Why not just use self.instance? > ahm. Good point. But what I mean is, if this a safe access respective to the public api. gregor > -- > DR. > > -- > > 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 email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=. > > > -- 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 email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.
Re: machinetags with namespaces and values, a ready-to-use branch
On Oct 15, 11:27 am, Sam Lai wrote: > I haven't looked at your code yet (I will soon), but I'm just curious > if your changes have had any impact on performance? I remember that > when I set out to implement some of this code, I had issues with it > being efficient when there are larger sets of tags, including > excessive database calls, or excessive data parsing. Unfortunatelly the branch is slower yes. Thats a bad thing ofcourse but a simple test revealed that the parse_tag_input must be the bottleneck. I changed this function to rely on regexps instead of simple char-by-char parsing and i think this slowed things down. Maybe i can rewrite this function again to avoid regexps. I'll let you know when i've tried something new in this function to speed things up. Here are also the results from a very simplistic performance test suite. Every test were run with 1 tags in string representation. MachineTags are tags with namespaces, names and values (each 5 characters long). NamespacedTags are tags with namespaces (5 chars) and names (10 chars). NormalTags are tags without any namespace and value, the names are 15 chars long. At first the results for the original tagging application: MachineTags test1_parse_tag_input 0.09s test2_insert_tags 9.76s test3_get_tag_list 0.87s test4_get_tag 4.85s MachineTags, total time: 15.57s NamespacedTags test1_parse_tag_input 0.09s test2_insert_tags 9.69s test3_get_tag_list 0.85s test4_get_tag 4.81s NamespacedTags, total time: 15.44s NormalTags test1_parse_tag_input 0.09s test2_insert_tags 9.70s test3_get_tag_list 0.85s test4_get_tag 4.81s NormalTags, total time: 15.44s And the results for the machinetags branch: MachineTags test1_parse_tag_input 0.43s test2_insert_tags 13.19s test3_get_tag_list 6.37s test4_get_tag 7.45s MachineTags, total time: 27.43s NamespacedTags test1_parse_tag_input 0.34s test2_insert_tags 12.94s test3_get_tag_list 6.13s test4_get_tag 7.40s NamespacedTags, total time: 26.81s NormalTags test1_parse_tag_input 0.10s test2_insert_tags 12.75s test3_get_tag_list 17.59s test4_get_tag 7.28s NormalTags, total time: 37.72s Here are the test methods: def test1_parse_tag_input(self): for tag in self.tags: parse_tag_input(tag) def pre_test2_insert_tags(self): self.articles = [] for i in range(len(self.tags) / 10): self.articles.append(Article.objects.create(name=i)) def post_test2_insert_tags(self): Article.objects.all().delete() def test2_insert_tags(self): for i, a in enumerate(Article.objects.all()): Tag.objects.update_tags(a, ', '.join(self.tags [i*10:i*10+10])) def test3_get_tag_list(self): for i in range(0, len(self.tags), 10): l = get_tag_list(', '.join(self.tags[i:i+10])) assert len(l) == 10, len(l) def test4_get_tag(self): for tag in self.tags: assert get_tag(tag) Gregor --~--~-~--~~~---~--~~ 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 start this dev server
Hi, please try to create an empty __init__.py file in your ~/nimma/ directory. Gregor On 15 Okt., 00:50, David wrote: > Hello django community, > > I checked out a django project from svn and tried to start dev server, > however I met > > d...@sgbr:~/nimma$ python manage.py runserver > Error: No module named nimma > d...@sgbr:~/nimma$ > > In my home directory I have > > nimma -> svn/nimma/trunk/ > svn > > and "svn" is a work copy and leads to "svn/nimma/trunk". In "trunk" > there are "manage.py", "settings.py", "urls.py", etc. > > Anybody knows how to make dev server start in this case? > > Thanks so 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 -~--~~~~--~~--~--~---
Re: Django test suite does not discover test method "test_string_regex"
I discovered that it gets not execute by looking at the coverage statistics. But you're totally right. I had a second method that is called the same. Very embarrassing for me. Sorry. Gregor 2009/8/28 Karen Tracey : > On Thu, Aug 27, 2009 at 2:21 PM, Gregor Müllegger > wrote: >> >> Hi, >> >> i have an issue with the standard test runner of django. If i try to >> run the testsuite of an app everything gets executed in the right >> fashion. While all executed tests pass without errors, the test method >> "test_string_regex" is not evaluated! If i rename the method to any >> athor name like "test_string_regex2", "test_string__regex" or >> "test__string_regex" it is discovered by the test suite. >> I also can execute the single test with the "python manage.py test >> applabel.TestCaseName.test_string_regex". >> >> This seams very scary to me. >> Is this a bug in the django testrunner? > > Unlikely. More likely there is something in your test suite causing this. > How are you determining that this method is not running when you run the > full suite? Are you sure you don't have multiple test_string_regex methods > defined in this TestCase? > > FWIW, I just tried adding a method with that name to a test suite I have and > it runs fine. > > Karen > > > > --~--~-~--~~~---~--~~ 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 test suite does not discover test method "test_string_regex"
Hi, i have an issue with the standard test runner of django. If i try to run the testsuite of an app everything gets executed in the right fashion. While all executed tests pass without errors, the test method "test_string_regex" is not evaluated! If i rename the method to any athor name like "test_string_regex2", "test_string__regex" or "test__string_regex" it is discovered by the test suite. I also can execute the single test with the "python manage.py test applabel.TestCaseName.test_string_regex". This seams very scary to me. Is this a bug in the django testrunner? Gregor --~--~-~--~~~---~--~~ 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: ModelForm/clean_
Daniel Roseman wrote: > On Mar 6, 10:37 am, gregor kling > wrote: >> Hello List, >> >> I have a form inheriting from ModelForm. >> class C(ModelForm): >> >> >> class Meta: >> model = SomeModel >> >> def clean_somefield: >> enhanced checks >> >> Now my problem is how to access session data (request.session) >> from within the clean method. >> Does anyone have a clue how to this. >> >> gfk > > Override the form's __init__ method to accept the request as a keyword > parameter, and stash it in an instance attribute. > > class MyForm(forms.ModelForm): > def __init__(self, *args, **kwargs): > self.request = kwargs.pop('request') > super(MyForm, self).__init__(*args, **kwargs) > > def clean_somefield(self): > .. do something with self.request... > > form = MyForm(request.POST, request=request, instance=myinstance) Thanks Daniel. That works like a charm. gfk > -- > DR. > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ModelForm/clean_
Hello List, I have a form inheriting from ModelForm. class C(ModelForm): class Meta: model = SomeModel def clean_somefield: enhanced checks Now my problem is how to access session data (request.session) from within the clean method. Does anyone have a clue how to this. gfk --~--~-~--~~~---~--~~ 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: Problems with multithreading in fastcgi environment
Thank you for your answer Malcolm. Though what would you suggest as an solution? Shall i use the multiprocessing package as a replacement for the threaded module (i've already tried that, see below) or is it better to execute a management command with Popen('python manage.py process_video_queue') from the subprocess module? I already tried it with multiprocessing, but it hasn't worked - just like threading. It doesn't get executed. Thanks again, Gregor 2009/2/15 Malcolm Tredinnick : > > On Sat, 2009-02-14 at 11:31 -0800, Gregor Müllegger wrote: >> Hi djangonauts, >> >> at the moment i try to setup a youtube-like site. Users can upload >> videos which will be converted with ffmpeg to the flv format. The >> convertion process is fired up in a view. Though i use the "threaded" >> module to not interrupt the view for sending back the response. > > This comes up quite often and the standard answer is that this isn't the > right approach to solving the problem. You are tying the background > processing to the lifecycle of the fastcgi process. Web processes can > stop and start for various reasons (including periodically being killed > after a number of requests to rest the memory base). > > Better to use a queue-like setup where you make a record of any > conversions that need to be done and have another process (or processes) > that go through the queue and convert things. The lifecycle of the > latter processes aren't then tied to the web-stack lifecycles. > > Regards, > Malcolm > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Problems with multithreading in fastcgi environment
Hi djangonauts, at the moment i try to setup a youtube-like site. Users can upload videos which will be converted with ffmpeg to the flv format. The convertion process is fired up in a view. Though i use the "threaded" module to not interrupt the view for sending back the response. In my development installation and on the production server in the "python manage.py shell" seems to work all perfectly. But when i try to use this method on the production server with a browser (i use nginx with django in an fcgi server, method is prefork), the video will not be converted as long as i try to do it in a new thread. If i block the view with processing the video in the same thread as the request, everything works ok. Does anyone know if there are known problems with multithreading in an fcgi environment? I hope someone can help me ... this bugs me quite a while. Thank you all. Gregor --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
VIM Plugin: Django Projects
Hi Djangonauts! Today i've written a plugin for vim to support django's management commands from within vim like runserver or syncdb etc. It supports settingup multiple projects. Just have a look at the plugin page on vim.org to see all details: http://www.vim.org/scripts/script.php?script_id=2392 It will only work on Unix-like systems and is only tested on linux. To install it just place it in your ~/.vim/plugin directory. Please tell me if you like the plugin and what else can be improved. Don't be shy and throw all your critisism at me. Gregor --~--~-~--~~~---~--~~ 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: Customizing the error page
The django-command-extensions manipulate the debug page to add an interactive console. They provide a new management command for that: "runserver_plus" Maybe you can get some know-how from them: http://code.google.com/p/django-command-extensions/source/browse/trunk/django_extensions/management/commands/runserver_plus.py On Aug 17, 5:54 pm, "Chris Moffitt" <[EMAIL PROTECTED]> wrote: > Does anyone know the best practice for customizing the default Django error > page? The simplest thing I'd like to do is include a version number for > other software components (just like Django does now) so that it makes it > easier for us to troubleshoot issues with Satchmo. Has anyone done this in a > simple way without hacking Django? > > Thanks, > Chris --~--~-~--~~~---~--~~ 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: Adding fields to form in form.clean()
Maybe you could use django's form wizard: http://www.djangoproject.com/documentation/form_wizard/ On Jun 25, 9:27 am, Thomas Guettler <[EMAIL PROTECTED]> wrote: > Hi, > > depending on the values from form.cleaned_data, I want to present different > input fields to the user. Example: > The user chooses a country, and after submit (no ajax), the > cities of this country should be in a drop down box. > > Since my setup is more complex, I don't want to use the uncleaned > request.POST or form.data. > > I guess I need to create two forms .. > Any hints? > > Thomas > > -- > Thomas Guettler,http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ 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: reloading models in the shell
Maybe the builtin function ``reload`` might help you: http://docs.python.org/lib/built-in-funcs.html I haven't tested it with django but it should work like that: >>> from yourapp import models >>> # Do stuff with your model >>> # Change models sourcecode >>> models = reload(models) >>> # Do more stuff with your new models Gregor On 12 Jun., 03:01, "Gene Campbell" <[EMAIL PROTECTED]> wrote: > I'm very new to Python and Django, I'm going through building some > models for the first time. > When I load the models in my shell like this > > python manage.py shell > > >>> from app.models import ModelClass > > then make a change to the ModelClass in models.py > > Now when back in the shell how do I reload the changes. This is no > doubt simple and due to my lack of experience with Python and Django. > I have tried > > reload(app.models) > reload(app.models.ModelClass) > reload(models) > etc. > > I can, of course, ctrl+D, and restart the shell, then reimport and the > changes are there. Is that the only way? > > thanks! --~--~-~--~~~---~--~~ 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: Suggestions on resolving broken link errors for free comment app
This is because the django.contrib.comments app still uses hardcoded links in its code. A quick and dirty workaround would be to setup a redirect from / comments/postfree/ to /your/comment/posting/url/ , but thats not quite nice. You could also fix the source code or copy&paste the comments app anthor location an alter the hardcoded links. (also quick&dirty but i cannot think of another solution) Gregor On 6 Jun., 01:13, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm using Django's free comments app for my site's blog app, but am > getting a lot of broken link errors like the following: > > Referrer:http://patrickbeeson.com/blog/2007/nov/06/rank-most-read-time-spent-n... > Requested URL: /comments/postfree/ > User agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) > IP address: 127.0.0.1 > > I can't find anything wrong in my templates -- can anyone offer any > suggestions? --~--~-~--~~~---~--~~ 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: Apache FastCGI & Django
Here is a sample configuration from one of my sites (domains and paths are altered): FastCGIExternalServer /var/www/myproject/fcgidummyfile.fcgi -host 127.0.0.1:3044 ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com Alias /static /var/www/example.com_static RewriteEngine On RewriteRule ^/(static.*)$ /$1 [QSA,L,PT] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/(.*)$ /fcgidummyfile.fcgi/$1 [QSA,L] --~--~-~--~~~---~--~~ 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: ASP.Net GridView Equivalent in Django
You are searching an UI Widget, is that right? Django doesn't provide any builtin UI stuff, except the templatetages. But you could try some of the following JavaScript libraries which inculde UI stuff: http://jquery.com/ with http://ui.jquery.com/ http://dojotoolkit.org/ http://extjs.com/ (i think this is the best for building "desktop like" webapps, it also includes a GridView) On 5 Jun., 01:10, Ian <[EMAIL PROTECTED]> wrote: > I am .Net developer looking to switch over to Python. > > I have started looking at Django and was wondering if there is a > widget equivalent to ASP.Net's GridView in terms of richness of > functionality. > > If someone knows of any and has some examples of its use I would > greatly appreciate 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Capturing full URL string
This is because Django will redirect you to a page with an appended slash to your url if it's not already there -- how you have discovered. To understand why this is done you should read the following section in django's documentation: http://www.djangoproject.com/documentation/middleware/#django-middleware-common-commonmiddleware To prevent the trailing slahs, set in your settings module APPEND_SLASH to False. Gregor --~--~-~--~~~---~--~~ 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: Relative views in urls.py
Your last example is near the typical solution. You could pass as second element of the "url-tuples" a callable object e.g. a view. from django.conf.urls.defaults import * import views urlpatterns = patterns('', (r'^(?P[a-z0-9_-]+)/$', views.view_city), (r'^(?P[a-z0-9_-]+)/category/(?P[a- z0-9_-]+)/$', views.view_category), (r'^(?P[a-z0-9_-]+)/all-categories/$', views.view_category_list), ) If you do that, the first argument of patterns() have no semantical meaning anymore. --~--~-~--~~~---~--~~ 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: local import or not for django apps?
I also think that apps should live in somewhere in your python path. But if you can use Python 2.5 for your django projects you could also write imports in the following style. from . import spam This imports the module "spam" from the folder the sourcefile lives in. It's much cooler than just doing a "import spam" because you can also call a file "django.py" or "sys.py" in your app without collidating with the standard library and athors thirdparty packages. Gregor --~--~-~--~~~---~--~~ 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: Memcached hangs & never responds?
I think this might be it, thank you *so much* Karen! On May 2, 1:55 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Thu, May 1, 2008 at 6:51 PM, Gregor Hochmuth <[EMAIL PROTECTED]> wrote: > > > Hello, > > Has anyone experienced the following symptom with Memcached before? > > > Intermittently and unpredictably, requests to our production web > > server will start "hanging" in the "Waiting for response..." loop and > > never get any further. When we restart memcached on the server, the > > request executes right away and things are back to normal (even > > requests that were pending suddenly finish) > > > Do you happen to know what the cause of this might be? We're using the > > most recent version of python-memcached (from tummy.com) and a recent > > development version of Django (0.97x) > > > I'd much appreciate any advice! Thanks, > > Could it be the same problem as this: > > http://code.djangoproject.com/ticket/5133 > > ? > > Karen --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Memcached hangs & never responds?
Hello, Has anyone experienced the following symptom with Memcached before? Intermittently and unpredictably, requests to our production web server will start "hanging" in the "Waiting for response..." loop and never get any further. When we restart memcached on the server, the request executes right away and things are back to normal (even requests that were pending suddenly finish) Do you happen to know what the cause of this might be? We're using the most recent version of python-memcached (from tummy.com) and a recent development version of Django (0.97x) I'd much appreciate any advice! Thanks, Greg. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
User tampered with session cookie
Hello, Maybe there is someone having an idea about this: There seems to be a couple of unsolved ? problems in combination with 'User tampered with session cookie' I have already used successfully the save/restore-session possibilty, with no problem. I do things like req.session['uid'] = uid, req.session['domains'] = domains, domains = req.session['domains'] with no problem. But when I want to store a more complicated object than a simple list using the cPickle module I get the 'User tampere...'-message. Environment: debian etch, python-django 0.95-1,no php,apache2.2.3-3.2. Another question is how to delete a session explicitly. I want to give the user the possibilty to logout. I do not find anything to delete the session? thx. -- Gregor Kling DV-Zentrum Fachhochschule Giessen Tel: 0641/309-1292 E-Mail: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: iteration over non-sequence and other quirks
Damn me, it was all my fault :-) Django gave me exactly, nearly, the hint. Regrettably django provided me with the false line number. So I have searched everywhere but the right position. django claimed 'The iteration over non sequence error' at the outer for-loop, but the problen was indeed in one of the embedded for-loops. Maybe this is something for a wishlist - to get the right line number in case of an error. gfk --~--~-~--~~~---~--~~ 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: iteration over non-sequence and other quirks
Gregor Kling wrote: {% for ndata in ndatas %} <--- iteration over nonsequence Netzdaten Ethernet-Adresse:* DHCP aktivieren ?:* {% for doption in dhcpoptions %} {% ifequal doption.get_val ndata.get_mac_dhcp_eintrag %} {{ doption.get_name }} {% else %} {{ doption.get_name }} {% endifequal %} {% endfor %} Hm, it seems django has a problem with the nature I do use the for loops. In the enclosing for-loop I have several other for-loops which are looping over other lists than the enclosing for-loop-list. Is this form of procedure not intended ? Actually I don't want to create an object only for this form-handling.But in absence of a suggestion, it seems I have no other choice. This seems to work, but if I use the browser-back-button and post the form again, i get a 'string accelerator'. This is (temporarly) solved with a Singleton. gfk --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
iteration over non-sequence and other quirks
Hello, I do get an iteration over non sequence error. If I make a normal in python code everything works as assumed, but I if let django iterate over , it says iteration over The weird thing is, that it worked sometime ago, but I can't recall whats the difference between know and the time it worked :-(. Apart from that, if i can iterate over the list in python directly, it should work in the template environment too (the iteration), - a list is a list. So does anyone have a general clue what's going on here? The template looks something like that: ... {% for ndata in ndatas %} <--- iteration over nonsequence Netzdaten Ethernet-Adresse:* DHCP aktivieren ?:* {% for doption in dhcpoptions %} {% ifequal doption.get_val ndata.get_mac_dhcp_eintrag %} {{ doption.get_name }} {% else %} {{ doption.get_name }} {% endifequal %} {% endfor %} ... Another thing is the usage of the python logging module. I have a class that does the general configuration for the logging. Momentarily it is merely the example provided by the library-doc from python. So I have a class: class Dlogger(object): def __init__(self,app=''): self.__logger = logging.getLogger('blax'+app) self.__hdlr = logging.FileHandler() self.__formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') self.__hdlr.setFormatter(self.__formatter) self.__logger.addHandler(self.__hdlr) self.__logger.setLevel(logging.DEBUG) From everywhere I want to use it, I instantiate a Dlogger-Object with a unique app-string. This seems to work, but if I use the browser-back-button and post the form again, i get a 'string accelerator'. So every time I do this, the output of a string is incremented by one like this DEBUG login-session-info blah DEBUG login-session-info blah instead of DEBUG login-session-info blah. P.S. I have to admit, that right now I have read the documentation not very painstakingly, but I assume this has something to do with the mod_python/django/cache ?... thx. --~--~-~--~~~---~--~~ 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: django something wrong with many to many relationship
thanks man I find error, I forget pass joined attribute. Thanks Again --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
django something wrong with many to many relationship
Hello i have manytomany relations (database PostgreSql 8.1.5) like this: class Photograph(models.Model): name = models.CharField(maxlength=200) email = models.EmailField() age = models.IntegerField() categories = models.ManyToManyField(Category) joined = models.DateField() albums = models.IntegerField() photos = models.IntegerField() county = models.ForeignKey(County) city = models.ForeignKey(City) class Category(models.Model): name = models.CharField(maxlength=15) I create some Categories like that: category = Category(name='weddings') category.save() and then I create a photograph and here is a problem: In [8]: p = Photograph(name="p", email="[EMAIL PROTECTED]",albums=26, photos=12,city=city, county=county, categories=category) --- exceptions.TypeError Traceback (most recent call last) C:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\base.py in __init__(self, *args, **kwargs) 123 pass 124 if kwargs: --> 125 raise TypeError, "'%s' is an invalid keyword argument for this function" % kwargs.keys()[0] 126 for i, arg in enumerate(args): 127 setattr(self, self._meta.fields[i].attname, arg) TypeError: 'categories' is an invalid keyword argument for this function or if try to save: Photograph.save() In [19]: p = Photograph(name="Smith",email="[EMAIL PROTECTED]",albums=26, photos=34, county=woj, city=miasto) In [20]: p.save() --- psycopg.ProgrammingError Traceback (most recent call last) I:\Prace\PRYWATNE\DJANGO_projekty\moremoments\ C:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\base.py in save(self) 202 cursor.execute("INSERT INTO %s (%s) VALUES (%s)" % \ 203 (backend.quote_name(self._meta.db_table), ','.join(field_names), --> 204 ','.join(placeholders)), db_values) 205 else: 206 # Create a new record with defaults for everything. C:\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\backends\util.py in execute(self, sql, params) 10 start = time() 11 try: ---> 12 return self.cursor.execute(sql, params) 13 finally: 14 stop = time() ProgrammingError: ERROR: null value in column "age" violates not-null constraint INSERT INTO "mm_photograph" ("name","email","age","joined","albums","photos","county_id","city_id") VALUES ('Smith','smi [EMAIL PROTECTED]',NW or i try to add category: n [21]: p.categories.add(kategoria) -- xceptions.ValueErrorTraceback (most recent call last) :\Prace\PRYWATNE\DJANGO_projekty\moremoments\ :\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\fields\related.py in __get__(self, instance, in tance_type) 437 join_table=qn(self.field.m2m_db_table()), 438 source_col_name=qn(self.field.m2m_column_name()), -> 439 target_col_name=qn(self.field.m2m_reverse_name()) 440 ) 441 :\opt\Python24\lib\site-packages\django-0.95-py2.4.egg\django\db\models\fields\related.py in __init__(self, model, core filters, instance, symmetrical, join_table, source_col_name, target_col_name) 276 self._pk_val = self.instance._get_pk_val() 277 if self._pk_val is None: -> 278 raise ValueError("%r instance needs to have a primary key value before a many-to-many relationsh p can be used." % model) 279 280 def get_query_set(self): ValueError: instance needs to have a primary key value before a many-to-many re ationship can be used. So what I'm doing wrong?? Any one help me, please --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
django model question about FileField
Hi all I ve got situation like this, I 'm writing a photograph's gallery where photo should be stored on disk in folders like this \\\ At the moment of creation Photo object I know album that foto belongs to and I know the photographer but I can't to implement path to upload_to option. How to do this? It looks like I should write a method that override a column option but I don't know how. Thans for any help Gregor --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---