Re: Error filtering using bboverlaps
On Wednesday 26 January 2011 05:57:01 B. Heath Robinson wrote: > I am getting the following error when I try a complicated filter with a > join involving bboverlaps. > > Join on field 'shape' not permitted. Did you misspell 'bboverlaps' for > the lookup type? > > > Here is the line that causes the problem. > > saved_properties = > saved_properties.filter(property__parcel__shape__bboxoverlaps=mybbox) > > Is this a legitimate way to use bboverlaps? You didn't posted your models, but does all of those, property and parcel have explicit definition GeoManager as their default manager? -- Jani Tiainen -- 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: Confusion about the new staticfiles contrib app
Op 26-jan-2011, om 06:46 heeft Brian Neal het volgende geschreven: > Hi - > I'm trying to cut over my project to use the new staticfiles > application. I'm using the dev server with DEBUG = True on a recent > SVN trunk checkout. My STATIC_URL is '/static/' and my MEDIA_URL is > 'http://localhost:8000/media/' in this environment. STATIC_URL and MEDIA_URL are two different things. if you want to serve static files that are related to your webdesign/development you should use STATIC. User related files such as uploaded files such be placed inside the MEDIA path. so change STATIC_URL into MEDIA_ROOT='static/'. I always use a fullpath when defining a MEDIA_ROOT or STATIC_ROOT. > > My first confusion point: > Maybe it was just me, but I got confused about serving my media > (MEDIA_ROOT/MEDIA_URL) files with the dev server. After cutting over > to staticfiles, my MEDIA_URL files started getting 404s. Eventually I > came to the conclusion that I had do this: > > urls.py: > if settings.DEBUG: > urlpatterns += patterns('django.contrib.staticfiles.views', > (r'^media/(?P.*)$', 'serve', {'document_root': > settings.MEDIA_ROOT}), > ) -- 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: DB-Views or read-only tables in models
2011/1/25 bvdb > A developer sometimes has to access and present data that existed > before his application. Common practice is for a database > administrator to define a database view (with a CREATE VIEW sql > command, not to be confused with the V in MVC) and give the Django > developer access to this. This is only a read access because in most > cases it is not possible or desireable to allow an UPDATE on a view. > > Now I am new to Django, have some experience with databases - and > couldn't find a "read-only attribute" when defining a model. > Without knowing that a view - that is accessed with the same SELECT > syntax as a table - is read-only Django would for example generate an > admin interface that produces errors, and leave the user wondering > why. > It makes also sense in some cases to define a table read-only for a > model even it is fully accessible by the Django team. > > Is it really not possible to define read-only access in Djangos ORM? > Or maybe I just overlooked the description? Define a model for your db view and set the meta option managed=False http://docs.djangoproject.com/en/dev/ref/models/options/#managed -- Simo - Registered Linux User #395060 - Software is like sex, it is better when it is free --> Linus B. Torvalds -- 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.
Confusion about the new staticfiles contrib app
Hi - I'm trying to cut over my project to use the new staticfiles application. I'm using the dev server with DEBUG = True on a recent SVN trunk checkout. My STATIC_URL is '/static/' and my MEDIA_URL is 'http://localhost:8000/media/' in this environment. My first confusion point: Maybe it was just me, but I got confused about serving my media (MEDIA_ROOT/MEDIA_URL) files with the dev server. After cutting over to staticfiles, my MEDIA_URL files started getting 404s. Eventually I came to the conclusion that I had do this: urls.py: if settings.DEBUG: urlpatterns += patterns('django.contrib.staticfiles.views', (r'^media/(?P.*)$', 'serve', {'document_root': settings.MEDIA_ROOT}), ) The docs don't seem to mention using this view for this purpose. Should they? My second confusion point: I am running the dev server with -Wall and I am seeing warnings: PendingDeprecationWarning: The view at `django.views.static.serve` is deprecated; use the path `django.contrib.staticfiles.views.serve` instead. I don't understand why I'm getting these warnings. My code no longer references django.views.static.serve. I even see this warning when looking at an admin page. Any thoughts on why this is occurring? Thanks. PS After coming to terms with staticfiles, I think it is a great idea. I like being able to separate my apps' static files from user uploaded media files. -- 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: DB-Views or read-only tables in models
Not sure if http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/ will be of some help. See admin.site.disable_action('delete_selected') ; but this is only via the admin app. You could build some logic in the model by overriding the save() method, conditionally, based upon user. So your developers/administrators can have full access but 'normal' users not. -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of bvdb Sent: 25 January 2011 18:20 To: Django users Subject: DB-Views or read-only tables in models A developer sometimes has to access and present data that existed before his application. Common practice is for a database administrator to define a database view (with a CREATE VIEW sql command, not to be confused with the V in MVC) and give the Django developer access to this. This is only a read access because in most cases it is not possible or desireable to allow an UPDATE on a view. Now I am new to Django, have some experience with databases - and couldn't find a "read-only attribute" when defining a model. Without knowing that a view - that is accessed with the same SELECT syntax as a table - is read-only Django would for example generate an admin interface that produces errors, and leave the user wondering why. It makes also sense in some cases to define a table read-only for a model even it is fully accessible by the Django team. Is it really not possible to define read-only access in Djangos ORM? Or maybe I just overlooked the description? -- 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. -- 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 facebook authentication
Hi, Is your request.get_host() the same defined in Facebook app settings? (Web site section if I can recall correctly), facebook doesn't accept 127.0.0.1 as redirect url and might not accept localhost too. Check social_auth/backends/facebook.py on https://github.com/omab/django-social-auth for an example. Regards, Matías Excerpts from CrabbyPete's message of Wed Jan 26 00:39:05 -0200 2011: > I am going nuts this should be simple but I keep getting a > verification error every time in my response in the following code. I > double checked my APP_ID and SECRET I try the following code. I'm > using python2.5. Any help appreciated. > > def login( request ): > > parms = { 'client_id': settings.FACEBOOK_APP_ID, > 'redirect_uri': 'http://' + request.get_host() + > request.get_full_path() > } > > if 'code' in request.GET: > parms['code'] = request.GET['code'] > parms['client_secret'] = settings.FACEBOOK_APP_SECRET > url = 'https://graph.facebook.com/oauth/access_token?' + > urllib.urlencode(parms) > > response = urllib.urlopen(url).read() > pdb.set_trace() > response =cgi.parse_qs(response) > > if 'access_token' in response: > access_token = response['access_token'][0] > graph = GraphAPI( access_token ) > profile = graph.get_object("me") > url = reverse('sites') > url = reverse('sites') > > else: > parms['scope'] = 'email,user_location' > url = "https://graph.facebook.com/oauth/authorize?"; + > urllib.urlencode(parms) > > return HttpResponseRedirect(url) -- Matías Aguirre -- 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.
Error filtering using bboverlaps
I am getting the following error when I try a complicated filter with a join involving bboverlaps. Join on field 'shape' not permitted. Did you misspell 'bboverlaps' for the lookup type? Here is the line that causes the problem. saved_properties = saved_properties.filter(property__parcel__shape__bboxoverlaps=mybbox) Is this a legitimate way to use bboverlaps? -- 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: DB-Views or read-only tables in models
Perhaps you could override the save method and make it like this: def save(self,*args,**kwargs): pass Would that work? This is also a curiosity I have, but didn't have a chance to test it. Any thoughts? George On Wed, Jan 26, 2011 at 12:22 AM, Russell Keith-Magee < russ...@keith-magee.com> wrote: > On Wed, Jan 26, 2011 at 12:19 AM, bvdb wrote: > > A developer sometimes has to access and present data that existed > > before his application. Common practice is for a database > > administrator to define a database view (with a CREATE VIEW sql > > command, not to be confused with the V in MVC) and give the Django > > developer access to this. This is only a read access because in most > > cases it is not possible or desireable to allow an UPDATE on a view. > > > > Now I am new to Django, have some experience with databases - and > > couldn't find a "read-only attribute" when defining a model. > > Without knowing that a view - that is accessed with the same SELECT > > syntax as a table - is read-only Django would for example generate an > > admin interface that produces errors, and leave the user wondering > > why. > > It makes also sense in some cases to define a table read-only for a > > model even it is fully accessible by the Django team. > > > > Is it really not possible to define read-only access in Djangos ORM? > > Or maybe I just overlooked the description? > > Essentially the answer is no. > > Django doesn't have a built-in representation of a view. You can't > define a view in the same way that you would define a model, for > example. This has long been on my 'things I want to look at' list, but > I've never got around to it. > > You can define a Django model as a wrapper around a view by marking it > managed, but that doesn't make the model read-only -- it just prevents > Django from trying to create the model during syncdb. > > From the perspective of the admin, you can define a field to be > readonly, but that's purely a data display level concern, and is > controlled on a per-field basis. With a bit of effort your could make > an admin view that is effectively readonly, but there isn't a simple > single switch to do this. > > Another approach is to use the databrowse app; that's purely a > readonly display. It's not as mature or pretty as the admin, but it > exists, and you might be able to use it. > > Yours, > Russ Magee %-) > > -- > 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. > > -- George R. C. Silva Desenvolvimento em GIS http://blog.geoprocessamento.net -- 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 facebook authentication
I am going nuts this should be simple but I keep getting a verification error every time in my response in the following code. I double checked my APP_ID and SECRET I try the following code. I'm using python2.5. Any help appreciated. def login( request ): parms = { 'client_id': settings.FACEBOOK_APP_ID, 'redirect_uri': 'http://' + request.get_host() + request.get_full_path() } if 'code' in request.GET: parms['code'] = request.GET['code'] parms['client_secret'] = settings.FACEBOOK_APP_SECRET url = 'https://graph.facebook.com/oauth/access_token?' + urllib.urlencode(parms) response = urllib.urlopen(url).read() pdb.set_trace() response =cgi.parse_qs(response) if 'access_token' in response: access_token = response['access_token'][0] graph = GraphAPI( access_token ) profile = graph.get_object("me") url = reverse('sites') url = reverse('sites') else: parms['scope'] = 'email,user_location' url = "https://graph.facebook.com/oauth/authorize?"; + urllib.urlencode(parms) return HttpResponseRedirect(url) -- 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: DB-Views or read-only tables in models
On Wed, Jan 26, 2011 at 12:19 AM, bvdb wrote: > A developer sometimes has to access and present data that existed > before his application. Common practice is for a database > administrator to define a database view (with a CREATE VIEW sql > command, not to be confused with the V in MVC) and give the Django > developer access to this. This is only a read access because in most > cases it is not possible or desireable to allow an UPDATE on a view. > > Now I am new to Django, have some experience with databases - and > couldn't find a "read-only attribute" when defining a model. > Without knowing that a view - that is accessed with the same SELECT > syntax as a table - is read-only Django would for example generate an > admin interface that produces errors, and leave the user wondering > why. > It makes also sense in some cases to define a table read-only for a > model even it is fully accessible by the Django team. > > Is it really not possible to define read-only access in Djangos ORM? > Or maybe I just overlooked the description? Essentially the answer is no. Django doesn't have a built-in representation of a view. You can't define a view in the same way that you would define a model, for example. This has long been on my 'things I want to look at' list, but I've never got around to it. You can define a Django model as a wrapper around a view by marking it managed, but that doesn't make the model read-only -- it just prevents Django from trying to create the model during syncdb. >From the perspective of the admin, you can define a field to be readonly, but that's purely a data display level concern, and is controlled on a per-field basis. With a bit of effort your could make an admin view that is effectively readonly, but there isn't a simple single switch to do this. Another approach is to use the databrowse app; that's purely a readonly display. It's not as mature or pretty as the admin, but it exists, and you might be able to use it. Yours, Russ Magee %-) -- 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.
Advanced search view in admin site.
I known that in admin.py I can put in search_fields with parameters I want for search. This works fine. But I want another View just like advanced search in google. There are boxes for me to specific each field. Like I can choose a date etc. And I can give a range for my numeral fields. Or even do ip address wild casting. Please give me some hint on how to do this. 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Can I store full dates (mmddyyyy) and year-only dates (yyyy) in the same field?
I had this need some time ago. You can check the answers of my question on stackoverflow for different avenues: http://stackoverflow.com/questions/2971198/how-to-deal-with-partial-dates-2010-00-00-from-mysql-in-django Etienne On Jan 25, 7:22 pm, David wrote: > Malcolm Tredinnick gave a talk at Djangocon last year that touched on > this. He used a similar approach to Tim. Essentially he had a model > that had a DateField and a precision. > > Malcolm has his slides > up:https://github.com/malcolmt/django-modeling-examples/blob/master/slid... > > On Jan 25, 9:16 am, "Tim Sawyer" wrote: > > > Hi Karen, > > > I did with two fields - storing a date and a date resolution. > > > The values could be: > > > date / resolution - display value > > > 1984-12-31 / Exact Date - 31st December 1984 > > 1984-12-01 / Month - December 1984 > > 1984-01-01 / Year - 1984 > > > So I just used the first of the month where unknown, and January where > > unknown. > > > I then had a method on the model object to return the format based on the > > stored date and the resolution. > > > It worked for what I needed it for, > > > Tim. > > > > Hello, > > > > I'm designing a model which is a collection of texts. Some of the > > > texts will be things like books, with a date of publication, and > > > some of them will be articles or transcripts with a mmddyyy date of > > > publication/broadcast. > > > > I'd like to structure it somehow so that when I view the list of texts > > > in the admin site, I see something like this: > > > > Title Date ...other > > > fields > > > --- > > > --- > > > Sample Book 1984 ... > > > Sample Blog Post 1/14/2010 ... > > > > Can I (should I?) store these two kinds of dates in one field? If I > > > can't (or shouldn't), is there some other way to accomplish this > > > (that's not too complicated)? > > > > Thanks, > > > 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. -- 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 form(s) for intermediary models
> In your case it would become something like: > > class Membership(ModelForm): > class Meta: > model = Membership > fields = ('person', 'date_joined') > widgets = { > 'person' : CheckBox(), > 'date_joined': TextInput(), > } I need a form for each person though because a Group could have many members. -- 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: Forbidden (403) CSRF verification failed. Request aborted.
Hey, I've also struggled with CSRF for a while. Maybe I can give you some guidance. > you need to ensure: > > •The view function uses RequestContext for the template, instead of > Context. > •In the template, there is a {% csrf_token %} template tag inside each > POST form that targets an internal URL. > •If you are not using CsrfViewMiddleware, then you must use > csrf_protect on any views that use the csrf_token template tag, as > well as those that accept the POST data. > You're seeing the help section of this page because you have DEBUG = > True in your Django settings file. Change that to False, and only the > initial error message will be displayed. > Have you checked each item mentioned by the error report ? > > Add {% crsf_token %} directly after the opening form tag. > >return render_to_response('polls/uploadfile.html', {'form': > form}) > You must always a ContextRequest like this: from django.template import RequestContext return render_to_response('polls/uploadfile.html', {'form':form}, context_instance=RequestContext(your_request_var)) If you are still stuck I can advise you to read the following article: http://andrew.io/weblog/2010/01/django-piston-and-handling-csrf-tokens Good luck! -- 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: MySQL behavior about Warning/Exception
Am Dienstag, 25. Januar 2011, 19:48:48 schrieb etienned: > I would like to understand how Warning/Exception are treated in the > MySQL backend because I have a weird bug. > > When I run the test suite of django-reversion on my production server > (Ubuntu 10.04) one test fail because MySQL give a warning instead of > an exception. If I run the same test on my testing server (again > Ubuntu 10.04 but in VirtualBox, so it's mostly the same software) > MySQL give the exception so the test didn't fail. I tried on both > server with DEBUG = True and DEBUG = False with the same result. > > For more info you could check here: > https://github.com/etianen/django-reversion/issues/closed#issue/18/comment/ > 566932 > > Anyone have an idea on this bug or, at least, explain how Warning/ > Exception are treated in the MySQL backend? Hello, the behaviour depends on the "non-strict" setting of the MySQL server. If i remember correctly in non-strict mode an error will be raised. You should compare the server configs of both machines. Best Regards, Dirk Eschler -- Dirk Eschler -- 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 form(s) for intermediary models
> In that form, I'd > like to see a checkbox for each Person (member) and a text field for > 'date_joined'. Anyway to do this? You can create forms from models. See this page for more information: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ You can always override the default widgets. In your case it would become something like: class Membership(ModelForm): class Meta: model = Membership fields = ('person', 'date_joined') widgets = { 'person' : CheckBox(), 'date_joined': TextInput(), } -- 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 form(s) for intermediary models
I have three models like so: class Person(models.Model): name = models.CharField(max_length=128) class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') class Membership(models.Model): person = models.ForeignKey(Person) group = models.ForeignKey(Group) date_joined = models.DateField() I already have the Person and Group tables populated. I'm now trying to add members to each Group and would like to create a form that gives me the option to create a Membership as well. In that form, I'd like to see a checkbox for each Person (member) and a text field for 'date_joined'. Anyway to do this? Any help would be greatly appreciated. -- 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.
Forbidden (403) CSRF verification failed. Request aborted.
I'm trying to write the code and implement a file upload screen based on this document: http://docs.djangoproject.com/en/1.2/topics/http/file-uploads I'm getting the following error: Forbidden (403) CSRF verification failed. Request aborted. Help Reason given for failure: CSRF token missing or incorrect. In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django's CSRF mechanism has not been used correctly. For POST forms, you need to ensure: •The view function uses RequestContext for the template, instead of Context. •In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL. •If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data. You're seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed. You can customize this page using the CSRF_FAILURE_VIEW setting. I have tried coding the csrf token ({% csrf_token %}) on my new screen as well as leaving it off and its presence does not seem to matter, at least by itself, because I get the same error whether its present or not. My screen so far is coded like this: POLL APPLICATION FILE UPLOAD SCREEN {{ form.title }} {{ form.filename.label }} {{ form.filename }} {{ form.filename.errors }} {{ mainmenutext }} and though I've defined and added the form.title field to the screen the document does not seem to mention what it's supposed to be for or how its used, though it shows it coded in the upload form. My view code for this screen looks like this: def process_uploaded_file(file): #destination = open('C:/users/hversemann/desktop/testfile.txt', 'wb +') destination = open('C:/users/hversemann/desktop/testfile.txt', 'w') for chunk in file.chunks(): destination.write(chunk) destination.close() def uploadfile(request): mainmenuurl = "/polls/mainmenu/" mainmenutext = "Main Menu" if request.method == 'POST': form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): process_uploaded_file(request.FILES['file']) confirmmessage = "File has been uploaded!" dctnry = { 'confirmmessage': confirmmessage, 'mainmenuurl': mainmenuurl, 'mainmenutext': mainmenutext } return render_to_response('polls/confirm.html', dctnry, context_instance=RequestContext(request)) else: dctnry = { 'form': form, 'mainmenuurl': mainmenuurl, 'mainmenutext': mainmenutext } return render_to_response('polls/uploadfile.html', dctnry, context_instance=RequestContext(request)) else: form = UploadFileForm() dctnry = { 'form': form, 'mainmenuurl': mainmenuurl, 'mainmenutext': mainmenutext } return render_to_response('polls/uploadfile.html', {'form': form}) I've coded as much of of this as possible from right out of the document. So I'm not sure based on the error exactly where the problem may be. Thanks in advance for the help. -- 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 am I doing wrong?
On Tuesday, January 25, 2011 5:41:35 PM UTC, MikeKJ wrote: > > > class CertForm(forms.Form): > agree = forms.BooleanField(required=True, label="I confirm the above > and > agree.") > cert = forms.BooleanField(required=False, label="I require a > certificate") > > class UserAccountForm(ModelForm): > class Meta: > model = UserAccount > > class VideoAccountForm(ModelForm): > class Meta: > model = VideoAccount > > def certificate(request, id): > if not request.user.is_authenticated(): > return HttpResponseRedirect('/user/login/') > person = request.user > check = UserProfile.objects.get(username=person) > if check.approved_member and check.gp: > part_vid = Part.objects.get(pk = id) > cost = round((part_vid.runtime/60)*10,2) > if request.POST: > form = CertForm(request.POST) > userform = UserAccountForm() > videoform = VideoAccountForm() > if form.is_valid(): > //normal form.cleaned_data stuff > // userform > data = {'user_id': 'check.id', > 'user_name': 'check.name', > 'user_email': 'check.email', > 'video_id': 'part_vid.id', > 'video_name': 'part_vid.title', > 'video_time': 'part_vid.runtime', > 'video_cost': 'cost' >} > userform.save(data) > // videodata > vdata = {'video_id': 'part_vid.id', > 'video_name': 'part_vid.title', > 'video_time': 'part_vid.runtime', > 'video_cost': 'cost', > 'lecturer_id': 'k', > 'lecturer_name': 'lecturer_name' > } > videoform.save(vdata) > > return HttpResponseRedirect(reverse('video.views.play_vid', > args=(cat_id, this_vid_id,))) > else: > form = CertForm(request.POST) > > all the stuff in data and vdata is derived from query sets prior to the > form > > Q > 1 Why am I getting "'UserAccountForm' object has no attribute > 'cleaned_data'" > 2 If I use if userform.is_valid() then userform is invalid in any case > 3 Just save the data given to another model 'Accounts' is all I want it to > do but it has to be done in here as this is where the agree is done > What is the point of UserAccountForm and VideoAccountForm? If you just want to create accounts in your view, why not just do so? As far as I can tell, those forms are simply being instantiated with no data. You are then trying to call `save()` on them, passing data - I've no idea why you think this will work. In any case, until you call is_valid() on them, they have no cleaned_data attribute, which is the immediate source of your error - but they won't be valid even if you do, because you haven't passed them any data. Some clearer explanation of what you're intending to do, and what those forms are for, would be helpful. -- 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.
Re: what am I doing wrong?
Is there a reason why you inherit from forms.Form, but not forms.ModelForm ? Is it successfully finding ModelForm without the reference to forms? -Rob On Tue, Jan 25, 2011 at 12:41 PM, MikeKJ wrote: > > class CertForm(forms.Form): >agree = forms.BooleanField(required=True, label="I confirm the above and > agree.") >cert = forms.BooleanField(required=False, label="I require a > certificate") > > class UserAccountForm(ModelForm): >class Meta: >model = UserAccount > > class VideoAccountForm(ModelForm): >class Meta: >model = VideoAccount > > def certificate(request, id): >if not request.user.is_authenticated(): >return HttpResponseRedirect('/user/login/') >person = request.user >check = UserProfile.objects.get(username=person) >if check.approved_member and check.gp: >part_vid = Part.objects.get(pk = id) >cost = round((part_vid.runtime/60)*10,2) >if request.POST: >form = CertForm(request.POST) >userform = UserAccountForm() >videoform = VideoAccountForm() >if form.is_valid(): >//normal form.cleaned_data stuff >// userform > data = {'user_id': 'check.id', >'user_name': 'check.name', >'user_email': 'check.email', >'video_id': 'part_vid.id', >'video_name': 'part_vid.title', >'video_time': 'part_vid.runtime', >'video_cost': 'cost' > } >userform.save(data) >// videodata >vdata = {'video_id': 'part_vid.id', > 'video_name': 'part_vid.title', > 'video_time': 'part_vid.runtime', > 'video_cost': 'cost', > 'lecturer_id': 'k', > 'lecturer_name': 'lecturer_name' >} >videoform.save(vdata) > >return HttpResponseRedirect(reverse('video.views.play_vid', > args=(cat_id, this_vid_id,))) >else: >form = CertForm(request.POST) > > all the stuff in data and vdata is derived from query sets prior to the > form > > Q > 1 Why am I getting "'UserAccountForm' object has no attribute > 'cleaned_data'" > 2 If I use if userform.is_valid() then userform is invalid in any case > 3 Just save the data given to another model 'Accounts' is all I want it to > do but it has to be done in here as this is where the agree is done > -- > View this message in context: > http://old.nabble.com/what-am-I-doing-wrong--tp30760259p30760259.html > Sent from the django-users mailing list archive at Nabble.com. > > -- > 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. > > -- Robert McQueen Massachusetts Institute of Technology Class of 2012, Course 6.3 - Computer Science rmcqu...@mit.edu -- 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: Can I store full dates (mmddyyyy) and year-only dates (yyyy) in the same field?
Malcolm Tredinnick gave a talk at Djangocon last year that touched on this. He used a similar approach to Tim. Essentially he had a model that had a DateField and a precision. Malcolm has his slides up: https://github.com/malcolmt/django-modeling-examples/blob/master/slides/modeling-challenges.pdf On Jan 25, 9:16 am, "Tim Sawyer" wrote: > Hi Karen, > > I did with two fields - storing a date and a date resolution. > > The values could be: > > date / resolution - display value > > 1984-12-31 / Exact Date - 31st December 1984 > 1984-12-01 / Month - December 1984 > 1984-01-01 / Year - 1984 > > So I just used the first of the month where unknown, and January where > unknown. > > I then had a method on the model object to return the format based on the > stored date and the resolution. > > It worked for what I needed it for, > > Tim. > > > > > > > > > Hello, > > > I'm designing a model which is a collection of texts. Some of the > > texts will be things like books, with a date of publication, and > > some of them will be articles or transcripts with a mmddyyy date of > > publication/broadcast. > > > I'd like to structure it somehow so that when I view the list of texts > > in the admin site, I see something like this: > > > Title Date ...other > > fields > > --- > > --- > > Sample Book 1984 ... > > Sample Blog Post 1/14/2010 ... > > > Can I (should I?) store these two kinds of dates in one field? If I > > can't (or shouldn't), is there some other way to accomplish this > > (that's not too complicated)? > > > Thanks, > > 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. -- 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.
MySQL behavior about Warning/Exception
I would like to understand how Warning/Exception are treated in the MySQL backend because I have a weird bug. When I run the test suite of django-reversion on my production server (Ubuntu 10.04) one test fail because MySQL give a warning instead of an exception. If I run the same test on my testing server (again Ubuntu 10.04 but in VirtualBox, so it's mostly the same software) MySQL give the exception so the test didn't fail. I tried on both server with DEBUG = True and DEBUG = False with the same result. For more info you could check here: https://github.com/etianen/django-reversion/issues/closed#issue/18/comment/566932 Anyone have an idea on this bug or, at least, explain how Warning/ Exception are treated in the MySQL backend? 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Constants in model, that point to certain objects in database
> The descriptor protocol is the mechanism that allows both property and > method: > http://docs.python.org/reference/datamodel.html#implementing-descriptors > http://users.rcn.com/python/download/Descriptor.htm > > In your case, something like the following could do: This looks awesome. I had no idea before, that such thing is possible. Cool to know a new thing :-) isinstance(Foo, type) > False > > But anyway... Yeah, for old style classes it's not true, but for the new style it is: In [18]: class Foo(object): pass : In [19]: isinstance(Foo, type) Out[19]: True -- Filip Gruszczyński -- 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.
Login view takes very long to load
I am running Django with uwsgi and Cherokee, the pages load fine, even those with database access. As you can see, they usually render with like 100 msec but when I go to the Login view which is provided by Django, It takes 10 seconds an more to load. I have only one uwsgi process and I am using sqlite. But I will switch to mysql because of concurrency. Still I am wondering what this is. It is not happening on my dev machine with runserver. I suppose it is some kind of lock on the DB? uwsgi output: [pid: 2599|app: 0|req: 15/15] IP_ADDRESS () {60 vars in 1447 bytes} [Tue Jan 25 18:39:32 2011] GET /accounts/login/ => generated 39240 bytes in 12896 msecs (HTTP/1.1 200) 9 headers in 469 bytes (0 async switches on async core 0) [pid: 2599|app: 0|req: 16/16] IP_ADDRESS () {56 vars in 1336 bytes} [Tue Jan 25 18:40:03 2011] GET /pages/about_us/ => generated 43730 bytes in 72 msecs (HTTP/1.1 200) 4 headers in 195 bytes (0 async switches on async core 0) [pid: 2599|app: 0|req: 17/17] IP_ADDRESS () {60 vars in 1447 bytes} [Tue Jan 25 18:40:05 2011] GET /accounts/login/ => generated 39240 bytes in 10472 msecs (HTTP/1.1 200) 9 headers in 469 bytes (0 async switches on async core 0) [pid: 2599|app: 0|req: 18/18] IP_ADDRESS () {60 vars in 1447 bytes} [Tue Jan 25 18:40:29 2011] GET /accounts/login/ => generated 39240 bytes in 15092 msecs (HTTP/1.1 200) 9 headers in 469 bytes (0 async switches on async core 0) [pid: 2599|app: 0|req: 19/19] 85.179.70.75 () {56 vars in 1336 bytes} [Tue Jan 25 18:43:22 2011] GET /courses/summer/ => generated 44054 bytes in 104 msecs (HTTP/1.1 200) 4 headers in 195 bytes (0 async switches on async core 0) -- 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: Getting hold of an instance of a model from inside RelatedManager
It's ok by me to return something generic or even raise an exception if I'm calling directly using RelatedStuff.objects.my_method(). Is it possible for my_method to access MainStuff instance or at least find out which way it is accessed? Imagine I got a instance of MainStuff like this... main = MainStuff.objects.get(id=1) When I later call main.relatedstuff_set.my_method() I need "my_method" to have access to "main" to do some additional filtering and crunching depending on some of the fields in "main". One other resort I possibly could do is some custom field instead, almost like the reverse generic relation using generic.GenericRelation. That would probably be a better pythonic/djangonic way of doing it but fixing that would probably mean more codeing and less progress for me. -- 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 am I doing wrong?
class CertForm(forms.Form): agree = forms.BooleanField(required=True, label="I confirm the above and agree.") cert = forms.BooleanField(required=False, label="I require a certificate") class UserAccountForm(ModelForm): class Meta: model = UserAccount class VideoAccountForm(ModelForm): class Meta: model = VideoAccount def certificate(request, id): if not request.user.is_authenticated(): return HttpResponseRedirect('/user/login/') person = request.user check = UserProfile.objects.get(username=person) if check.approved_member and check.gp: part_vid = Part.objects.get(pk = id) cost = round((part_vid.runtime/60)*10,2) if request.POST: form = CertForm(request.POST) userform = UserAccountForm() videoform = VideoAccountForm() if form.is_valid(): //normal form.cleaned_data stuff // userform data = {'user_id': 'check.id', 'user_name': 'check.name', 'user_email': 'check.email', 'video_id': 'part_vid.id', 'video_name': 'part_vid.title', 'video_time': 'part_vid.runtime', 'video_cost': 'cost' } userform.save(data) // videodata vdata = {'video_id': 'part_vid.id', 'video_name': 'part_vid.title', 'video_time': 'part_vid.runtime', 'video_cost': 'cost', 'lecturer_id': 'k', 'lecturer_name': 'lecturer_name' } videoform.save(vdata) return HttpResponseRedirect(reverse('video.views.play_vid', args=(cat_id, this_vid_id,))) else: form = CertForm(request.POST) all the stuff in data and vdata is derived from query sets prior to the form Q 1 Why am I getting "'UserAccountForm' object has no attribute 'cleaned_data'" 2 If I use if userform.is_valid() then userform is invalid in any case 3 Just save the data given to another model 'Accounts' is all I want it to do but it has to be done in here as this is where the agree is done -- View this message in context: http://old.nabble.com/what-am-I-doing-wrong--tp30760259p30760259.html Sent from the django-users mailing list archive at Nabble.com. -- 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: Can I store full dates (mmddyyyy) and year-only dates (yyyy) in the same field?
Hi Karen, I did with two fields - storing a date and a date resolution. The values could be: date / resolution - display value 1984-12-31 / Exact Date - 31st December 1984 1984-12-01 / Month - December 1984 1984-01-01 / Year - 1984 So I just used the first of the month where unknown, and January where unknown. I then had a method on the model object to return the format based on the stored date and the resolution. It worked for what I needed it for, Tim. > Hello, > > I'm designing a model which is a collection of texts. Some of the > texts will be things like books, with a date of publication, and > some of them will be articles or transcripts with a mmddyyy date of > publication/broadcast. > > I'd like to structure it somehow so that when I view the list of texts > in the admin site, I see something like this: > > > TitleDate ...other > fields > -- > Sample Book 1984 ... > Sample Blog Post 1/14/2010 ... > > > Can I (should I?) store these two kinds of dates in one field? If I > can't (or shouldn't), is there some other way to accomplish this > (that's not too complicated)? > > Thanks, > 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. > > -- 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: [OT]Code Review As a Service
On Tue, Jan 25, 2011 at 7:03 AM, Daniel Roseman wrote: > On Tuesday, January 25, 2011 9:42:59 AM UTC, Venkatraman.S. wrote: >> >> Hi, >> >> I was wondering whether there any freelancers/companies who offer >> code-review as a service. >> IMHO, a code review helps in almost all occasions, but the faced paced >> life seems to have >> put this in the back burner. >> >> Would like your code to be reviewed? If yes, what would be the ideal per >> hour rates that >> would not hurt your wallet? >> >> -Venkat >> http://blizzardzblogs.blogspot.com/ > > Are you asking, or offering? I've done a few successful code reviews for > people on this group and elsewhere. If you're interested, contact me > off-list to discuss rates/times. > -- > Daniel. > I'm one of those who used Daniel for a code review and I was extremely grateful for his help. -- 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.
syncdb fails when creating super user - Django: v 1.2.4 Python: 2.6 MySQL Server: 5.5 Windows 7 Extra: MySQL-Python v1.2.3
What steps will reproduce the problem? 1. install the above programs 2. create a project 3. run syncdb Note: I have installed mySQL to support UTF 8. I also create the mysite_db database using CREATE DTABASE mysite_db CHARACTER SET = UTF8; What is the expected output? What do you see instead? syncdb create the required tables as follows: - C:\DjangoProjects\mysite>python manage.py syncdb Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_user_permissions Creating table auth_user_groups Creating table auth_user Creating table auth_message Creating table django_content_type Creating table django_session Creating table django_site You just installed Django's auth system, which means you don't have any superuse rs defined. Would you like to create one now? (yes/no): - I select 'YES' and get the following error: - Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "C:\Python26\lib\site-packages\django\core\management \__init__.py", line 438, in execute_manager utility.execute() File "C:\Python26\lib\site-packages\django\core\management \__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python26\lib\site-packages\django\core\management\base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "C:\Python26\lib\site-packages\django\core\management\base.py", line 220, in execute output = self.handle(*args, **options) File "C:\Python26\lib\site-packages\django\core\management\base.py", line 351, in handle return self.handle_noargs(**options) File "C:\Python26\lib\site-packages\django\core\management\commands \syncdb.py" , line 103, in handle_noargs emit_post_sync_signal(created_models, verbosity, interactive, db) File "C:\Python26\lib\site-packages\django\core\management\sql.py", line 182, in emit_post_sync_signal interactive=interactive, db=db) File "C:\Python26\lib\site-packages\django\dispatch\dispatcher.py", line 172, in send response = receiver(signal=self, sender=sender, **named) File "C:\Python26\lib\site-packages\django\contrib\auth\management \__init__.py ", line 44, in create_superuser call_command("createsuperuser", interactive=True) File "C:\Python26\lib\site-packages\django\core\management \__init__.py", line 166, in call_command return klass.execute(*args, **defaults) File "C:\Python26\lib\site-packages\django\core\management\base.py", line 220, in execute output = self.handle(*args, **options) File "C:\Python26\lib\site-packages\django\contrib\auth\management \commands\cr eatesuperuser.py", line 71, in handle User.objects.get(username=default_username) File "C:\Python26\lib\site-packages\django\db\models\manager.py", line 132, in get return self.get_query_set().get(*args, **kwargs) File "C:\Python26\lib\site-packages\django\db\models\query.py", line 342, in g et num = len(clone) File "C:\Python26\lib\site-packages\django\db\models\query.py", line 80, in __ len__ self._result_cache = list(self.iterator()) File "C:\Python26\lib\site-packages\django\db\models\query.py", line 271, in i terator for row in compiler.results_iter(): File "C:\Python26\lib\site-packages\django\db\models\sql \compiler.py", line 67 7, in results_iter for rows in self.execute_sql(MULTI): File "C:\Python26\lib\site-packages\django\db\models\sql \compiler.py", line 73 2, in execute_sql cursor.execute(sql, params) File "C:\Python26\lib\site-packages\django\db\backends\util.py", line 15, in e xecute return self.cursor.execute(sql, params) File "C:\Python26\lib\site-packages\django\db\backends\mysql \base.py", line 86 , in execute return self.cursor.execute(query, args) File "C:\Python26\lib\site-packages\MySQLdb\cursors.py", line 175, in execute if not self._defer_warnings: self._warning_check() File "C:\Python26\lib\site-packages\MySQLdb\cursors.py", line 89, in _warning_ check warn(w[-1], self.Warning, 3) _mysql_exceptions.Warning: Incorrect string value: '\xED' for column 'username' at row 1 - What version of the product are you using? On what operating system? Django: v 1.2.4 Python: 2.6 MySQL Server: 5.5 Windows 7 Extra: MySQL- Python v1.2.3 Please provide any additional information below. I also have mySQL C++ and ODBC database connectors installed. Any help is greatly appreciated. -- You received this message because you are subs
Re: Getting hold of an instance of a model from inside RelatedManager
On Tue, Jan 25, 2011 at 3:34 PM, kmpm wrote: > I have some issues with getting hold of the instance of a Model to which a > RelatedManager got contributed to. > Is that at all possible and if so, how? > From my_method below I can get hold of the model RelatedStuff by calling > self.model but that really doesn't get me there. > class MainStuff(models.Model): > > > class RelatedStuff(models.Model): > ... > main = models.ForeignKey(MainStuff) > objects = CustomManager() > class CustomManager(models.Manager): > use_for_related_fields=True > > def my_method(self): > #here I would like to access the instance of MainStuff to which this > got contributed > What model instance? I think you are discounting the fact that CustomManager instances may be called without a related model instance. RelatedStuff.objects is an instance of CustomManager, so RelatedStuff.objects.my_method() is a valid method call, but what model instance do you think is relevant there? Cheers Tom -- 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.
DB-Views or read-only tables in models
A developer sometimes has to access and present data that existed before his application. Common practice is for a database administrator to define a database view (with a CREATE VIEW sql command, not to be confused with the V in MVC) and give the Django developer access to this. This is only a read access because in most cases it is not possible or desireable to allow an UPDATE on a view. Now I am new to Django, have some experience with databases - and couldn't find a "read-only attribute" when defining a model. Without knowing that a view - that is accessed with the same SELECT syntax as a table - is read-only Django would for example generate an admin interface that produces errors, and leave the user wondering why. It makes also sense in some cases to define a table read-only for a model even it is fully accessible by the Django team. Is it really not possible to define read-only access in Djangos ORM? Or maybe I just overlooked the description? -- 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.
Can I store full dates (mmddyyyy) and year-only dates (yyyy) in the same field?
Hello, I'm designing a model which is a collection of texts. Some of the texts will be things like books, with a date of publication, and some of them will be articles or transcripts with a mmddyyy date of publication/broadcast. I'd like to structure it somehow so that when I view the list of texts in the admin site, I see something like this: TitleDate ...other fields -- Sample Book 1984 ... Sample Blog Post 1/14/2010 ... Can I (should I?) store these two kinds of dates in one field? If I can't (or shouldn't), is there some other way to accomplish this (that's not too complicated)? Thanks, 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.
Re: copying sqlite database file between projects
That solved the syncdb error, but I'm still getting the same error inside the shell when I am trying get to the data. Progress! Thanks again! On 25/01/11 16:36, Michael wrote: I believe table names are all lower-case, so try 'sample_app_person' -- 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: copying sqlite database file between projects
I believe table names are all lower-case, so try 'sample_app_person' -- Michael On Tue, 2011-01-25 at 08:33 -0800, Ben Dembroski wrote: > Attempting to add the db_table name to the model made things a bit > more confusing. > > The original app's name was 'sample_app' (not my choosing) > > The app that I'm trying to get to access the data is 'trajectories' > > > > I just added the following the Meta class for one of the models: > > > class Meta: > db_table = 'sample_app_Person' > > and got the following when I ran syncdb: > Traceback (most recent call last): > File "manage.py", line 11, in > execute_manager(settings) > File "/usr/local/lib/python2.6/dist-packages/django/core/management/ > __init__.py", line 438, in execute_manager > utility.execute() > File "/usr/local/lib/python2.6/dist-packages/django/core/management/ > __init__.py", line 379, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File "/usr/local/lib/python2.6/dist-packages/django/core/management/ > base.py", line 191, in run_from_argv > self.execute(*args, **options.__dict__) > File "/usr/local/lib/python2.6/dist-packages/django/core/management/ > base.py", line 220, in execute > output = self.handle(*args, **options) > File "/usr/local/lib/python2.6/dist-packages/django/core/management/ > base.py", line 351, in handle > return self.handle_noargs(**options) > File "/usr/local/lib/python2.6/dist-packages/django/core/management/ > commands/syncdb.py", line 95, in handle_noargs > cursor.execute(statement) > File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ > util.py", line 15, in execute > return self.cursor.execute(sql, params) > File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ > sqlite3/base.py", line 200, in execute > return Database.Cursor.execute(self, query, params) > django.db.utils.DatabaseError: table "sample_app_Person" already > exists > > If I run the shell, and try to get to the data, I get this: > > (InteractiveConsole) > >>> from trajectories.models import Person > >>> Person.objects.all() > Traceback (most recent call last): > File "", line 1, in > File "/usr/local/lib/python2.6/dist-packages/django/db/models/ > query.py", line 67, in __repr__ > data = list(self[:REPR_OUTPUT_SIZE + 1]) > File "/usr/local/lib/python2.6/dist-packages/django/db/models/ > query.py", line 82, in __len__ > self._result_cache.extend(list(self._iter)) > File "/usr/local/lib/python2.6/dist-packages/django/db/models/ > query.py", line 271, in iterator > for row in compiler.results_iter(): > File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/ > compiler.py", line 677, in results_iter > for rows in self.execute_sql(MULTI): > File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/ > compiler.py", line 732, in execute_sql > cursor.execute(sql, params) > File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ > util.py", line 15, in execute > return self.cursor.execute(sql, params) > File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ > sqlite3/base.py", line 200, in execute > return Database.Cursor.execute(self, query, params) > DatabaseError: no such column: sample_app_Person.dobestm > > Any ideas ? > > Thanks again! > > On Jan 25, 4:02 pm, Ben Dembroski wrote: > > Thanks. > > > > I suspect this is the issue, as I just changed the settings.py file on > > the original project to point to the copied database file. It has no > > problem accessing the data. I'll play around with the meta settings > > and see what I can come up with. > > > > Thanks! > > > > On Jan 25, 3:46 pm, Michael wrote: > > > > > > > > > > > > > > > > > The database tables are named {{app_label}}_{{model_name}}, so in order > > > to use the same database you will need to use the same application name > > > (or specify db_table in the model's Meta). > > > > > -- > > > Michael > > > > > On Tue, 2011-01-25 at 07:36 -0800, Ben Dembroski wrote: > > > > Hi all, > > > > > > Afraid I've got another newbie question. I've been doing some > > > > development on a project using sqlite3. All is working well, and I'd > > > > like to use the same database file in another project, data intact. > > > > I've copied the database file, and the models.py file to the > > > > appropriate locations in the new project. When I run syncdb, the > > > > only result is 'no fixtures found.' > > > > > > When I pop into the shell, all the fields are there, but I can't get > > > > to the data in any of them. > > > > > > For instance, inside the shell for the new project I run: > > > > > > Person.objects.all() > > > > > > it returns > > > > > > [] > > > > > > Do I need to do something besides just copying the database file to > > > > keep my data, provided the models.py files are unchanged? > > > > > > Many thanks, > > > > Ben > -- You received this message because you are subscribed t
Re: copying sqlite database file between projects
Attempting to add the db_table name to the model made things a bit more confusing. The original app's name was 'sample_app' (not my choosing) The app that I'm trying to get to access the data is 'trajectories' I just added the following the Meta class for one of the models: class Meta: db_table = 'sample_app_Person' and got the following when I ran syncdb: Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ __init__.py", line 438, in execute_manager utility.execute() File "/usr/local/lib/python2.6/dist-packages/django/core/management/ __init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ base.py", line 220, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ base.py", line 351, in handle return self.handle_noargs(**options) File "/usr/local/lib/python2.6/dist-packages/django/core/management/ commands/syncdb.py", line 95, in handle_noargs cursor.execute(statement) File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ util.py", line 15, in execute return self.cursor.execute(sql, params) File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ sqlite3/base.py", line 200, in execute return Database.Cursor.execute(self, query, params) django.db.utils.DatabaseError: table "sample_app_Person" already exists If I run the shell, and try to get to the data, I get this: (InteractiveConsole) >>> from trajectories.models import Person >>> Person.objects.all() Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.6/dist-packages/django/db/models/ query.py", line 67, in __repr__ data = list(self[:REPR_OUTPUT_SIZE + 1]) File "/usr/local/lib/python2.6/dist-packages/django/db/models/ query.py", line 82, in __len__ self._result_cache.extend(list(self._iter)) File "/usr/local/lib/python2.6/dist-packages/django/db/models/ query.py", line 271, in iterator for row in compiler.results_iter(): File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/ compiler.py", line 677, in results_iter for rows in self.execute_sql(MULTI): File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/ compiler.py", line 732, in execute_sql cursor.execute(sql, params) File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ util.py", line 15, in execute return self.cursor.execute(sql, params) File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ sqlite3/base.py", line 200, in execute return Database.Cursor.execute(self, query, params) DatabaseError: no such column: sample_app_Person.dobestm Any ideas ? Thanks again! On Jan 25, 4:02 pm, Ben Dembroski wrote: > Thanks. > > I suspect this is the issue, as I just changed the settings.py file on > the original project to point to the copied database file. It has no > problem accessing the data. I'll play around with the meta settings > and see what I can come up with. > > Thanks! > > On Jan 25, 3:46 pm, Michael wrote: > > > > > > > > > The database tables are named {{app_label}}_{{model_name}}, so in order > > to use the same database you will need to use the same application name > > (or specify db_table in the model's Meta). > > > -- > > Michael > > > On Tue, 2011-01-25 at 07:36 -0800, Ben Dembroski wrote: > > > Hi all, > > > > Afraid I've got another newbie question. I've been doing some > > > development on a project using sqlite3. All is working well, and I'd > > > like to use the same database file in another project, data intact. > > > I've copied the database file, and the models.py file to the > > > appropriate locations in the new project. When I run syncdb, the > > > only result is 'no fixtures found.' > > > > When I pop into the shell, all the fields are there, but I can't get > > > to the data in any of them. > > > > For instance, inside the shell for the new project I run: > > > > Person.objects.all() > > > > it returns > > > > [] > > > > Do I need to do something besides just copying the database file to > > > keep my data, provided the models.py files are unchanged? > > > > Many thanks, > > > Ben -- 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: Getting hold of an instance of a model from inside RelatedManager
On Tuesday, January 25, 2011 3:34:03 PM UTC, kmpm wrote: > > I have some issues with getting hold of the instance of a Model to which a > RelatedManager got contributed to. > Is that at all possible and if so, how? > > From *my_method* below I can get hold of the model *RelatedStuff* by > calling self.model but that really doesn't get me there. > > class MainStuff(models.Model): > > > class RelatedStuff(models.Model): > ... > main = models.ForeignKey(MainStuff) > objects = CustomManager() > > class CustomManager(models.Manager): > use_for_related_fields=True > > def my_method(self): > #here I would like to access the instance of MainStuff to which > this got contributed > > > Interesting question. Unfortunately, looking at the code, it doesn't seem like you can. Django creates a new RelatedManager class every time, but it does this via a closure - and the instance is only accessible within the closure. There are probably good reasons why it's done that way (I suspect passing the instance as a parameter and making it available as an attribute would cause a persistent reference to be kept, which would mean that the instance would never be garbage-collected). -- 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.
Re: Announcing djeneralize
Great packages ... I was looking for something exactly similar for a project I am working on. I will surely use one of those ! On Jan 25, 4:49 pm, Euan Goddard wrote: > Hi Tom, > > I hadn't seen that. django_polymorphic looks pretty fully featured and > from a quick look, I'd say it accomplishes everything we set out to > do. I guess a use case for djeneralize would be to handle the simple > specializations and generalizations and nothing more. The impetuous to > write the package was just to augment Django's model inheritance which > did almost everything we needed. > > Thanks again for the link. > > Euan > > On Jan 25, 2:26 pm, Tom Evans wrote: > > > On Tue, Jan 25, 2011 at 11:43 AM, Euan Goddard > > wrote: > > > Hi, > > > > I've recently been working on an open source project to augment the > > > inheritance of models in Django. This project, called "djeneralize" > > > allows you to declare specializations on your models and then query > > > the general case model and get back the specialized instances. A > > > simple example of the models might be: > > > Hi Euan, sounds good. > > > Had you come across django_polymorphic[1]? This library also covers > > similar goals. > > > Cheers > > > Tom > > > [1]http://bserve.webhop.org/django_polymorphic/ -- 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: 'unique' field upon inserting
On Tue, Jan 25, 2011 at 10:28 AM, Jonas Geiregat wrote: > The id field (which is added by django by default has this) other then that > the field doesn't have unique=True > > I was also thinking of a better solution. > > I have a Gig model which contains gigs with a ForeignKey to Artist. > I have a Artist model which contains artists. > > One Gig can have multiple artists. > > So instead of creating a field that is unique for each Gig (which might > occur more then once since each gig might have more the one artist) I was > thinking of the following. > > Create a model GigArtist (and leave the Artist Foreign key out of the Gig > model). > > This model contains two fields one who references to a specific gig and one > that references to a (or more then one) specific artist. > > > > > > Op 25-jan-2011, om 16:20 heeft Shawn Milochik het volgende geschreven: > > > Do you have 'unique = True' in the field definition in the model? > > > > -- > > 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. > > > > Met vriendelijke groeten, > > Jonas Geiregat > jo...@geiregat.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 > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > Why can't you just use a ManyToManyField ( http://docs.djangoproject.com/en/1.2/ref/models/fields/#manytomanyfield)? Or am I not correctly understanding what you're trying to do? -- 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: copying sqlite database file between projects
Thanks. I suspect this is the issue, as I just changed the settings.py file on the original project to point to the copied database file. It has no problem accessing the data. I'll play around with the meta settings and see what I can come up with. Thanks! On Jan 25, 3:46 pm, Michael wrote: > The database tables are named {{app_label}}_{{model_name}}, so in order > to use the same database you will need to use the same application name > (or specify db_table in the model's Meta). > > -- > Michael > > > > > > > > On Tue, 2011-01-25 at 07:36 -0800, Ben Dembroski wrote: > > Hi all, > > > Afraid I've got another newbie question. I've been doing some > > development on a project using sqlite3. All is working well, and I'd > > like to use the same database file in another project, data intact. > > I've copied the database file, and the models.py file to the > > appropriate locations in the new project. When I run syncdb, the > > only result is 'no fixtures found.' > > > When I pop into the shell, all the fields are there, but I can't get > > to the data in any of them. > > > For instance, inside the shell for the new project I run: > > > Person.objects.all() > > > it returns > > > [] > > > Do I need to do something besides just copying the database file to > > keep my data, provided the models.py files are unchanged? > > > Many thanks, > > Ben -- 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: Getting hold of an instance of a model from inside RelatedManager
can't you do self.model.main? On Jan 25, 3:34 pm, kmpm wrote: > I have some issues with getting hold of the instance of a Model to which a > RelatedManager got contributed to. > Is that at all possible and if so, how? > > From *my_method* below I can get hold of the model *RelatedStuff* by calling > self.model but that really doesn't get me there. > > class MainStuff(models.Model): > > > class RelatedStuff(models.Model): > ... > main = models.ForeignKey(MainStuff) > objects = CustomManager() > > class CustomManager(models.Manager): > use_for_related_fields=True > > def my_method(self): > #here I would like to access the instance of MainStuff to which this > got contributed -- 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: copying sqlite database file between projects
On Tue, Jan 25, 2011 at 10:36 AM, Ben Dembroski wrote: > When I run syncdb, the > only result is 'no fixtures found.' in Django-speak 'fixtures' are external files with data to be inserted in the database, could be in XML, JSON or YAML. do you use them? maybe you should copy those too from your old project to the new -- Javier -- 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: copying sqlite database file between projects
> 've copied the database file, and the models.py file to the > appropriate locations in the new project. Have you adjusted the settings.py database settings to the correct values ? If so, maybe try the full path to your database file. Regards, Jonas. -- 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: copying sqlite database file between projects
The database tables are named {{app_label}}_{{model_name}}, so in order to use the same database you will need to use the same application name (or specify db_table in the model's Meta). -- Michael On Tue, 2011-01-25 at 07:36 -0800, Ben Dembroski wrote: > Hi all, > > Afraid I've got another newbie question. I've been doing some > development on a project using sqlite3. All is working well, and I'd > like to use the same database file in another project, data intact. > I've copied the database file, and the models.py file to the > appropriate locations in the new project. When I run syncdb, the > only result is 'no fixtures found.' > > When I pop into the shell, all the fields are there, but I can't get > to the data in any of them. > > For instance, inside the shell for the new project I run: > > Person.objects.all() > > it returns > > [] > > Do I need to do something besides just copying the database file to > keep my data, provided the models.py files are unchanged? > > Many thanks, > Ben > -- 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: copying sqlite database file between projects
Do you have suitable file system permissions on the db file for use in the new context? Are the two usages (if they are on different machines, or in different accounts) using the same version of sqlite? (I don't know enough about sqlite to know if this is a problem, but it's worth checking.) Does the settings.py configuration give an absolute path or relative path including "../some_dir/..." that doesn't work in the new context? Bill On Tue, Jan 25, 2011 at 10:36 AM, Ben Dembroski wrote: > Hi all, > > Afraid I've got another newbie question. I've been doing some > development on a project using sqlite3. All is working well, and I'd > like to use the same database file in another project, data intact. > I've copied the database file, and the models.py file to the > appropriate locations in the new project. When I run syncdb, the > only result is 'no fixtures found.' > > When I pop into the shell, all the fields are there, but I can't get > to the data in any of them. > > For instance, inside the shell for the new project I run: > > Person.objects.all() > > it returns > > [] > > Do I need to do something besides just copying the database file to > keep my data, provided the models.py files are unchanged? > > Many thanks, > Ben > > -- > 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. > > -- 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.
copying sqlite database file between projects
Hi all, Afraid I've got another newbie question. I've been doing some development on a project using sqlite3. All is working well, and I'd like to use the same database file in another project, data intact. I've copied the database file, and the models.py file to the appropriate locations in the new project. When I run syncdb, the only result is 'no fixtures found.' When I pop into the shell, all the fields are there, but I can't get to the data in any of them. For instance, inside the shell for the new project I run: Person.objects.all() it returns [] Do I need to do something besides just copying the database file to keep my data, provided the models.py files are unchanged? Many thanks, Ben -- 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.
Getting hold of an instance of a model from inside RelatedManager
I have some issues with getting hold of the instance of a Model to which a RelatedManager got contributed to. Is that at all possible and if so, how? >From *my_method* below I can get hold of the model *RelatedStuff* by calling self.model but that really doesn't get me there. class MainStuff(models.Model): class RelatedStuff(models.Model): ... main = models.ForeignKey(MainStuff) objects = CustomManager() class CustomManager(models.Manager): use_for_related_fields=True def my_method(self): #here I would like to access the instance of MainStuff to which this got contributed -- 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: 'unique' field upon inserting
The id field (which is added by django by default has this) other then that the field doesn't have unique=True I was also thinking of a better solution. I have a Gig model which contains gigs with a ForeignKey to Artist. I have a Artist model which contains artists. One Gig can have multiple artists. So instead of creating a field that is unique for each Gig (which might occur more then once since each gig might have more the one artist) I was thinking of the following. Create a model GigArtist (and leave the Artist Foreign key out of the Gig model). This model contains two fields one who references to a specific gig and one that references to a (or more then one) specific artist. Op 25-jan-2011, om 16:20 heeft Shawn Milochik het volgende geschreven: > Do you have 'unique = True' in the field definition in the model? > > -- > 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. > Met vriendelijke groeten, Jonas Geiregat jo...@geiregat.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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: 'unique' field upon inserting
I don't know if this will make you happy but when I researched this some months ago I found no good solution. During my search I came upon the following pages that sort of relate to this... - http://github.com/dcramer/django-idmapper - http://appengine-cookbook.appspot.com/recipe/high-concurrency-counters-without-sharding/ - http://pastie.org/615863 - http://stackoverflow.com/questions/3522827/handling-race-condition-in-model-save-django I ended up using something similar to the stackoverflow solution. I needed to generate a new number per "produced_at" date in a model called Entity and ended up with the following custom .save method. This is a pretty rough copy-paste so things might not work out of the box but the principle is there. class Entity(models.Model): ... created_at = models.DateTimeField(auto_now_add=True) produced_at = models.DateField(default=datetime.now) number = models.PositiveIntegerField(default=1) class Meta: unique_together=(('produced_at', 'number')) def save(self, *args, **kwargs): if self.id: #do a normal save super(Entity, self).save(*args, **kwargs) return while not self.id: try: max = Entity.objects.filter(produced_at=self.produced_at).aggregate(Max('number')) if max['number__max']: self.number = max['number__max']+1 else: self.number=1 #Trying to save with number = self.number super(Entity, self).save(*args, **kwargs) except IntegrityError: # conflicting number, chill out and try again sleep(uniform(0.1, 0.6)) #chill out, then try again # try again then -- 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: 'unique' field upon inserting
Do you have 'unique = True' in the field definition in the model? -- 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.
'unique' field upon inserting
Hello, I have a model that has a field of the type BigIntegerField(). When inserting something into that field the value must not have been used before but upon inserting it's possible to insert the same value twice. Is there a way to do this using django ? I could generate a random number check if it's already present etc .. but that seems like overhead. Regards, Jonas. -- 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: [OT]Code Review As a Service
On Tuesday, January 25, 2011 9:42:59 AM UTC, Venkatraman.S. wrote: > > Hi, > > I was wondering whether there any freelancers/companies who offer > code-review as a service. > IMHO, a code review helps in almost all occasions, but the faced paced life > seems to have > put this in the back burner. > > Would like your code to be reviewed? If yes, what would be the ideal per > hour rates that > would not hurt your wallet? > > -Venkat > http://blizzardzblogs.blogspot.com/ Are you asking, or offering? I've done a few successful code reviews for people on this group and elsewhere. If you're interested, contact me off-list to discuss rates/times. -- Daniel. -- 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: remove items as they are assigned
Have a look at: http://groups.google.com/group/django-users/browse_thread/thread/eaafb5c60108f3bd/50d871a1627453f5?fwc=1 On Jan 24, 9:22 pm, arlen nascimento wrote: > Hi all, > i'm trying to do a simple thing, but it seems not so simple in django. > > I have the following models > > class Monitor(models.Model): > id ... > name ... > address = foreignkey(MonitorAddress) > > class MonitorAddress(models.Model): > address = CharField() > > what i want to do is as long as i assign a name to a monitor in the > admin add page, MonitorAddress show me only the non-assigned addresses > in the combobox > > i've already tried with forms and inserting a raw sql query in > models.py and forms.py, but it looks like these files are loaded only > once -- 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: Announcing djeneralize
Hi Tom, I hadn't seen that. django_polymorphic looks pretty fully featured and from a quick look, I'd say it accomplishes everything we set out to do. I guess a use case for djeneralize would be to handle the simple specializations and generalizations and nothing more. The impetuous to write the package was just to augment Django's model inheritance which did almost everything we needed. Thanks again for the link. Euan On Jan 25, 2:26 pm, Tom Evans wrote: > On Tue, Jan 25, 2011 at 11:43 AM, Euan Goddard wrote: > > Hi, > > > I've recently been working on an open source project to augment the > > inheritance of models in Django. This project, called "djeneralize" > > allows you to declare specializations on your models and then query > > the general case model and get back the specialized instances. A > > simple example of the models might be: > > Hi Euan, sounds good. > > Had you come across django_polymorphic[1]? This library also covers > similar goals. > > Cheers > > Tom > > [1]http://bserve.webhop.org/django_polymorphic/ -- 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: Code Review As a Service
Wonderful idea Are you going to open business like that? On Tue, Jan 25, 2011 at 10:18 PM, Derek wrote: > Yes, I think this is a great idea. > > Ideally, the charge-rate would be "per lines of code" (excluding > blanks, of course!). Hours are just, too, "amorphous" in this > particular case. > > On Jan 25, 11:42 am, Venkatraman S wrote: > > Hi, > > > > I was wondering whether there any freelancers/companies who offer > > code-review as a service. > > IMHO, a code review helps in almost all occasions, but the faced paced > life > > seems to have > > put this in the back burner. > > > > Would like your code to be reviewed? If yes, what would be the ideal per > > hour rates that > > would not hurt your wallet? > > > > -Venkathttp://blizzardzblogs.blogspot.com/ > > -- > 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. > > -- === Regards Ronghui Yu -- 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: Announcing djeneralize
On Tue, Jan 25, 2011 at 11:43 AM, Euan Goddard wrote: > Hi, > > I've recently been working on an open source project to augment the > inheritance of models in Django. This project, called "djeneralize" > allows you to declare specializations on your models and then query > the general case model and get back the specialized instances. A > simple example of the models might be: > Hi Euan, sounds good. Had you come across django_polymorphic[1]? This library also covers similar goals. Cheers Tom [1] http://bserve.webhop.org/django_polymorphic/ -- 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: method of method
On Tue, Jan 25, 2011 at 11:41 AM, Jaroslav Dobrek wrote: >>> What happens ? > > I get this error message when I run manage.py syncdb: > > AttributeError: 'ForeignKey' object has no attribute 'producer' > >>> And what did you expect to happen ? > > I want the 'country_of_origin' of cars to be the string that is stored > in their producer's 'country_of_origin': > > class CarProducer(models.Model): > country_of_origin = models.CharField(max_length=200) > > > class Car(models.Model): > producer = models.ForeignKey(CarProducer) > country_of_origin = producer.country_of_origin > class Car(models.Model): producer = models.ForeignKey(CarProducer) @property def country_of_origin(self): return self.producer.country_of_origin Cheers Tom -- 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: Code Review As a Service
Yes, I think this is a great idea. Ideally, the charge-rate would be "per lines of code" (excluding blanks, of course!). Hours are just, too, "amorphous" in this particular case. On Jan 25, 11:42 am, Venkatraman S wrote: > Hi, > > I was wondering whether there any freelancers/companies who offer > code-review as a service. > IMHO, a code review helps in almost all occasions, but the faced paced life > seems to have > put this in the back burner. > > Would like your code to be reviewed? If yes, what would be the ideal per > hour rates that > would not hurt your wallet? > > -Venkathttp://blizzardzblogs.blogspot.com/ -- 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.
Lazy translation (unicode) not working for a CharField in the Admin?
A new and strange error for me... A model that has a CharField: comment = models.CharField(max_length=100,db_column='Comment', blank=True, null=True) that is defined in a MySQL database: `Comment` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, is depicted by the Admin in both the changelist and the editing form as: Other similar fields in other models do not have this "strangeness". The docs suggest : "Normally, you won’t have to worry about lazy translations. Just be aware that if you examine an object and it claims to be a django.utils.functional.__proxy__ object, it is a lazy translation. Calling unicode() with the lazy translation as the argument will generate a Unicode string in the current locale." But I am not sure that this helps in the current situation (and it also does not explain why this particular model behaves differently from the others). Any ideas or insights appreciated. Derek -- 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: WEB SERVICE
HI Now i am getting some way but i still cant parse the incoming request my view looks like this at present i am trying to send the request i am getting from xml.dom import minidom import urllib import socket from django.http import HttpResponse from django.core import serializers import urllib import socket def recive_ShortMessage(request): if request.method == 'GET': ref= "Process in progress" return HttpResponse(ref) elif request.method == 'POST': print request socket.setdefaulttimeout(20) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) request.message=['brave'] print request.message XMLSerializer = serializers.get_serializer("xml") xml_serializer = XMLSerializer() xml_serializer.serialize(request) data = xml_serializer.getvalue() print data return HttpResponse(request) -- 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: Versioned database content
see here http://djangopackages.com/grids/g/versioning/ ore there is also a interesting chapter on versioning on page 263 here: http://books.google.com/books?id=lJwOcsZq5g4C&printsec=frontcover&dq=django+pro&hl=de&ei=TdA-TdSyH4GA4Aat1fGwCg&sa=X&oi=book_result&ct=book-thumbnail&resnum=1&ved=0CCwQ6wEwAA#v=onepage&q&f=false please share your results -- 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: method of method
On 25 jan, 12:41, Jaroslav Dobrek wrote: > >> What happens ? > > I get this error message when I run manage.py syncdb: > > AttributeError: 'ForeignKey' object has no attribute 'producer' > > >> And what did you expect to happen ? > > I want the 'country_of_origin' of cars to be the string that is stored > in their producer's 'country_of_origin': Do you mean that you want Car to have a country_of_origin model.Field (IOW: the yourapp_car table to have a country_of_origin column) and copy the related Producer.country_of_origin field's value in it, or just Car instances to have a "country_of_origin" attribute that is just a shortcut for self.producer.country_of_origin ? > class CarProducer(models.Model): > country_of_origin = models.CharField(max_length=200) > > class Car(models.Model): > producer = models.ForeignKey(CarProducer) > country_of_origin = producer.country_of_origin -- 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: method of method
Hi there, Are you sure that you want to denormalize your schema like that ? I now this is a totally different issue and question but in this case do you really need to perform this operation ? Have considered the problems that this approach will bring? Imagine this simple use case: If one changes the country_of _orign of the Producer that wont reflect on the Car instance! I can see some utility for this use but in any case I would review my requirements. Cheers, N. On Jan 25, 12:36 pm, Euan Goddard wrote: > I agree with the previous poster - the title is misleading as the word > "method" is incorrect in both places. > > It seems that the original poster is talking about denormalizing data. > However, this is unnecessary as the ORM allows for this type of data > to be retrieved any how, e.g. > Car.objects.all().select_related(depth=1) will allow statements like: > car.producer.country_of_origin > > If you want access to country_of_origin directly on the Car instances, > I'd suggest a property: > > @property > def country_of_origin(self): > return self.producer.country_of_origin > > Euan > > On Jan 25, 11:30 am, bruno desthuilliers > > > > > > > > wrote: > > On 25 jan, 11:57, Jaroslav Dobrek wrote: > > > > Hi, > > > > can I use methods of methods in Django? > > > What's a "methods of methods" ??? > > > > Like so: > > > > class Car(models.Model): > > > producer = models.ForeignKey(CarProducer) > > > country_of_origin = producer.country_of_origin > > > What is CarProducer.country_of_origin ? A method ? A model.Field ? > > Something else ? > > > > This doesn't seem to work. > > > What happens ? And what did you expect to happen ? -- 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.
Error when subclassing models.ForeignKey field
Hello, I'm using a current SVN checkout of django an I'm having difficulties creating a custom field. class ForeignKeyAX(models.ForeignKey): __metaclass__ = models.SubfieldBase description = "ForeignKey field prepared for Ajax Autocompletion" def __init__(self,*args,**kwargs): self.kunde_rel=False if kwargs.has_key('kunde_rel'): self.kunde_rel = kwargs.pop('kunde_rel') super(ForeignKeyAX, self).__init__(*args,**kwargs) with this, I get the folowing error: KeyError at /path//id/ 'ip' Request Method: GET Request URL:http://localhost:8000/path/id/ Django Version: 1.3 beta 1 SVN-15308 Exception Type: KeyError Exception Value: 'ip' Exception Location: /path-to_djanog/django/db/models/fields/subclassing.py in __get__, line 96 and further down: /home/roman/devel/django-trunk/django/db/models/fields/subclassing.py in __get__ 89. def __init__(self, field): self.field = field def __get__(self, obj, type=None): if obj is None: raise AttributeError('Can only be accessed via an instance.') 96. return obj.__dict__[self.field.name] 'ip' is not contained in obj.__dict__. Like the other foreignkey fields its there as ip_id. What am I doing wrong? How can I get this going? BTW: When I ommit the line: __metaclass__ = models.SubfieldBase Everything works fine. But then other things I want to do like overriding to_python will not work as far as I understand. Please help. Best regards Roman -- 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: method of method
On 25 Jan., 12:36, Euan Goddard wrote: > I agree with the previous poster - the title is misleading as the word > "method" is incorrect in both places. O.k. sorry. Should have been "attribute of attribute", right? -- 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: method of method
>> What happens ? I get this error message when I run manage.py syncdb: AttributeError: 'ForeignKey' object has no attribute 'producer' >> And what did you expect to happen ? I want the 'country_of_origin' of cars to be the string that is stored in their producer's 'country_of_origin': class CarProducer(models.Model): country_of_origin = models.CharField(max_length=200) class Car(models.Model): producer = models.ForeignKey(CarProducer) country_of_origin = producer.country_of_origin -- 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: Announcing djeneralize
Hi Euan, Impressive work. On Tue, Jan 25, 2011 at 5:13 PM, Euan Goddard wrote: > Hi, > > I've recently been working on an open source project to augment the > inheritance of models in Django. This project, called "djeneralize" > allows you to declare specializations on your models and then query > the general case model and get back the specialized instances. A > simple example of the models might be: > > class Fruit(BaseGeneralizedModel): >name = models.CharField(max_length=30) > >def __unicode__(self): >return self.name > > class Apple(Fruit): >radius = models.IntegerField() > >class Meta: >specialization = 'apple' > > class Banana(Fruit): >curvature = models.DecimalField(max_digits=3, decimal_places=2) > >class Meta: >specialization = 'banana' > > class Clementine(Fruit): >pips = models.BooleanField(default=True) > >class Meta: >specialization = 'clementine' > > which then allows the following queries to be executed: > > >>> Fruit.objects.all() # what we've got at the moment > [, , clementine>] > >>> Fruit.specializations.all() # the new stuff! > [, , clementine>] > > I hope this type of general case/specialization might be of some use > to someone else out there. We're planning on integrating this work in > a large project we're undertaking on content categorization. > > Grab the source at github: https://github.com/2degrees/djeneralize > > or you can easy_install it (easy_install djeneralize). > > Feedback, etc. very welcome. > > Thanks, Euan > > -- > 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. > > -- Thanks & Regards *Manoj Kumar* * * -- 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.
Announcing djeneralize
Hi, I've recently been working on an open source project to augment the inheritance of models in Django. This project, called "djeneralize" allows you to declare specializations on your models and then query the general case model and get back the specialized instances. A simple example of the models might be: class Fruit(BaseGeneralizedModel): name = models.CharField(max_length=30) def __unicode__(self): return self.name class Apple(Fruit): radius = models.IntegerField() class Meta: specialization = 'apple' class Banana(Fruit): curvature = models.DecimalField(max_digits=3, decimal_places=2) class Meta: specialization = 'banana' class Clementine(Fruit): pips = models.BooleanField(default=True) class Meta: specialization = 'clementine' which then allows the following queries to be executed: >>> Fruit.objects.all() # what we've got at the moment [, , ] >>> Fruit.specializations.all() # the new stuff! [, , ] I hope this type of general case/specialization might be of some use to someone else out there. We're planning on integrating this work in a large project we're undertaking on content categorization. Grab the source at github: https://github.com/2degrees/djeneralize or you can easy_install it (easy_install djeneralize). Feedback, etc. very welcome. Thanks, Euan -- 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: method of method
I agree with the previous poster - the title is misleading as the word "method" is incorrect in both places. It seems that the original poster is talking about denormalizing data. However, this is unnecessary as the ORM allows for this type of data to be retrieved any how, e.g. Car.objects.all().select_related(depth=1) will allow statements like: car.producer.country_of_origin If you want access to country_of_origin directly on the Car instances, I'd suggest a property: @property def country_of_origin(self): return self.producer.country_of_origin Euan On Jan 25, 11:30 am, bruno desthuilliers wrote: > On 25 jan, 11:57, Jaroslav Dobrek wrote: > > > Hi, > > > can I use methods of methods in Django? > > What's a "methods of methods" ??? > > > Like so: > > > class Car(models.Model): > > producer = models.ForeignKey(CarProducer) > > country_of_origin = producer.country_of_origin > > What is CarProducer.country_of_origin ? A method ? A model.Field ? > Something else ? > > > This doesn't seem to work. > > What happens ? And what did you expect to happen ? -- 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: automated testing: how to generate human-verifiable views?
2011/1/4 Jennifer Bell > Hi, > > I'm trying to figure out the best way of doing something I'd like > to partially automate staging testing by generating a sequence of > human verifiable views, with the goal of making sure my app views/css/ > 3rd-party javascript etc. are drawing the way they ought to in more > complicated scenarios.While back end code can easily be tested > with TestClient, failures in the 'final mile' of rendering are really > annoying. > > It would be nice to have a 'view test mode' that allows a tester to > click through a series of database configuration / URL pairs in a > relatively painless way. > > Is there a standard way of doing this, or any existing modules I could > use to achieve this? > > Jennifer > > -- > 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. > > http://twill.idyll.org/ -- Simo - Registered Linux User #395060 - Software is like sex, it is better when it is free --> Linus B. Torvalds -- 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: method of method
On 25 jan, 11:57, Jaroslav Dobrek wrote: > Hi, > > can I use methods of methods in Django? What's a "methods of methods" ??? > Like so: > > class Car(models.Model): > producer = models.ForeignKey(CarProducer) > country_of_origin = producer.country_of_origin What is CarProducer.country_of_origin ? A method ? A model.Field ? Something else ? > This doesn't seem to work. What happens ? And what did you expect to happen ? -- 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.
method of method
Hi, can I use methods of methods in Django? Like so: class Car(models.Model): producer = models.ForeignKey(CarProducer) country_of_origin = producer.country_of_origin This doesn't seem to work. Is there a special syntax for this? Jaroslav -- 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.
Multiple Admins, improper object linking
Hi, I have a lot of admin customization. Queryset overriding, custom urls per object, per admin site, save methods overriding and calling some external services, template changes, you name it. So, In my application, I like to have another instance of admin I call "bare-tables" in which I auto register all existing models in a project level admin.py using the following: from django.db.models import get_models from django.contrib.admin import AdminSite from reversion.admin import VersionAdmin class BareTables(AdminSite): pass new_admin = BareTables(name='bare_tables') for el in get_models(): new_admin.register(el,VersionAdmin) And I link up both the admins in the URL using the following: urlpatterns = patterns('', url(r'^admin_tools/', include('admin_tools.urls')), (r'^admin/doc/', include('django.contrib.admindocs.urls')), (r'^admin/', include(admin.site.urls)), (r'^bare-tables/', include(new_admin.urls)), I was all good and happy. Except, I included the admin tools, to customize only the first admin with all the Jazz, dashboard and menus, the way I like it. Now, when I go to the admin, or to the plain admin that I called "bare-tables", the objects are linked to the main admin. :( If I manually change the "admin" in the url above to "bare-tables", it works. I think the problem is that admin_tools templates don't use the prefix to reverse the urls, or that I need to pass it the prefix somehow and I am not. What simple change that I can make to make it work properly. I am ok, even if the plain admin retains the old skin, Is there a way I can tell admin-tools, not to get involved if the base url is something. -Regards, Lakshman lakshmanprasad.com -- 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: automated testing: how to generate human-verifiable views?
On Thu, Jan 6, 2011 at 11:07 PM, Jennifer Bell wrote: > Is this a really weird thing to want to do? You can TDD almost > everything else in django through TestClient except for the end result > of how stuff looks. > > Jennifer > Not that weird: http://en.wikipedia.org/wiki/Selenium_(software) I'm not aware of any django specifc integration. Cheers Tom -- 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: Versioned database content
On Jan 25, 12:08 pm, Juergen Schackmann wrote: > why do you want to create the dual tables, instead of only having one table > with a current tag that holds the old version and the current ones? and then > handle access to those via different managers? > have you also had a look at the available versioning apps? I forgot to include this in my original post: I already have a working application and I would like to be able to add versioning support without changing the current schema. Also, I am using Admin, and I am afraid of the amount of work this would require. I am currently using a setup where each change gets logged into dual tables using plpgsql triggers, but as the content is relatively large per row, and updated quite often, while new versions aren't that common, I will get a lot of bloat in the dual tables using my current setup. And it is a bit hard to actually fetch the correct version from the dual tables... I will look into the existing versioning apps, maybe one of the will allow me to easily create this kind of setup. Thank you for the help, - Anssi -- 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: Versioned database content
why do you want to create the dual tables, instead of only having one table with a current tag that holds the old version and the current ones? and then handle access to those via different managers? have you also had a look at the available versioning apps? -- 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: Constants in model, that point to certain objects in database
On 24 jan, 21:20, Filip Gruszczyński wrote: > > > You could write a custom descriptor then. But the whole idea of a > > class-level pseudo-constant pointing to a model instance still looks > > rather backward to me. > > What is a custom descriptor? I have never used it. Is it something > like a property? The descriptor protocol is the mechanism that allows both property and method: http://docs.python.org/reference/datamodel.html#implementing-descriptors http://users.rcn.com/python/download/Descriptor.htm In your case, something like the following could do: class ModelInstanceConst(object): def __init__(self, **lookup): self.lookup = lookup def __get__(self, instance, cls=None): if instance is None and cls is None: # shouldn't happen but well... return self if cls is None: cls = type(instance) return cls.objects.get(**self.lookup) def __set__(self, instance, value): raise AttributeError("attribute is read-only") def __delete__(self, instance): raise AttributeError("attribute is read-only") class MyModel(models.Model): CONST = ModelInstanceConst(id=1) NB : not tested. > > Oh, and while were at it: the Python standard for the current class > > param name in a classmethod is 'cls', not 'Class' ;) > > I have seen both cls and klass in django code. I prefer mine, because > it clearly indicates, that the objects is not an instance, but a class It's still an instance (of it's metaclass). If it's a newstyle class, at least ;) > (and therefore type instance, right?). Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class Foo: pass ... >>> isinstance(Foo, type) False >>> But anyway... > > Yes they do - as long as their metaclass derives from the appropriate > > metaclass (ModelBase IIRC but better to check it out). > > I'll definitely try that. I'm not sure it's necessary here - the custom descriptor solution might be enough. -- 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: Versioned database content
You probably want to look at abstract models in Django. It's also known as concrete inheritance in some ORMs -- Jani Tiainen On Tuesday 25 January 2011 09:42:08 akaariai wrote: > Hello all, > > My problem is as follows: I have content (for simplicity, lets say > articles), and some content related to that (authors for the example). > I would like to add the ability for users to create versions of the > content. The procedure from user perspective is as follows: they click > a button ("create new version") and supply some details about the > update. > > Now, I would like to automatically generate dual tables for articles > and content which would be versioned. That is, when users click > "create new version" my software should insert the current data into > the dual tables so that it is possible to go back to each published > version. > > The problem I am facing is this: I would like to create automatically > the dual tables. I haven't thought about the schema much, but I > probably don't need anything more than the base tables + an integer > column version. Is there any relatively easy way to create the dual > tables automatically? That is, is it possible to read the models I > have currently and create the dual table without me having to copy all > the definitions. For example, given the article model: > > class Author(models.Model): > name = models.TextField() > > class Article(models.Model): > id = models.AutoField() > text = models.TextField() > authors = models.ManyToManyField(Author) > > I would like to create automatically (in runtime or just create the > models.py file automatically running a script) the dual models: > > class AuthorDual(models.Model): > name = models.TextField() > version = models.PositiveIntegerField() > > class ArticleDual(models.Model): > id = models.AutoField() > text = models.TextField() > authors = models.ManyToManyField(AuthorDual) > version = models.PositiveIntegerField() > > Has anybody done anything similar? Any pointers where to look for > similar code? And is this doable in sane amount of time? > > Thanks in advance, > - Anssi -- 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.
[OT]Code Review As a Service
Hi, I was wondering whether there any freelancers/companies who offer code-review as a service. IMHO, a code review helps in almost all occasions, but the faced paced life seems to have put this in the back burner. Would like your code to be reviewed? If yes, what would be the ideal per hour rates that would not hurt your wallet? -Venkat http://blizzardzblogs.blogspot.com/ -- 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: DjangoAMF status
On Jan 22, 4:50 am, "Joni @ mindpulse" wrote: > Comparing all of them, It looks like PyAMF is the way to go, having > oficial sopport for django and all. > > Though I'm concerned about one particular issue... Suppose I have two > django models related by a FK. > > class Category(models.Model): > name = models.CharField(max_length=100) > > class Product(models.Model): > code = models.CharField(max_length=100) > category = models.ForeignKey(Category) > > I would need to map both classes to their Actionscript counterparts. > What I'm not sure about is what happens with the FK in Product? Is it > possible to define something like this: > > class ASCategory > { > public var name:String; > > } > > class ASProduct > { > public var code:String; > public var category:ASCategory; > > } > > Notice that in ASProduct I'm expecting an ASCategory object, not the > category id. If this isn't possible, what will actually happen? Do I > receive the category id? Has anybody worked before with django and > AMF? I'll appreciate any info here! PyAMF handles ForeignKey relationships the way as Django conceptualises them - objects attached to other objects. You will need to use select_related to make Django pull the relations in the same query. It should 'just work' and if not, its a bug. - Nick -- 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.