Re: Can't Send Password With Test Client
It appears that the password value isn't printed for security reasons. The problem remains that the form will not validate. James wrote: > I've confirmed that while I can send other fields via the Django test > client, I can't send password fields. > > So for instance: > > print "password:", form['password'] > print "email:", form['email'] > > >>>password: id="id_password" /> > >>>email: value="[EMAIL PROTECTED]" id="id_email" /> > > > > There is no value for the password field, and the form is not being > validated. > > I've also tried the client.login() method, but haven't gotten that to > work. Shouldn't I be able to login through the same POST request that > a client would normally make? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django not deleting files still referenced by ImageField
So I added a custom storage class to an ImageField which overwrites files with the same name. I noticed while testing that I can add many records all referencing the same single image, which gets overwritten with each new record created. What's strange/interesting is... the image file doesn't get deleted until I remove the last record referencing the file! Is django really this smart? :) Storage class: http://www.djangosnippets.org/snippets/976/ --~--~-~--~~~---~--~~ 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: Coding for arbitrary additional fields of a certain type
On Jun 27, 8:56 pm, lzantal wrote: > Hi, > > On Jun 27, 2009, at 10:55 AM, "Daniele Procida" > > > > wrote: > > > I am wondering what sort of coding/storage approach to take to manage > > contact details in a more sophisticated way. > > > For example, one person might need: > > > Phone (London): xxx x > > Phone (Edinburgh): xxx xx > > > and another: > > > Phone (office): xxx > > Phone (laboratory): xxx > > Phone (mobile): xxx x > > > but you can't know in advance how any particular person might need > > their > > details labelled. > > > Is there a name for this kind of scheme, or a standard way of > > handling it? > > > Thanks, > > > Daniele > > I had a similar need a few months ago. > What I did is I stored those info in a database in ini format. > So after running the query I parsed it as an ini conf data. It works > great. > Doesn't that make searching by number a nightmare? I'd favour Alex's approach myself. --~--~-~--~~~---~--~~ 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: Is IP address caching built into the Django Framework?
On Jun 29, 8:13 am, Vladimir Shulyak wrote: > > You can't rely on just the IP. If you do then you will have problems > > where large numbers of people sit behind a single IP, as will be case > > where corporate firewall is used, or where proxies or other gateway or > > NAT solution are used by ISPs. > > That's right, try to use cookie check instead of IP check. > Except cookies are very easy to fake it depends on how serious you want your voting to be; whether you could tolerate a little hacking or not. http://stackoverflow.com/questions/1042580/best-way-to-store-views-of-an-topic/ Is a discussion on this in mysql/php but the general principles are the same. Basically, IP addr is the only thing it's really hard to play around with - user-agent, cookie, everything else is fakable with ease. But if you use IP addr only then 2 people sharing the same IP address (different computers on the same broadband connection, etc) can only vote once. It's a problem. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Extending AdminSite
Based some tutorials and code examples, I'm attempting to modify my admin page by adding "admin.py" in my project directory. However, the changes don't seem to make a lick of difference. This (http://www.webmonkey.com/tutorial/ Install_Django_and_Build_Your_First_App#Check_your_head) implies that, by creating "admin.py" in the "djangoblog" directory (if the tutorial is followed verbatim) with the listed code, the "Auth" and "Sites" sections of the administration page would not show up. I also take that to mean, based on other documentation I've read, that these, and other models, can be rearranged in the admin interface as desired. However, I ran across this (http://docs.djangoproject.com/en/dev/ref/ contrib/admin/#adminsite-objects) that makes me believe such ideas are in Django 1.1, rather than 1.0.2, which I am currently running. Is this correct? If the modification should be done in templates, let me know; I do think admin.py is the appropriate place for it, but I'm new to the community. Thank you, James --~--~-~--~~~---~--~~ 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: redirecting after login
You can access the page that they were previously on using HttpRequest.META['HTTP_REFERER']. You'll probably need to persist it in a session so you still have access to it after they submit their login credentials (otherwise HTTP_REFERER would be the login page). I'm not sure if HTTP_REFERER can be abused or not (i.e. CSRF), but as a precaution you might consider just using the path from HTTP_REFERER. On Jul 31, 8:15 am, When ideas fail wrote: > I was wondering if there was a way to redirect users after login to > the page they where looking at before they logged in. > > So if they where on "/blog/" when they logged in they could be > redirected back and if they where on "/about_us/" they could be > redirected to "/about_us/"? > > I'd appreciate any help, 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 -~--~~~~--~~--~--~---
Open Position: Software/System Engineer....Django...
Hello All I do not know if this is the correct forum. I am looking for a Software/System Engineer with Django experience in the Cleveland, OH area. The skill set looks like this: • Expertise in M/S Windows, Red Hat Linux Operating Systems, MySQL database development and Apache server setup. • Expertise in Languages: Python • Knowledge of the Django framework and working in a web development environment. Interested individuals can submit resumes to employm...@globalww.com. If this is not the place for this type of posting, if someone could suggest an area, I would appreciate the guidance. Thanks James --~--~-~--~~~---~--~~ 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: Open Position: Software/System Engineer....Django...
Thanks, I will post there. On Sep 8, 4:41 pm, Jim McGaw wrote: > There is a site for posting Django jobs: > > http://djangogigs.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 -~--~~~~--~~--~--~---
UserProfile / admin.site.unregister / "'PropertiedClass' object is not iterable" Error
I'm a bit new to all this. I was trying to implement the UserProfile feature described here: http://www.thenestedfloat.com/articles/displaying-custom-user-profile-fields-in-djangos-admin But when it comes time to add that to the admin side of things (in appengine), I get the error: 'PropertiedClass' object is not iterable This is the latest version of the offending file: from django.contrib import admin from django.contrib.auth.models import User from django.contrib.auth.admin import UserAdmin from userprofile.models import UserProfile admin.site.unregister(User) #class UserProfileInline(admin.StackedInline): # model = UserProfile #class UserProfileAdmin(UserAdmin): # inlines = [UserProfileInline] #admin.site.register(User, UserAdmin) __END__ ... any ideas? Many Thanks, James --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
how to organize favorites in template?
Hi, I'm writing a video site on app engine where the user can tag videos as favorites. What I've done is store the keys of a users favorite videos in a dict, and I try to determine if I should be allowing them to add or remove this video from their favorites like this (truncated): {% for video in video_list %} {% if favorites[video.key] %} ... offer to remove {% endif %} {% endfor %} ... but this of course blows up because the template system can't understand favorites[video.key]. I wonder how I should organize this data and write the tags so that it works... should I be adding a property to each video to mark it as a favorite? I've tried this: for video in videos: video.favorite = True but that property (or attribute or whatever it's called) doesn't show up in my template as true ... ?? Many Thanks, James --~--~-~--~~~---~--~~ 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: get value in session when concurrency request
I think (in v 1.0) you can call session_store.save() -- I'm guessing that it will save immediately, but I'm not sure: http://docs.djangoproject.com/en/dev/topics/http/sessions/?from=olddocs#using-sessions-out-of-views On Apr 16, 10:06 pm, leopay wrote: > at first session["a"] is oldvalue, > request A set session["a"] to newvalue, before session.save to db,(as > in django, the session save action occur at end of the request), > meanwhile, request B arrive, but get session["a"] is still the > oldvalue, > how to handle this? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Display dashes in the admin site combobox
Hello, I have this product model class Product(models.Model): VAT_CODES = ( (6.00, '6%'), (12.00, '12%'), (21.00, '21%'), ) description = models.CharField(max_length=50,) unit_price = models.DecimalField(max_digits=10,decimal_places=2) vat_code = models.DecimalField (max_digits=4,decimal_places=2,choices=settings.VAT_CODES,) # vat_code = models.CharField (max_length=7,choices=settings.VAT_CODES,) But when I try the admin interface the vat_code combobox give all dashes when I will change the product vat_code. The vat_code have the right value in the database. There is no problem when I change from DecimalField to CharField see the line in comment. Any idea what could be the problem ? Kind Regards James --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
An ORM request returns the same object twice?
So the models I am using are at http://github.com/jarofgreen/TaggedWiki/blob/e45ede936ebc2e88c9b60de7572b5048da43c0e6/taggedwikitest/taggedwiki/models.py Here is some test code to run on an empty DB: >>> from taggedwiki.models import * >>> s = Space.objects.create(Title='test') >>> p1 = Page.objects.create(Title='blah', Body='', >>> Space=s,LastUpdateIP='127.0.0.1') >>> p2 = Page.objects.create(Title='blah2', Body='', >>> Space=s,LastUpdateIP='127.0.0.1') >>> p2.addTag('blah') >>> Tag.objects.all() [, ] >>> Tag.objects.filter(page__Space=s) [, , ] Why is tag 'blah' repeated twice in that last query? I assumed that the results from a query set would be unique - am I wrong? Are there any other instances where you don't get unique objects? Thanks for your help, James --~--~-~--~~~---~--~~ 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: An ORM request returns the same object twice?
Ah, I somehow missed distinct() when reading the docs. Sorry, and thanks for your help. On Jun 7, 2:20 pm, Karen Tracey wrote: > On Sun, Jun 7, 2009 at 8:47 AM, James wrote: > > > So the models I am using are at > > >http://github.com/jarofgreen/TaggedWiki/blob/e45ede936ebc2e88c9b60de7... > > > Here is some test code to run on an empty DB: > > > >>> from taggedwiki.models import * > > >>> s = Space.objects.create(Title='test') > > >>> p1 = Page.objects.create(Title='blah', Body='', > > Space=s,LastUpdateIP='127.0.0.1') > > >>> p2 = Page.objects.create(Title='blah2', Body='', > > Space=s,LastUpdateIP='127.0.0.1') > > >>> p2.addTag('blah') > > >>> Tag.objects.all() > > [, ] > > >>> Tag.objects.filter(page__Space=s) > > [, , ] > > > Why is tag 'blah' repeated twice in that last query? I assumed that > > the results from a query set would be unique - am I wrong? Are there > > any other instances where you don't get unique objects? > > Tag 'blah' is associated with Space s twice, once via p1 (auto-added in your > Page save()) and once via the p2 addTag call you show. By default such > duplicates are not removed from QuerySet results, if you want them to be you > need to use specify distinct(): > > http://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct > > 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: getting the latest story is too slow
I would explore some database indexes. Is that publish date column indexed in any way? I've seen MySQL batch scripts drop from 30 mins plus to a minute or two with the right index, it's worth looking into. James --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Open source project looking for developer
Hi, http://www.myjobseek.net/ is a tool for job seekers to organise their job hunt, storing details of jobs applied for and applications, making it easy to reuse covering letters and so on. However, as I only develop it when I' -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Open source project looking for developer
Pressed the wrong button and posted prematurely ... :-/ Hi, http://www.myjobseek.net/ is a tool for job seekers to organise their job hunt, storing details of jobs applied for and applications, making it easy to re-use covering letters and so on. To-do lists and reminders are included to. However, as I only develop it when I'm job hunting, it's in a early state. (Thankfully I haven't been job-hunting much recently) If I open sourced it, would people be intrested in picking this up and working on in? (It's in Django, of course) Reply off list if you want. Sorry if this is off-topic (& for my stupidity in posting twice!) James -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: about file uploading
WebDav will not work for you? -james On Mon, Nov 1, 2010 at 1:37 PM, Lic. José M. Rodriguez Bacallao wrote: > yes, I saw that page but this is a complete application, I need > someting with source code for mimifiying in django > > On Mon, Nov 1, 2010 at 1:35 PM, Cal Leeming [Simplicity Media Ltd] > wrote: >> Here, let me google that for you.. >> http://www.radinks.com/upload/plus/resume.php >> http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=http+upload+resume >> Please make sure you make reasonable attempt to find the answer yourself on >> Google, otherwise the boards get filled with copy pasta. >> On Mon, Nov 1, 2010 at 6:30 PM, Lic. José M. Rodriguez Bacallao >> wrote: >>> >>> hi folks, I need to develop an application for uploading big files but >>> one requirement is that I must be able to resume a partially uploaded >>> file. How can I achieve this with django, any ideas? >>> >>> -- >>> Lic. José M. Rodriguez Bacallao >>> Centro de Biofisica Medica >>> - >>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo >>> mismo. >>> >>> Recuerda: El arca de Noe fue construida por aficionados, el titanic >>> por profesionales >>> - >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-us...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >> >> >> >> -- >> >> Cal Leeming >> >> Operational Security & Support Team >> >> Out of Hours: +44 (07534) 971120 | Support >> Tickets: supp...@simplicitymedialtd.co.uk >> Fax: +44 (02476) 578987 | Email: cal.leem...@simplicitymedialtd.co.uk >> IM: AIM / ICQ / MSN / Skype (available upon request) >> >> Simplicity Media Ltd. All rights reserved. >> Registered company number 7143564 >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > > > -- > Lic. José M. Rodriguez Bacallao > Centro de Biofisica Medica > - > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. > > Recuerda: El arca de Noe fue construida por aficionados, el titanic > por profesionales > - > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: about file uploading
You can use webdav to help accomplish that goal. See: http://stackoverflow.com/questions/492307/uploading-big-files-over-http/1499819#1499819 (from the link Cal provided) -james On Mon, Nov 1, 2010 at 2:19 PM, Lic. José M. Rodriguez Bacallao wrote: > with webdav can I uploading a file, interrupt it the then resume the > upload again starting from an offset of the previously uploading file > ? > > On Mon, Nov 1, 2010 at 1:54 PM, James wrote: >> WebDav will not work for you? >> -james >> >> On Mon, Nov 1, 2010 at 1:37 PM, Lic. José M. Rodriguez Bacallao >> wrote: >>> yes, I saw that page but this is a complete application, I need >>> someting with source code for mimifiying in django >>> >>> On Mon, Nov 1, 2010 at 1:35 PM, Cal Leeming [Simplicity Media Ltd] >>> wrote: >>>> Here, let me google that for you.. >>>> http://www.radinks.com/upload/plus/resume.php >>>> http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=http+upload+resume >>>> Please make sure you make reasonable attempt to find the answer yourself on >>>> Google, otherwise the boards get filled with copy pasta. >>>> On Mon, Nov 1, 2010 at 6:30 PM, Lic. José M. Rodriguez Bacallao >>>> wrote: >>>>> >>>>> hi folks, I need to develop an application for uploading big files but >>>>> one requirement is that I must be able to resume a partially uploaded >>>>> file. How can I achieve this with django, any ideas? >>>>> >>>>> -- >>>>> Lic. José M. Rodriguez Bacallao >>>>> Centro de Biofisica Medica >>>>> - >>>>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo >>>>> mismo. >>>>> >>>>> Recuerda: El arca de Noe fue construida por aficionados, el titanic >>>>> por profesionales >>>>> - >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google Groups >>>>> "Django users" group. >>>>> To post to this group, send email to django-us...@googlegroups.com. >>>>> To unsubscribe from this group, send email to >>>>> django-users+unsubscr...@googlegroups.com. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/django-users?hl=en. >>>>> >>>> >>>> >>>> >>>> -- >>>> >>>> Cal Leeming >>>> >>>> Operational Security & Support Team >>>> >>>> Out of Hours: +44 (07534) 971120 | Support >>>> Tickets: supp...@simplicitymedialtd.co.uk >>>> Fax: +44 (02476) 578987 | Email: cal.leem...@simplicitymedialtd.co.uk >>>> IM: AIM / ICQ / MSN / Skype (available upon request) >>>> >>>> Simplicity Media Ltd. All rights reserved. >>>> Registered company number 7143564 >>>> >>>> -- >>>> You received this message because you are subscribed to the Google Groups >>>> "Django users" group. >>>> To post to this group, send email to django-us...@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> django-users+unsubscr...@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/django-users?hl=en. >>>> >>> >>> >>> >>> -- >>> Lic. José M. Rodriguez Bacallao >>> Centro de Biofisica Medica >>> - >>> Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo >>> mismo. >>> >>> Recuerda: El arca de Noe fue construida por aficionados, el titanic >>> por profesionales >>> - >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-us...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >>> >> >> -- &
Re: Repost Admin Site Without Graphics
So your admin media (js, css, images, etc) isn't working? Try two things: 1. Open the source of some admin page. Look at some image, css, or js object. Find the path where it is pointing. Does this path makes sense? (Have you put it in the settings.py file?) 2. Check your site settings. If you are using django's web server, it will serve the admin files automatically, if you are using apache or some other web server, you will have to specify where the admin site's files are, like Robbington said. Compare the path in the settings file to the one that is being served. ... On Tue, Nov 2, 2010 at 11:58 AM, octopusgrabbus wrote: > Tried suggestions, and still do not get full graphics. Everything else > works. Users are displayed, and so on. > > On Nov 2, 12:24 pm, octopusgrabbus wrote: >> Thanks. I'll try your suggestions. I am using the phrase no graphics >> to mean the admin site comes up, but doesn't have all the nice >> background. >> >> On Nov 1, 3:41 pm, Robbington wrote: >> >> > Hi, >> >> > By 'with out graphics' do you mean no css or Javascript? >> >> > If so you want to make sure the value for these 3 varibles are correct >> > as its not governed by the templates list. >> >> > MEDIA_ROOT = ' /var/www/django_project/media' # Where media is the >> > copied folder of admin media or a symbolic link if you are using >> > Linux. >> >> > MEDIA_URL = 'media/' >> >> > ADMIN_MEDIA_PREFIX = '/media/' >> >> > Rob -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How create a simple "brochure" website in django?
On Thu, Nov 4, 2010 at 10:37 AM, Karim Gorjux wrote: > On Thu, Nov 4, 2010 at 15:06, bruno desthuilliers > wrote: >> You may not realize that what you're describing here is a full blown >> CMS, and as such is a tad more complex than simple thing like a blog >> or wiki or dumbed-down twitter clone. I strongly suggest you try some >> existing CMS like django-cms or LFC >> >> http://www.lfcproject.com/ >> http://www.django-cms.org/ > > Thanks! I understand why I can't find anything on internet about that. > Do you know if there is a really simplecms where I can work on without > too much problems? > Yes, there is. You should take a look at "Practical Django Projects" (be sure to get the 2nd edition) by James Bennett. In the book he creates a simple-cms with a tinymce editor. He has the source code published here: http://bitbucket.org/ubernostrum/practical-django-projects/src -james -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Automatically assume "models." prefix in models.py
Forgive a django newbie... Maybe I'm the laziest person in the world, but sometimes I get tired of typing "models.WhatEver" for every single model I have to write. Is there anyway a shortcut could be added that would 'assume' the 'models.' prefix when I am defining a model? e.g. instead of: class SomeModel(models.Model): something = models.SomeField(someoption=something) # some other things Could a shortcut be added so that I can write: class SomeModel(models.Model): something = SomeField(someoption=something) # some other things I realized that not everything I will write will have the "models." prefix, but I think _most_ of what I write in models.py will have it. So... I'm a being too lazy, or perhaps just stupid? Thanks, -james -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Automatically assume "models." prefix in models.py
On Mon, Nov 15, 2010 at 7:48 AM, bruno desthuilliers wrote: > On Nov 14, 8:20 am, James wrote: >> Forgive a django newbie... >> >> Maybe I'm the laziest person in the world, but sometimes I get tired >> of typing "models.WhatEver" for every single model I have to write. Is >> there anyway a shortcut could be added that would 'assume' the >> 'models.' prefix when I am defining a model? >> > Others already answered this question. On a more general level, I very > strongly suggest you spend some time learning Python (version 2.x - > not (yet) version 3.x), because your question is really about Python > itself, and something anyone coding in Python should know. Remember > that Django is just a Python framework... > > HTH > > -- Thanks all. Good point. I've actually been working through Learn Python the Hard Way & How to Think Like A Computer Scientist. -James -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Did you ever get this issue resolved?
Hi, I have come across the same problem as you describe. Did you resolve the issue? If so, what was wrong? Thanks, James -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Did you ever get this issue resolved?
Hi Tom, Sorry, that was my first post on Google Groups. It seems I created a new thread instead of replying to: http://groups.google.com/group/django-users/browse_thread/thread/6dd8777e19f06de8/ I have since resolved my issue but don't think Jonathan has. Thanks, James --- On Mar 19, 12:24 pm, Tom Evans wrote: > On Fri, Mar 19, 2010 at 10:59 AM, James wrote: > > Hi, > > > I have come across the same problem as you describe. > > Did you resolve the issue? > > If so, what was wrong? > > > Thanks, > > > James > > Perhaps some context about 'the same problem' is required. No-one has > a clue what you are talking about - I mean seriously, re-read your > email, how can anyone answer that? > > HTH > > 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Arrays
Hi, I am struggling to get a piece of code working. I've looked at it too much and now can't see what im doing wrong. Anyone have any ideas? The error is as follows: Type Error string indices must be integers - (if ids['m'['manufacturer__id']] is not m['manufacturer__id']: ) Code: tmp_manufacturers = Product.objects.filter(category=category).values( 'manufacturer__title', 'manufacturer__slug', 'manufacturer__id' ).distinct() manufacturers = {} for m in tmp_manufacturers: ids = {} if ids['m'['manufacturer__title']] is not m['manufacturer__title']: ids.append(m['manufacturer__title']) manufacturers.append({ 'title': m['manufacturer__title'], 'slug': m['manufacturer__slug'], 'id': m['manufacturer__id'], 'total_products': Product.objects.filter( category=category, manufacturer__slug=m['manufacturer__slug'] ).count() }) Also, does anyone have any decent documentation on arrays? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Arrays
Hi, Thanks for this, it's helped me a lot. I will see if I can muddle through the next part. My my had just gone completely blank with this. Going to get some fresh air first. Thanks again! --- On 22 Mar, 11:38, Daniel Roseman wrote: > On Mar 22, 11:19 am, James wrote: > > > > > Hi, > > > I am struggling to get a piece of code working. > > I've looked at it too much and now can't see what im doing wrong. > > > Anyone have any ideas? The error is as follows: > > Type Error > > string indices must be integers - (if ids['m'['manufacturer__id']] is > > not m['manufacturer__id']: ) > > > Code: > > > tmp_manufacturers = Product.objects.filter(category=category).values( > > 'manufacturer__title', 'manufacturer__slug', > > 'manufacturer__id' > > ).distinct() > > > manufacturers = {} > > for m in tmp_manufacturers: > > ids = {} > > > if ids['m'['manufacturer__title']] is not > > m['manufacturer__title']: > > ids.append(m['manufacturer__title']) > > manufacturers.append({ > > 'title': m['manufacturer__title'], > > 'slug': m['manufacturer__slug'], > > 'id': m['manufacturer__id'], > > 'total_products': Product.objects.filter( > > category=category, > > manufacturer__slug=m['manufacturer__slug'] > > ).count() > > }) > > > Also, does anyone have any decent documentation on arrays? > > Firstly, this is not an array, or even the Python equivalent (a list), > but a dictionary. If you want documentation on these, you should look > at the excellent Python docs (eg the reference on standard types > athttp://docs.python.org/library/stdtypes.htmlor the tutorial on > datastructures athttp://docs.python.org/tutorial/datastructures.html). > > Secondly, your code has at least one syntax error, but even without > those, it will always fail because of its logic errors. The initial > syntax error should be obvious in the line of code you show: you have > quotes around the 'm', ie referring to the string 'm', when you just > want to refer to the dictionary m, without quotes. > > But even fixed, that line makes no sense. Firstly, do not use 'is' or > 'is not' for comparisons. That checks for **identity**, which is a > completely different thing from **equality**. You should use != > instead. And then ask yourself how that line could ever be True. You > have just set ids to a blank dictionary, so there is no such thing as > ids[anything]. That line will now always fail with an IndexError. > > Then, note that both 'ids.append()' and 'manufacturers.append()' will > fail with AttributeErrors, because these are both dictionaries, not > lists, and so have no append function. > > Perhaps you should explain exactly what you're trying to achieve, with > an example of the expected output, and we should be able to help in > more detail. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Selected option in bounded ModelChoiceField
I have created a bounded ModelChoiceField like this : Model: -- class Project(models.Model): name = models.CharField() class Staff(models.Model): name = models.CharField() project = models.ForeignKey(Project) Forms: -- class StaffForm(newforms.Form): name = forms.CharField() project = models.ModelChoiceField(Project.objects.all()) Views: - def StaffView(request): . staff = Staff.objects.get(pk=1) # assume this record exist in the db data = {'name':staff.name , 'project':staff.project} form = StaffForm(data) # a bounded form return render_to_response('template.html', {'form':form}) But I can not set selected="selected" in in the View output. I know that I can use unbounded form and initial parameter but I guess I need bounded Form in my scenario. I tried many different things with no success to show current project in the selection box of StaffForm.project. I am suspicious that django by design, do not want me to use bounded Form to initiate ChoiceField / ModelChoiceField in the view or may be I am wrong. But I use it many times in admin site using many to many and many to one relations but I could not simulate it myself yet. I would appreciate any help regarding this issue. With Regards. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Just learning the ropes with Django and authentication
I am trying to figure out if there is a way to used the Django built in login page (the one used to get into the administration pages) and link that to my own site. I am also just beginning in the website business as well. Does anyone have any suggestions, or anyway that I can better understand the template system they used to create that login information. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Just learning the ropes with Django and authentication
Ok great, thank you very much for that input I will start there. On Apr 1, 8:24 pm, Jeremy Sandell <[EMAIL PROTECTED]> wrote: > Probably the best way to understand how it works is to check the > source. under django/contrib/admin/views/decorators.py is the view > (_display_login_form), and under django/contrib/admin/templates/admin/ > login.html is the form itself. > > I'd also suggest looking at django/contrib/auth/ for futher insight as > to what's going on there. > > Hope this helps. > > On Mar 31, 11:26 pm, James <[EMAIL PROTECTED]> wrote: > > > I am trying to figure out if there is a way to used the Django built > > in login page (the one used to get into the administration pages) and > > link that to my own site. I am also just beginning in the website > > business as well. Does anyone have any suggestions, or anyway that I > > can better understand the template system they used to create that > > login information. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Setting up fixture on model with ForeignKey
Hi, I'm having some trouble setting up a fixture for a model (Dataset) that has a many-to-one relation with another model, DataSource. My initial try at this was to put "datasource_id": "1" (the "1" points to a datasource fixture in another file) in the dataset fixture, but that results in "Problem installing fixture '/dev/myproject/myapp/fixtures/ datasets.json': Dataset has no field named u'datasource_id'". I initially thought that the datasource_id field in the db wasn't being created, but a look at the generated sql as well as a peek at the database itself shows this not to be the case. The error instead seems to refer to the model itself, which has the declaration: "datasource = models.ForeignKey(DataSource)" I tried changing the fixture line to "datasource": "1", but this results in the stack trace below. Does anyone know how to set up this fixture properly? Thanks, James Traceback (most recent call last): File "manage.py", line 11, in ? execute_manager(settings) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 1669, in execute_manager execute_from_command_line(action_mapping, argv) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 1583, in execute_from_command_line action_mapping[action](args[1:], int(options.verbosity)) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 1306, in test failures = test_runner(app_list, verbosity) File "/usr/lib/python2.4/site-packages/django/test/simple.py", line 82, in run_tests result = unittest.TextTestRunner(verbosity=verbosity).run(suite) File "/usr/lib/python2.4/unittest.py", line 696, in run test(result) File "/usr/lib/python2.4/unittest.py", line 428, in __call__ return self.run(*args, **kwds) File "/usr/lib/python2.4/unittest.py", line 424, in run test(result) File "/usr/lib/python2.4/unittest.py", line 428, in __call__ return self.run(*args, **kwds) File "/usr/lib/python2.4/unittest.py", line 424, in run test(result) File "/usr/lib/python2.4/unittest.py", line 428, in __call__ return self.run(*args, **kwds) File "/usr/lib/python2.4/unittest.py", line 424, in run test(result) File "/usr/lib/python2.4/unittest.py", line 428, in __call__ return self.run(*args, **kwds) File "/usr/lib/python2.4/unittest.py", line 424, in run test(result) File "/usr/lib/python2.4/unittest.py", line 281, in __call__ return self.run(*args, **kwds) File "/usr/lib/python2.4/site-packages/django/test/testcases.py", line 49, in run self.install_fixtures() File "/usr/lib/python2.4/site-packages/django/test/testcases.py", line 39, in install_fixtures management.flush(verbosity=0, interactive=False) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 693, in flush sql_list = get_sql_flush() File "/usr/lib/python2.4/site-packages/django/core/management.py", line 359, in get_sql_flush statements = backend.get_sql_flush(style, _get_table_list(), _get_sequence_list()) File "/usr/lib/python2.4/site-packages/django/core/management.py", line 68, in _get_table_list cursor = connection.cursor() File "/usr/lib/python2.4/site-packages/django/db/backends/ postgresql_psycopg2/base.py", line 50, in cursor cursor = self.connection.cursor() psycopg2.InterfaceError: connection already closed --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Setting up fixture on model with ForeignKey [IGNORE]
Never mind. Forgot to reference the fixture in my test. jh On Apr 20, 10:28 am, James <[EMAIL PROTECTED]> wrote: > Hi, > > I'm having some trouble setting up a fixture for a model (Dataset) > that has a many-to-one relation with another model, DataSource. My > initial try at this was to put "datasource_id": "1" (the "1" points to > a datasource fixture in another file) in the dataset fixture, but that > results in > "Problem installing fixture '/dev/myproject/myapp/fixtures/ > datasets.json': Dataset has no field named u'datasource_id'". I > initially thought that the datasource_id field in the db wasn't being > created, but a look at the generated sql as well as a peek at the > database itself shows this not to be the case. The error instead seems > to refer to the model itself, which has the declaration: > > "datasource = models.ForeignKey(DataSource)" > > I tried changing the fixture line to "datasource": "1", but this > results in the stack trace below. Does anyone know how to set up this > fixture properly? > > Thanks, > James > > Traceback (most recent call last): > File "manage.py", line 11, in ? > execute_manager(settings) > File "/usr/lib/python2.4/site-packages/django/core/management.py", > line 1669, in execute_manager > execute_from_command_line(action_mapping, argv) > File "/usr/lib/python2.4/site-packages/django/core/management.py", > line 1583, in execute_from_command_line > action_mapping[action](args[1:], int(options.verbosity)) > File "/usr/lib/python2.4/site-packages/django/core/management.py", > line 1306, in test > failures = test_runner(app_list, verbosity) > File "/usr/lib/python2.4/site-packages/django/test/simple.py", line > 82, in run_tests > result = unittest.TextTestRunner(verbosity=verbosity).run(suite) > File "/usr/lib/python2.4/unittest.py", line 696, in run > test(result) > File "/usr/lib/python2.4/unittest.py", line 428, in __call__ > return self.run(*args, **kwds) > File "/usr/lib/python2.4/unittest.py", line 424, in run > test(result) > File "/usr/lib/python2.4/unittest.py", line 428, in __call__ > return self.run(*args, **kwds) > File "/usr/lib/python2.4/unittest.py", line 424, in run > test(result) > File "/usr/lib/python2.4/unittest.py", line 428, in __call__ > return self.run(*args, **kwds) > File "/usr/lib/python2.4/unittest.py", line 424, in run > test(result) > File "/usr/lib/python2.4/unittest.py", line 428, in __call__ > return self.run(*args, **kwds) > File "/usr/lib/python2.4/unittest.py", line 424, in run > test(result) > File "/usr/lib/python2.4/unittest.py", line 281, in __call__ > return self.run(*args, **kwds) > File "/usr/lib/python2.4/site-packages/django/test/testcases.py", > line 49, in run > self.install_fixtures() > File "/usr/lib/python2.4/site-packages/django/test/testcases.py", > line 39, in install_fixtures > management.flush(verbosity=0, interactive=False) > File "/usr/lib/python2.4/site-packages/django/core/management.py", > line 693, in flush > sql_list = get_sql_flush() > File "/usr/lib/python2.4/site-packages/django/core/management.py", > line 359, in get_sql_flush > statements = backend.get_sql_flush(style, _get_table_list(), > _get_sequence_list()) > File "/usr/lib/python2.4/site-packages/django/core/management.py", > line 68, in _get_table_list > cursor = connection.cursor() > File "/usr/lib/python2.4/site-packages/django/db/backends/ > postgresql_psycopg2/base.py", line 50, in cursor > cursor = self.connection.cursor() > psycopg2.InterfaceError: connection already closed --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
newforms, form_for_model, and FilePathField
Hi, Quite new to both Django and python. I'm trying to create a form using form_for_model with a model that has a FilePathField as one of it's attributes. The documentation for FilePathField states that the path parameter is the "absolute filesystem path to a directory from which this FilePathField should get its choices. " My question is, given the implication of choices in the above, does this mean that I should expect form_for_model to output that attribute as a select tag? (It doesn't; it's just a plain text input.) Is that how it worked with the old form framework? If yes, is that how it will eventually work with newforms? Thanks, James --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
***great chance to earn money!***
My name is James Cai from China.And I would like to say I've find some good ways to make business ( trade related ).If you are interested,please offer your email address,so that I can send a plan of it to you.Hope you will be my partner!! My E-mail:[EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: is possible to only select the specified fields?
You matter-of-factly suggest that a ValuesQuerySet is as good as QuerySet. However, the ValuesQuerySet has some fundamental limitations. In particular, the ValuesQuerySet does not have attributes corresponding to the fields in the QuerySet. This makes a ValuesQuerySet completely useless in a template -- quite unlike a regular QuerySet. -james On Aug 30, 5:15 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 8/29/07, Diego pylorca <[EMAIL PROTECTED]> wrote: > > > ok, but this not return aquerySet, return a dictionary :S > > Read the documentation more carefully. Specifically: > > > Returns a ValuesQuerySet - aQuerySetthat evaluates to a list > > of dictionaries instead of model-instance objects. > > And: > > > Finally, note a ValuesQuerySet is a subclass ofQuerySet, so it has all > > methods ofQuerySet. You can call filter() on it, or order_by(), or whatever. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: is possible to only select the specified fields?
I overstated the problem:a ValuesQuerySet is not completely useless, but you lose a lot of the functionality that you would otherwise have with a QuerySet. There is a incongruency between the ValuesQuerySet and the regular QuerySet in that the dictionary contains only string representations of the field values rather than the datatype-representation of the fields themselves -- which is what you get with a QuerySet. In essence the ValuesQuerySet breaks the paradigm of the model from which it is derived. If you try to do anything remotely exotic with your ValuesQuerySet you'll quickly bump into this. The most obvious case is where you have a foreign key data element in your model. Consider the example of when the foreign key refers to a lookup label table. Whereas a queryset will dereference the element's value to give the string label of the of the element's value (i.e., the text from the label table), the same behavour is not mimiced in the ValuesQuerySet, there you only get the numerical value of the element. As another example, you'll note that it is impossible to access meta information from the rows of a ValuesQuerySet (again because each row is just a flat dictionary, rather than a representation of the model). cheers, james On Sep 18, 5:22 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 9/19/07, James <[EMAIL PROTECTED]> wrote: > > > > > You matter-of-factly suggest that a ValuesQuerySet is as good as > > QuerySet. However, the ValuesQuerySet has some fundamental > > limitations. In particular, the ValuesQuerySet does not have > > attributes corresponding to the fields in the QuerySet. This makes a > > ValuesQuerySet completely useless in a template -- quite unlike a > > regular QuerySet. > > It was said matter-of-factly because it's true. How is ValuesQuerySet > useless in a template? It returns a list of dictionaries; the template > syntax can iterate over lists, and dictionary keys are one of the > lookup schemes. As long as you're not referencing an attribute that > isn't contained in the ValueQuerySet, moving from a QuerySet to a > ValuesQuerySet shouldn't even require a change in template. > > 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Out of range value
MySQL's int column is 4 bytes long. If you need to go (2^32) - 1 is the largest value that will fit in an unsigned int and (2^31) - 1 is the largest that will fit in a signed int. This is because 2^32, in binary, is a 1 with 32 zeroes after it--likewise 2^31 is a 1 with 31 zeroes after is. Subtracting 1 from those number makes them 32 or 31 bits wide, all containing 1s. If you need larger numbers, you need a bigint column. Also, int(12), int(13), int(14), etc. all have the same range. The number just tells MySQL to left-pad the number with zeros to the specified length when returning it in a query. MySQL documentation page here: http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html If anything about my explanation isn't clear, I can try to clarify for you. --James Nader wrote: > Hallo, > > I have a model in which one field value can be a large integer value > (from 2^0=1 till 2^32=4294967296). > > poolMaskID = models.IntegerField(choices=[(pow(2,elm), '2^%s=%s' % > (elm, pow(2,elm))) > for elm in range(33)]) > > The definition of attribute in MySQL database is: > > poolMaskID int(11) > > If want to try to input the 2^31 or 2^32 I get the next 'Warning': > > Out of range value adjusted for column 'poolMaskID' at row 1! > > I have tried to change the attribute definition in MySQL database and > have changed the "postMaskID" to int(12). int(16). This was > without any result. I have once used 'models.Positive.IntegerField' > in place of 'models.IntegerField'. The problem has been stayed the > same. > Does somebody any idea about this problem? > > Regards, > Nader --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
UK DJANGO/Python Developer positions (Contract/Permanent)
Hi There, I hope this is Ok to post this to this group - I've seen other job ads here so I'm assuming it is. DJANGO/Python Developer position (Contract/Permanent) Oxford, UK (potential to do some telecommuting) We are currently expanding our in-house team to take forward the development of an exciting Web 2.0 business networking platform and have both permanent and contract opportunities for django developers. We are a small team which is working on a functionally complex Web 2.0 networking platform and are looking for talented developers to play an important role in this innovative project. The people we're looking for will have experience in requirements analysis, design, coding and unit testing of scalable, distributed, fault-tolerant applications in Web environments. You will also need the following: - Development experience using Python or DJANGO - Experience of at least one other OO language such as Java or C++ - Hands-on knowledge of relational databases (preferably PostgreSQL) - Basic LINUX system administration skills - Experience of working with Subversion or other source control systems If you are interested in this challenging project then please give me (James) a ring on 01865 339395 (I don't check my googlemail very often) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Making translations appear without server restart?
Hello, I have developed a Django application that provides an interface for editing gettext message files in a Django project. It accepts translations from English to a different language, merges those translations with the existing message catalog, then does a recompile on the message files. Unfortunately, the new translations don't immediately show in the site pages; it seems a server restart is required. I tried calling translation.deactivate_all() and then calling translation.activate() from my code but apparently only a restart does the trick. Does anyone know how to make Django's i18n machinery pick up new translations as soon as they are generated? Thanks, James --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Making translations appear without server restart?
On Dec 19, 4:07 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > Hi, > > > I tried calling translation.deactivate_all() and then calling > > translation.activate() from my code but > > apparently only a restart does the trick. > > > Does anyone know how to make Django's i18n machinery pick up new > > translations as soon as they are generated? > > Try something like this. Hopefully this will clear out the global > translations and force a reload: > > translation.deactivate_all() > globals _translations > _translations = {} > translation.activate() > Thanks, Rajesh, but this doesn't work. You've put me on the right track though: I just need to find a reliable way to clear out that _translations global. With the above code, printing out the _translations dictionary inside the activate() method shows it to still be populated, which prevents the translation() method from reloading the message files from disk. James --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Making translations appear without server restart?
Sorry, I replied to your first post before I saw this one.. On Dec 19, 4:28 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > Hi again, > On second thoughts, I think you will need to do more work than this > since this will only force a reload of the translations within the > current process. Other processes will have their own global > _translations cache and without further work those won't get reloaded. > If you try the above idea and it seems to work for one process (the > process of the request/view in which you run the above code), consider > the following: As I mentioned in my other post, it doesn't work for the one process. I don't know if I really need to bother with the timestamp as you outline below. I want the message files reloaded no matter what whenever someone submits new translations using my app. I'm probably understanding Python's 'global' declaration imperfectly, but from the print statements I have littered about in both my code and Django's, the _translations object I'm referring to in my view code doesn't seem to be the same object being referred to in trans_real.py. still looking, James > > Maintain the timestamp (say, catalog_change_timestamp) of when the > translation catalog last changed in a resource that all processes can > access (e.g. memcache, DB, or filesystem). Secondly, modify the above > snippet like this: > > translation.deactivate_all() > globals _translations > _translations = {} > from datetime import datetime > globals _translations_loadtime > _translations_loadtime = datetime.now() > translation.activate() > > Lastly, add a custom middleware that checks the global > _translations_loadtime against catalog_change_timestamp and rerun the > above snippet. This should reset the translations in every process > that has not yet loaded your modified language catalog. > > FAT DISCLAIMER: I have not tested any of this and am not at all sure > if this work. So, please take it with lots of salt. > > -Rajesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Making translations appear without server restart?
On Dec 19, 7:47 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > > As I mentioned in my other post, it doesn't work for the one process. > > My previous code snippet missed an important statement. You will need > to first get an instance of _transactions from trans_real.py before > you declare it to be global. So, check if something like this helps: > > from django.utils import translation > translation.deactivate_all() > _translations = translation.trans_real._translations # <--- Note this > globals _translations > _translations = {} > from datetime import datetime > globals _translations_loadtime > _translations_loadtime = datetime.now() > translation.activate() > Tried the above, but _translations is still getting repopulated somewhere and won't pick up the new translations. > > James Bennett has a nice article about server startup in which one > section talks about registries. It might be worth it to peruse that > even though it doesn't directly address this problem. > > See:http://www.b-list.org/weblog/2007/nov/05/server-startup/ Useful information, thanks. James > > -Rajesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Feeds as a web service
Anyone thought of using Django's feeds to supply XML in a sort of simple, read-only, web service kinda way? :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
order_by()
Hi, according to the docs, I should be able order by a field in another table like below, but for some reason I can't get it to work. I'm new to django. Thought I'd give it a shot as I've primarily been using Ruby on Rails. views.py: products = Product.objects.order_by('products_brand.name', 'products_product.name') models.py: class Brand(models.Model): name = models.CharField(maxlength=192) link = models.CharField(maxlength=192) class Product(models.Model): category = models.ForeignKey(Category) brand = models.ForeignKey(Brand) name = models.CharField(maxlength=192) description = models.TextField() link = models.CharField(maxlength=384) Any ideas as to what I'm doing wrong, or do the docs need fixing? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: order_by()
Just for the record, see: http://code.djangoproject.com/ticket/2076 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Django + fastCGI + bluehost
Carlos, I have django running on my bluehost account with fcgi. The best notes on how to get things running I have found are here: http://wiki.dreamhost.com/index.php/Django Bluehost is setup pretty much the same as dreamhost. I recommend Bluehost for the price and support. James Carlos Yoder wrote: > Hey there, FP and all that :-) > > Does anyone of you have experience with running Django on Bluehost? > > They don't support mod_python, but according to their support people, > they do FastCGI. I include their reply, to see if it helps: > > > We do not have mod_python installed, but we do have Fast CGI on all of > our servers. The following are a list of mods installed on our > servers which may differ slightly between versions: > > Apache/1.3.34 (Unix) mod_fastcgi/2.4.2 mod_auth_passthrough/1.8 > mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635 > mod_ssl/2.8.25 OpenSSL/0.9.7a PHP-CGI/0.1b > - > > Is there anything else I should ask, or this setup could run Django > successfully? Thanks a lot! > > -- > Carlos Yoder > [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: Static files is not loading while deploying the project to AWS ec2
It sounds like nginx doesn't know where your static files are being served from. If you don't want to bother with NGINX you can use Whitenoise. Django doesn't serve staticfiles in production; something that isn't overly apparent. You still need something like apache or nginx or whitenoise to serve static files in production. On Saturday, November 5, 2022 at 1:35:31 AM UTC-6 nishan...@gmail.com wrote: > Hi all, > > I deployed the django project to AWS ec2 instance using nginx and gunicorn > but the static file is not loading at all. > > Can someone suggest where did I do wrong? > > Note - I've not created Profile before deploying > > Here is my settings.py file > STATIC_URL = 'static/' > STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') > STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),) > > Project URl - http://54.242.38.208/ > Github- https://github.com/Nishant-Sagar/BaskinSolar > > Thank you for your help, > Nishant > > > > > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b2af5c41-3202-4bd4-b195-777a80f144e1n%40googlegroups.com.
Re: Django multistep form
Hi, Can you also link the relevant urls.py please? Thanks! On Monday, November 7, 2022 at 2:58:01 AM UTC-7 uobod...@gmail.com wrote: > I have a multi-step form that is 3 steps but it has 4 forms. In the first > form, the user has to choose from two choices. The user’s first form > choices will determine the next form that will be displayed. > The code is not working as it should. The first form choices are radio > buttons which are commercial and private. If the user chooses commercial it > brings the next form and if the user chose private it brings a different > form. My problem is that if the user chose private or commercial it brings > the same form. > Views.py > template > forms.py > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f782c4e7-5d09-42d9-b3e7-a177ecce8368n%40googlegroups.com.
Re: HOW TO GET DJANGO MODELS FIELD VALUE FROM MODEL OBJECT IN TEMPLATE TAGS-DJANGO
Hi; There's a method you're supposed to override in your views (inherit from Views) to do what you want, it's called "get_context_data". This method will pump whatever data you send to it into your template tags. On Sunday, November 6, 2022 at 4:15:35 AM UTC-7 rani...@gmail.com wrote: > my models.py > > class Locations(models.Model): > region = models.ForeignKey(Regions, > on_delete=models.CASCADE,blank=True,null=True) > name = models.CharField(max_length=255) > active_flag = models.BooleanField(default=True) > created_at = models.DateTimeField(auto_now_add = True) > updated_at = models.DateTimeField(auto_now=True) > > def __str__(self): > return self.name > > > class Regions(models.Model): > region_name = models.CharField(max_length=255) > working_hours_per_day = models.CharField(max_length=255,null=True) > days_per_week = models.CharField(max_length=255,null=True) > hours_per_week = models.CharField(max_length=255,null=True) > week_per_month = models.CharField(max_length=255,null=True) > hours_per_month = models.CharField(max_length=255,null=True) > days_per_year = models.CharField(max_length=255,null=True) > weeks_per_year = models.CharField(max_length=255,null=True) > active_flag = models.BooleanField(default=True) > show_flag = models.BooleanField(default=True) > created_at = models.DateTimeField(auto_now_add = True) > updated_at = models.DateTimeField(auto_now=True) > > def __str__(self): > return self.region_name > > > views.py > > def center(request): > locations = Locations.objects.select_related('region') > td_serializer = LocationSerializer(locations,many=True) > x=td_serializer.data > data = { > 'td':td_serializer.data, > #'centers':center_serializer.data, > } > return response.Response(data,status.HTTP_200_OK) > > > > > template: > > fetchLocationsList(){ > this.$axios.$post('/projects/chcenter',config).then(response => { > if(response){ > this.locations =response.td; > for(let i=0;i this.x=this.locations[i].name > this.y=this.locations[i].region > this.z=this.y + "-" +this.x > this.result.push(this.z) > > > How to get region_name ? > > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/be86acab-55f2-4ce2-a1b5-930b1b5c77aen%40googlegroups.com.
Can't Load Django Dev Sever
Hello, I can't connect to my django web server and it's all my fault. I turned on SECURE_HSTS_SECONDS to 60 by accident in development, in another project, a few days ago. Now I can not load http://127.0.0.1:8000 on FireFox and I don't know how to fix it. And yes runserver is set to that port/ip and yes I can connect in incognito mode and in chrome. I have cleared all caches and cookies. Thanks very much! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/29a776ee-e840-45ad-885b-3f5752c9466fn%40googlegroups.com.
Re: Can't Load Django Dev Sever
Thanks so much! I thought I was doing something wrong when I deleted the cache and cookies and nothing happened. Just needed to restart my computer after clearing the cache/cookies; may have been a firefox bug! Thanks again for you help! Best Regards, -James Logan On Friday, November 11, 2022 at 1:01:56 AM UTC-7 ahmadabd...@gmail.com wrote: > Try clearing cache and cookies for 127.0.0.1 > > On Fri, Nov 11, 2022, 8:36 AM Mike Dewhirst wrote: > >> Try visiting http://localhost:8000 instead >> >> No guarantees and I'm not going to test it myself ;-) >> >> >> >> >> >> -- >> (Unsigned mail from my phone) >> >> >> >> Original message >> From: James >> Date: 11/11/22 16:13 (GMT+10:00) >> To: Django users >> Subject: Can't Load Django Dev Sever >> >> Hello, >> >> I can't connect to my django web server and it's all my fault. I turned >> on SECURE_HSTS_SECONDS to 60 by accident in development, in another >> project, a few days ago. >> >> Now I can not load http://127.0.0.1:8000 on FireFox and I don't know how >> to fix it. And yes runserver is set to that port/ip and yes I can connect >> in incognito mode and in chrome. >> >> I have cleared all caches and cookies. >> >> Thanks very much! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/29a776ee-e840-45ad-885b-3f5752c9466fn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/29a776ee-e840-45ad-885b-3f5752c9466fn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users...@googlegroups.com. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/636dfb79.050a0220.368b6.8b8fSMTPIN_ADDED_MISSING%40gmr-mx.google.com >> >> <https://groups.google.com/d/msgid/django-users/636dfb79.050a0220.368b6.8b8fSMTPIN_ADDED_MISSING%40gmr-mx.google.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a1f86756-0bd9-4743-a7fb-8c32d32b709cn%40googlegroups.com.
Re: Apps aren't loaded yet exception when trying to run migrate Django oscar
I fixed something similar once by having the model that was causing the problem be set to abstract in its class meta. O you need to "makemigrations user" if you've opened up the usermodel and changed a lot of stuff (also had that problem before) Hope these simple solutions work! On Friday, November 11, 2022 at 11:38:44 AM UTC-7 imper...@gmail.com wrote: > I'm trying to get to know django-oscar and this is what happens when i try > to make migrations : > Traceback (most recent call last): > File "C:\Users\Leslie\Desktop\GrandmarketV3\Grandmarket\manage.py", line > 22, in > main() > File "C:\Users\Leslie\Desktop\GrandmarketV3\Grandmarket\manage.py", line > 18, in main > execute_from_command_line(sys.argv) > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\core\management\__init__.py", > > line 419, in execute_from_command_line > utility.execute() > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\core\management\__init__.py", > > line 363, in execute > settings.INSTALLED_APPS > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\conf\__init__.py", > > line 82, in __getattr__ > self._setup(name) > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\conf\__init__.py", > > line 69, in _setup > self._wrapped = Settings(settings_module) > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\conf\__init__.py", > > line 170, in __init__ > mod = importlib.import_module(self.SETTINGS_MODULE) > File > "C:\Users\Leslie\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", > > line 126, in import_module > return _bootstrap._gcd_import(name[level:], package, level) > File "", line 1050, in _gcd_import > File "", line 1027, in _find_and_load > File "", line 1006, in > _find_and_load_unlocked > File "", line 688, in _load_unlocked > File "", line 883, in exec_module > File "", line 241, in > _call_with_frames_removed > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Grandmarket\Grandmarket\settings.py", > line 18, in > from oscar.core.compat import get_user_model > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\oscar\core\compat.py", > > line 6, in > from django.contrib.auth.models import User > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\contrib\auth\models.py", > > line 3, in > from django.contrib.auth.base_user import AbstractBaseUser, > BaseUserManager > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\contrib\auth\base_user.py", > > line 48, in > class AbstractBaseUser(models.Model): > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\db\models\base.py", > > line 108, in __new__ > app_config = apps.get_containing_app_config(module) > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\apps\registry.py", > > line 253, in get_containing_app_config > self.check_apps_ready() > File > "C:\Users\Leslie\Desktop\GrandmarketV3\Market\lib\site-packages\django\apps\registry.py", > > line 136, in check_apps_ready > raise AppRegistryNotReady("Apps aren't loaded yet.") > django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. > > This is my settings.py file: > import os > import oscar > > import django > from django.conf import settings > from oscar.core.compat import get_user_model > from oscar.defaults import * > from pathlib import Path > > # Build paths inside the project like this: BASE_DIR / 'subdir'. > BASE_DIR = Path(__file__).resolve().parent.parent > > > > # Quick-start development settings - unsuitable for production > # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ > > # SECURITY WARNING: keep the secret key used in production secret! > SECRET_KEY = > > # SECURITY WARNING: don't run with debug turned on in production! > DEBUG = True > > ALLOWED_HOSTS = [] > > > # Application definition > > INSTALLED_APPS = [ > 'django.contrib.admin', > 'django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.messages', > 'django.contrib.staticfiles', > 'django.contrib.sites', > 'django.contrib.flatpages', > > 'Grandmarket.' > 'oscar.config.Shop', > 'oscar.apps.analytics.apps.AnalyticsConfig', > 'oscar.apps.checkout.apps.CheckoutConfig', > 'oscar.apps.address.apps.AddressConfig', > 'oscar.apps.shipping.apps.ShippingConfig', > 'oscar.apps.catalogue.apps.CatalogueConfig', > 'oscar.apps.catalogue.reviews.apps.CatalogueReviewsConfig', > 'oscar.apps.communication.apps.CommunicationConfig', > 'oscar.apps.partner.apps.PartnerConfig', > 'oscar.apps.basket.apps.BasketConfig', > 'oscar.apps.payment.apps.PaymentConfig', > 'oscar.apps.offer.apps.OfferConfig', > 'oscar.apps.order.apps.OrderConfig', > 'oscar.apps.customer.apps.C
Favicon Error While Using Inline Favicon
Hello, So everything is working but I get errors in my logs that I could just suppress, but I would rather just fix the error. NGINX Error: 775#775: *2421 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory) Django Error (warning): Not Found: /favicon.ico So here's where things get interesting. I don't want to serve a favicon this way because I can't do a media query. I inline my favicon such that I can do a media query to detect light/dark mode and change the color of the favicon accordingly. If I save the inline code as a svg the media query will not work. Is there a way around this, or I am forced to choose from implementing the media query at the nginx layer or not having my theme-responsive favicon? Thanks very much! I hope this is interesting to someone because I think it's super neat to have the favicon change color based on a media query. Best Regards, -James Logan -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/649de193-8817-402d-aa7c-39eed5737de2n%40googlegroups.com.
Re: Custom user model password is not hashed
Yup, 100% correct. Glad to hear you fixed it. Custom user models that inherit from the abstractbaseuser class can be a little tricky at first. On Friday, November 13, 2015 at 5:41:09 AM UTC-7 benjamin...@gmail.com wrote: > The problem was, when creating a custom user, one has to define a custom > model form and model admin that handles the password properly. After that > it was solved. > > Thank you. > > On Thu, Nov 12, 2015 at 9:25 PM, Andreas Kuhne > wrote: > >> Try to debug and check what your password value is after the >> set_password() statement. Also have you checked the database after trying >> to create a user with the new method? It should be hashed in the database. >> This is stuff that should "just work" in django (it's regulated by the >> AbstractBaseUser and is the same that I am using in a project). >> >> You did restart the django shell after changing the code? >> >> 2015-11-12 16:44 GMT+01:00 Benjamin Smith : >> >>> I have changed user.set_password(self.cleaned_data["password"]) to >>> user.set_password(password). >>> But I am getting the same result. >>> >>> On Thu, Nov 12, 2015 at 8:57 PM, Andreas Kuhne >>> wrote: >>> As aRkadeFR says, you seam to have mixed code there The row: user.set_password(self.cleaned_data["password"]) is taken from a form somewhere and won't work. It should instead be : user.set_password(password) I suppose the password is going through to the create method via the kwargs argument at the end of you create method. But if you change like I said, everything should work. Med vänliga hälsningar, Andréas Kühne Software Development Manager Suitopia Scandinavia AB 2015-11-12 16:20 GMT+01:00 aRkadeFR : > Hello, > > I don't quite get the code in your method: ' > MyUserManager.create_user': > user.set_password(self.cleaned_data["password"]) > > You're in your Manager method but call self.cleaned_data ? > > You can set a breakpoint inside your method with pdb to see > what's going on with your fields? > > > On 11/12/2015 04:11 PM, Benjamin Smith wrote: > > I have my own custom User model, and its own Manger too. > > Models: > > class MyUser(AbstractBaseUser, PermissionsMixin): > email = models.EmailField(max_length=255, unique=True) > first_name = models.CharField(max_length=35) > last_name = models.CharField(max_length=35) > username = models.CharField(max_length=70, unique=True) > date_of_birth = models.DateField() > is_active = models.BooleanField(default=True) > is_admin = models.BooleanField(default=False) > > @property > def is_staff(self): > return self.is_admin > > def get_full_name(self): > return ('%s %s') % (self.first_name, self.last_name) > > def get_short_name(self): > return self.username > > objects = MyUserManager() > USERNAME_FIELD = 'email' > REQUIRED_FIELDS = ['first_name', 'last_name', 'username', > 'date_of_birth'] > > > Manager: > > class MyUserManager(BaseUserManager): > def create_user(self, email, first_name, last_name, username, > date_of_birth, password=None, **kwargs): > if not email: > raise ValueError('User must have an email address') > > user = self.model( > email=self.normalize_email(email), > first_name=first_name, > last_name=last_name, > username=username, > date_of_birth=date_of_birth, > **kwargs > ) > user.set_password(self.cleaned_data["password"]) > user.save(using=self._db) > return user > > def create_superuser(self, email, first_name, last_name, username, > date_of_birth, password, **kwargs): > user = self.create_user( > email, > first_name=first_name, > last_name=last_name, > username=username, > date_of_birth=date_of_birth, > password=password, > is_superuser=True, > **kwargs > ) > user.is_admin = True > user.save(using=self._db) > return user > > > Everything works when creating a new user without any errors. But when > I try to login I can't. So I checked the user's email and password to > confirm. Then I noticed that the password is displayed as plain text (eg. > *strongpassword)*, and when changed the admin form to get the hashed > password using *ReadOnlyPasswordHashField()* I get an error inside > the password field, even though I used *set_password()* for the > Manger inside the *create_us
Re: using forloop.counter to access data
On Wednesday, March 21, 2012 8:47:23 AM UTC-4, larry@gmail.com wrote: > > This is probably a stupid newbie question > > I want to access a column of data in a row using forloop.counter, but > I cannot get it to work. > > In my test code, if I display {{ forloop.counter }} I get 2 > If I display {{ headers.0.2 }} I get ToolType > But if I display {{ headers.0.forloop.counter }} I get nothing > > What is the proper syntax for this? > the forloop.counter and friends will simply give you information about the iteration, it won't give you any information about the data in the queryset (I'm assuming this is what you mean when you say column). Here are the docs https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#for If you want to access the column of data, assuming it's referenced from a model, just the attribute of that model. If you passed in a list to the template, you just use the django "dot" look-up syntax. Docs here: https://docs.djangoproject.com/en/dev/ref/templates/api/#render So, let's say your list looks like a = [1,2,3,4] and in your context it looks like c ={'a':a} if you want to reference the second "column" (index really) you would just do {{ a.1 }}, this will render the number "2". You would use forloop.counter for something like, let's say we passed in hundreds of such lists. And, for whatever reason, once we reach the 100th iteration, we want the loop to end. Then we would do this: {% for list in list_of_lists %} {{ list.1 }} {% if forloop.counter == 100 %} {% endfor %} {% endif %} {% if forloop. last %} {% endfor %} {% endif %} The last if / endif is not necessary, but I wanted to show some control flow using the forloop context. In fact, I wouldn't do this at all at the template level. I would instead limit the queryset to 100 when creating the queryset and pass that in and then just iterate over it like any other queryset, but I think you see what I mean. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/HsGotgeD_XkJ. 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: using forloop.counter to access data
On Wednesday, March 21, 2012 10:41:08 AM UTC-4, larry@gmail.com wrote: > > On Wed, Mar 21, 2012 at 7:53 AM, James <> wrote: > > > > > > On Wednesday, March 21, 2012 8:47:23 AM UTC-4, Larry@gmail.comwrote: > >> > >> This is probably a stupid newbie question > >> > >> I want to access a column of data in a row using forloop.counter, but > >> I cannot get it to work. > >> > >> In my test code, if I display {{ forloop.counter }} I get 2 > >> If I display {{ headers.0.2 }} I get ToolType > >> But if I display {{ headers.0.forloop.counter }} I get nothing > >> > >> What is the proper syntax for this? > > > > > > the forloop.counter and friends will simply give you information about > the > > iteration, it won't give you any information about the data in the > queryset > > Yes, I realize that. I am using it withing a loop to try an access a > specific item of data. The code I showed was just an example from one > iteration of the loop. > > > (I'm assuming this is what you mean when you say column). > > > > Here are the > > docs > https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#for > > > > If you want to access the column of data, assuming it's referenced from > a > > model, just the attribute of that model. If you passed in a list to the > > template, you just use the django "dot" look-up syntax. > > Perhaps my question wasn't clear. I have a list called headers. From > within a for loop I want the n'th item from the first row. In the loop > I am trying to access {{ headers.0.forloop.counter }} but I get no > value from that. But if I hard code the number (as a test), e.g.: {{ > headers.0.2 }} then I do get the value. > With regards to your reply: Yes, I realize that. I am using it withing a loop to try an access a > specific item of data. The code I showed was just an example from one > iteration of the loop. You can't use forloop and friends in the manner you attempting to use it. It's The reason is, headers.0 has no attribute named "forloop" The best that you could do here, in this situation, is to create a custom filter and pass it forloop.counter as variable like so: {{ headers.0|forloop.counter }} You will of course have to write that filter out first, register it, and install it in the template. I'm still not sure if this is the right approach. Why not just iterate over the list itself, if you want to print the nth item within the list? Or, structure the list/queryset from the view such that you don't have to do such acrobatics. But if I hard code the number (as a test), e.g.: {{ > headers.0.2 }} then I do get the value. This works because headers.0 has an attribute that works by way of the django dot look up. See Tom Evan's post regarding this. It seems to me that you have a list of lists (and not a single list). In which case, you can just iterate over the first list and iterate over the second list. If you need some control flow, just use the standard if / else conditions. But, maybe I'm missing something? Even easier would be to use django's introspect feature and create models based on the tables in the DB, query the DB using the models and create querysets. Then you can access and display the data in a more coherent manner. see the docs here for introspection: https://docs.djangoproject.com/en/dev/howto/legacy-databases/?from=olddocs -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/1F5cm7oGKOMJ. 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: Bus Error: 10 (Intro Tutorial)
I just started receiving the same error "Bus error: 10". I made a small code change and it suddenly appeared. I've reverted but that doesn't seem to matter. Very odd behavior. I'll continue debugging. My settings: Python 2.7.1 OS:X Lion 10.7.3 Django 1.4.0 James Leard On Apr 20, 7:58 am, Tom Evans wrote: > On Thu, Apr 19, 2012 at 5:11 PM, Harald Sigh Andertun > > wrote: > > I'm sorry. Actually that was not the solution. It works sometimes now, which > > it didn't before. I'll attach a screenshot. > > > I'm on mac (OS X Lion). > > A bus error occurs due to unaligned memory access, or access to a non > existent memory address. In the absence of an actual bug (which others > would see), this clearly indicates that one or another of the C > libraries used by python conflicts with it. > > This could happen if you compiled a C library to use with python, like > one of the many python packages that consist of a small C library > (mysql and postgresql DB adaptors, PIL, many others), and use it with > a different python than it was compiled against. > > It probably has very little to do with django - django is pure python > - but with one of the libraries that is used by django or your code. > The solution is simple; remove everything, start from scratch and > recompile/reinstall everything relevant. > > It is probably trickier as OS X does interesting things with python, > and most users end up with a system python and a user python. Making > sure your installed extensions are compiled and used with the right > python is then what is important. > > 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: Bus Error: 10 (Intro Tutorial)
I found the problem. I had overridden __getattr__ and returned self.value which did not yet exist on the object. This caused a maximum recursion depth RuntimeError. I'm still not sure why this became "Bus error: 10", however. James Leard On Apr 23, 1:31 pm, Nikolas Stevenson-Molnar wrote: > I would try reinstalling Python and Django. This seemed to resolve the > issue of the original poster. > > _Nik > > On 4/21/2012 3:18 PM, James wrote: > > > > > > > > > I just started receiving the same error "Bus error: 10". I made a > > small code change and > > it suddenly appeared. I've reverted but that doesn't seem to matter. > > Very odd behavior. > > I'll continue debugging. My settings: > > > Python 2.7.1 > > OS:X Lion 10.7.3 > > Django 1.4.0 > > > James Leard > > > On Apr 20, 7:58 am, Tom Evans wrote: > >> On Thu, Apr 19, 2012 at 5:11 PM, Harald Sigh Andertun > > >> wrote: > >>> I'm sorry. Actually that was not the solution. It works sometimes now, > >>> which > >>> it didn't before. I'll attach a screenshot. > >>> I'm on mac (OS X Lion). > >> A bus error occurs due to unaligned memory access, or access to a non > >> existent memory address. In the absence of an actual bug (which others > >> would see), this clearly indicates that one or another of the C > >> libraries used by python conflicts with it. > > >> This could happen if you compiled a C library to use with python, like > >> one of the many python packages that consist of a small C library > >> (mysql and postgresql DB adaptors, PIL, many others), and use it with > >> a different python than it was compiled against. > > >> It probably has very little to do with django - django is pure python > >> - but with one of the libraries that is used by django or your code. > >> The solution is simple; remove everything, start from scratch and > >> recompile/reinstall everything relevant. > > >> It is probably trickier as OS X does interesting things with python, > >> and most users end up with a system python and a user python. Making > >> sure your installed extensions are compiled and used with the right > >> python is then what is important. > > >> 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: PyPm / Django 1.4?
I use Postgres for this. You will need to install visual studios 2008. Not sure why you said that is an issue. I've never had a problem on several installations. However, pscyopg2 has binaries, that is what I use. >From there you can just virtualnv / pip. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/24bvJyQyqc4J. 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: Handling millions of rows + large bulk processing (now 700+ mil rows)
On Saturday, June 30, 2012 11:10:27 AM UTC-4, Cal Leeming [Simplicity Media Ltd] wrote: > > Hi all, > > As some of you know, I did a live webcast last year (July 2011) on our LLG > project, which explained how we overcome some of the problems associated > with large data processing. > > After reviewing the video, I found that the sound quality was very > poor, the slides weren't very well structured, and some of the information > is now out of date (at the time it was 40mil rows, now we're dealing with > 700+mil rows). > > Therefore, I'm considering doing another live webcast (except this time > it'll be recorded+posted the next day, the stream will be available in > 1080p, it'll be far better structured, and will only last 50 minutes). > > The topics I'd like to cover are: > > * Bulk data processing where bulk_insert() is still not viable (we went > from 30 rows/sec to 8000 rows/sec on bulk data processing, whilst still > using the ORM - no raw sql here!!) > * Applying faux child/parent relationship when standard ORM is too > expensive (allows for ORM approach without the cost) > * Applying faux ORM read-only structure to legacy applications (allows ORM > usage on schemas that weren't properly designed, and cannot be changed - > for example, vendor software with no source code). > * New Relic is beautiful, but expensive. Hear more about our plans to make > an open source version. > * Appropriate use cases for IAAS vs colo with SSDs. > * Percona is amazing, some of the tips/tricks we've learned over. > > If you'd like to see this happen, please leave a reply in the thread - if > enough people want this, then we'll do public vote for the scheduled date. > > Cheers > > Cal > Sounds great! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/CLrrYBziHO4J. 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.
Caching Options
Right now, I'm loading up some data VIA the orm. The nature of the data is fairly complex, somewhere around 10-12 tables are touched per insert and about twice that number referencing static helper tables. For production and day to day use, I've been using django-cache-machine, but I've also been considering Johnny-caching. For this problem though, johnny won't work because the cache would effectively never get hit. As far as Django-Cache-Machine, I don't think it's caching .get type queries. I believe it only caches querysets, and then only when you actually iterate over them. Considering most of my references are .get type queries for this operation, I would think that caching those type of queries would be useful for me during this process. Now, I won't have to go through this that often, maybe once ever four months, but still I think caching some of the queries up front could speed this up. What are peoples thoughts on this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/pvdY4dz4LdgJ. 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.
ModelChoiceFields and verbose names
Hello all: This is my first question posted to this group! I am also a noob, so please be gentle. So, my issue is, I have a ModelForm, which looks like this: class UAssumptionsForm(ModelForm): primary_le = forms.ModelChoiceField(queryset=models.Mortality.objects.none()) secondary_le = forms.ModelChoiceField(queryset=models.Mortality.objects.none()) def __init__(self, *args, **kwargs): self.insured = kwargs.pop('insured') super(ModelForm, self).__init__(*args, **kwargs) morts = self.insured.mortalities.all() self.fields['primary_le'].queryset = morts self.fields['secondary_le'].queryset = morts class Meta: model = models.UAssumptions Now, when I render the form I get two choices for each of the fields I overrode above. This is expected behavior. What I want though is for each object to have a descriptive name, rather than "Mortality object", based on the values of the object itself, so one might have a value of "Caterpillar" and another might have a value of "Seychelles". I'm sure this is a common problem and I apologize in advance. I searched, but being a noob I'm probably not using the right search terms. -- 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: Since Django has its own database schema, can we still use sqlalchemy instead?
On Jan 8, 8:43 am, Venkatraman S wrote: > On Sun, Jan 8, 2012 at 9:49 AM, Chen Xu wrote: > > > Since Django has its own database schema, can we still use sqlalchemy > > instead? > > Just to correct the nomeclature : Django has an ORM, and *NOT* a database > schema. An application has its own schema. > And to answer the 'modified' Q : django's orm is pretty good. (but yes, i > would expect that you can swap it with sqlalchemy, but I havent done it > yet). > > -Vhttp://blizzardzblogs.blogspot.com/ To add to what the above poster said, the blog irrational exuberance has an entire series on django's loose coupling philosophy. This article is on using SQLAlchemy. I've really been considering switching over to jinja based on his articles (since it seems like it won't break anything, other than all my render_to_response and will need to longform the return render). For my money, django's ORM seems to do a pretty good job. I haven't yet said to myself "wow, it would be nice if it did X" but I say that all the time to myself about the templating engine (which is why I'm considering the switch). -- 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.
Groups in Forms
I have a Jquery Notebook that has common options on one tab and more advanced options on another tab. The model referencing this data has both tabs of data and a description field as well. Initially, I broke out the form manually, but I decided that this would be a major pain to write {{ formfield.label }}:{{ formfield }} for each and every single row, not to mention to add in the custom error class for the field when it fails to validate. Then I decided to have three forms, one for each tab and a single field form for description. But, in using forms.Forms you lose Forms.save() and other shortcuts. So, to save back to an existing model, I think, you need to break out each one again. example: m = models(pk=mypk) m.date = form.cleaned_data['date'] and then you would have to do that for each line. This seems inefficient to me. For now, I'm using two model forms, excluding the fields of the opposite tab in the modelform. Example: class TabOne(ModelForm): class Meta: model = models.models exclude = ('stuff_from_tab_two', 'stuff_from_tab_two', 'stuff_from_tab_two', 'stuff_from_tab_two') and then again for TabTwo. My question is: Is it possible to break out a ModelForm into groups for display purposes? It would be handy if in the Meta you could set a "break" attribute that allowed you to break out different areas of the same ModelForm For example, in a model one might have: Class Model(models.Models): field_1 = models.IntegerField() field_2 = models.IntegerField() field_3 = models.IntegerField() field_4 = models.IntegerField() field_5 = models.IntegerField() field_6 = models.IntegerField() field_7 = models.IntegerField() field_8 = models.IntegerField() field_9 = models.IntegerField() field_10 = models.IntegerField() in the ModelForm: class Form(ModelForm): class Meta: break = (('one',field_3), ('two',field_7), ('three',field_10),) form = Form() then to refer to form in a template, where you defined it as 'form':form, in the Context, it would be form['form_one'], form['form_two'], form['form_three']. Basically, the break would create a dictionary appending the name you gave in the first part of the tuple to the name of the form. Or anyway, something like that. For now, I can't see a simple way to break out groups of a form. It seems you have to either use the whole thing as intended or break it up into individual parts in the template. -- 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 - This field is required.What am I missing.
On Jan 22, 5:42 am, Johan wrote: > Hi I have a form that has a required email field. This due to the fact > that the model requires an email. However, I don't display the email > field on the form. So when the post gets back into my view the email > field is empty. I then thought I would do the following just before > the form.is_valid() : > > form = students.forms.StudentForm(request.POST) > form.instance.email=user.email > > User is a session variable which contains the correct email for the > session. The above code however still fail with is_valid. I even > changed the forms clean_email() to return the correct email. But, I > still get 'This field is required'. > > Any help would be appreciated. One: You can change the default behavior of the widget so it is hidden. The email address will come back in the post data (this means you don't mind the email address in the raw html). This also assumes you are using modelforms. Two: Alter the POST data upon return so you add the email address to it. Three: Create the model first (or retrieve the existing model) and do this instead: form = students.forms.StudentForm(request.POST, instance=students_model) Four: Again, assuming you are using model forms, change the email address field to (blank=True, null=True). Once you save the modelform and a model is returned, you can then save the email address directly to the field, eg: model = form.save(commit=False) model.email = email model.save() (it might be you don't have to have null=True if you always do commit = False, I'm not 100% certain) I think any of those should work as a workaround for your problem. -- 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.
Python problem
Hey there, Did first Django app and everything worked find, however my computer crashed and after restoring it each time I try to execute any .py file in command prompt it says syntax error or that the module doesnt exist... Would you know any reasons for this? Python is still installed and everything that was there before the crash is still there. Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Python problem
haha sorry for got to post, windows 7 running on activepython 2.7.2.5 (path is under python27) Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\James>python ActivePython 2.7.2.5 (ActiveState Software Inc.) based on Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> C:\Users\James\Desktop\test.py runserver File "", line 1 C:\Users\James\Desktop\test.py runserver ^ SyntaxError: invalid syntax >>> C:\Users\James\Desktop\test.py File "", line 1 C:\Users\James\Desktop\test.py ^ SyntaxError: invalid syntax >>> but the test.py file or any other py file is there and the path is correct but python fails to recognise it as valid cheers On Friday, March 22, 2013 2:32:52 PM UTC+13, James wrote: > > Hey there, > > Did first Django app and everything worked find, however my computer > crashed and after restoring it each time I try to execute any .py file in > command prompt it says syntax error or that the module doesnt exist... > > Would you know any reasons for this? Python is still installed and > everything that was there before the crash is still there. > > Thanks! > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Cache witin a single transaction / session ?
Use the 'with' template tag. That's what it is for. https://docs.djangoproject.com/en/dev/ref/templates/builtins/#with Also you should probably use |pluralize filter to add pluralization. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Self-Referential System or Tree?
I started writing a new model for a client's website. The easiest analogy I can make is something like a menu, so I wrote just that (start simple, then add the hard stuff). from django.db import models class Menu(models.Model): parent=models.ForeignKey(Menu) text=models.CharField(max_length=50) location=models.CharField(max_length=255) def __unicode__(self): return self.text While this allows me to back-track up, when displaying, I want ordered lists (the actual ordering comes later, but that's easy enough). So basically, is there a way to find out what models reference a given object? So my template can pick "object number 1" and find all those that reference it as a parent, and move on down the line? Or would I be better off grabbing something like django-treebeard and using that? If the latter, is there some sample code beyond the "Basic Usage" in its documentation someone could point me to? Thanks! James C -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: Self-Referential System or Tree?
That's the main thing about this structure. It is unlikely to change very often, but I don't want it set in stone because there's always a chance it will change. And it will display on most, if not all, pages in this project. But all that caching, etc., is stuff I can deal with later. Because it'll be *primarily* two levels, I figured the AL approach would work best, which is why I chose that when writing this class. But given what I've got, how do I ask, "What are all the children of this node?" Do I do so in the template, or in the defining view? That's the question I'm having trouble answering. James C On Thursday, September 5, 2013 10:43:14 AM UTC-5, Javier Guerra wrote: > > On Thu, Sep 5, 2013 at 10:22 AM, James > > wrote: > > I started writing a new model for a client's website. The easiest > analogy I > > can make is something like a menu, so I wrote just that (start simple, > then > > add the hard stuff). > > > the main aspect to choose between "just a parent link" (Adjacency > List) and a full tree library (typically nested sets or materialized > path) is the frequency of full (sub) hierarchy requests. > > if in most cases you have a given node and just need to get all the > direct children, then the simplest solution works great. > > if, on the other hand, you have to get a whole subbranch at > indeterminate depth, then use something else. > > I guess that most pages will have to display the whole menu tree, so > using nested sets seems better since it would add just a single query. > But if it is the _whole_ tree, then you could just as easily read the > whole table and unravel the hierarchy in python. Even better, if the > menu doesn't change so often, you should store the rendered structure > in some cache and don't care about the base structure > > -- > Javier > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Custom fields and widgets in a ModelForm
Hey all, A question about form fields and widgets: I want to use custom ones in a ModelForm, but I'm not sure where to specify this. I see the widgets dict in the ModelForm Meta class to control the custom widgets, but no equivalent for custom form fields. http://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#overriding-the-default-field-types-or-widgets suggests I should just do field_name = CustomFormField() on my ModelForm, but when it comes to full_clean(), I don't see my custom form field being used in ModelForm.fields... Any suggestions much appreciated. Thanks! James -- 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.
User Profile and Form initial values
I'm struggling to create a method by which a user can update his user profile, where the current information is displayed in the "edit" form, and I'm hoping someone here can point out what I'm doing wrong. I am not using ubernostrum's django-profiles for this because it hasn't been touched in quite some time and therefore doesn't work out- of-the-box with Django 1.3 (perhaps there's a fork or patch that I missed). Anyway, the issue: when the form is displayed, it acts as if I've submitted it (error messages of missing data appear), and the initial data doesn't appear, even if I make it explicit in __init__ (e.g. self.fields['field'].initial = 'test'). I just get a blank field. I've pared the following code down to the very basics and it still doesn't work. Is there something missing? Or do I have something extra that shouldn't be there? http://pastebin.com/2D7ABMKW Thanks, James -- 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: User Profile and Form initial values
That did it. 99% of the time the data will be there; I can write exception clauses for when it isn't. I think I'll use this method, though I had just discovered the "initial" dictionary argument as well, a few minutes before I noticed your reply. Is there a spot in the Django docs that explains this in more detail? I haven't been able to find it. Thank you very much! James On Apr 26, 3:17 pm, Shawn Milochik wrote: > If you're creating a ModelForm that already has data in the database, > don't pass in request.POST. Instead, pass in the instance with the > 'instance' keyword argument. > > For example, if it was a ModelForm for the User object: form = > UserForm(instance = request.user) -- 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: User Profile and Form initial values
Doh! As much as I read in the forms section, I skipped the ModelForms part, even though that's what I was using! Thanks again! James -- 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.
Flatpages - Django 1.5.1
I’m having trouble implementing flatpages in Django 1.5.1 - I’m new to Django/Python (~3 months) so any insight is appreciated. I’ve added flatpages in APPS and MIDDLEWARE_CLASSES and ran a syncdb: INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: 'django.contrib.admindocs', 'django.contrib.flatpages', 'blog', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', ) I logged into Django admin and created: URL: /about/ Title: About Content: testing… Sites: 127.0.0.1:8000 I clicked ‘view on site’ within the Django admin > flatpages > /about/ and I get sent to http://localhost:8000/about/ which returns a 404. I opened up a SQLite browser and I can see that my page is in the db. Am I missing anything else? Thanks James -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/019cf512-4712-4af0-9bde-0db7c46d71d0%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Flatpages - Django 1.5.1
Fixed. After some Google-fu I set SITE_ID = 2 and it worked. On Monday, January 20, 2014 4:41:05 PM UTC-8, James wrote: > > I’m having trouble implementing flatpages in Django 1.5.1 - I’m new to > Django/Python (~3 months) so any insight is appreciated. > > I’ve added flatpages in APPS and MIDDLEWARE_CLASSES and ran a syncdb: > > INSTALLED_APPS = ( > > 'django.contrib.auth', > > 'django.contrib.contenttypes', > > 'django.contrib.sessions', > > 'django.contrib.sites', > > 'django.contrib.messages', > > 'django.contrib.staticfiles', > > # Uncomment the next line to enable the admin: > > 'django.contrib.admin', > > # Uncomment the next line to enable admin documentation: > > 'django.contrib.admindocs', > > 'django.contrib.flatpages', > > 'blog', > > ) > > > MIDDLEWARE_CLASSES = ( > > 'django.middleware.common.CommonMiddleware', > > 'django.contrib.sessions.middleware.SessionMiddleware', > > 'django.middleware.csrf.CsrfViewMiddleware', > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > 'django.contrib.messages.middleware.MessageMiddleware', > > 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', > > ) > > I logged into Django admin and created: > > URL: /about/ > > Title: About > > Content: testing… > > Sites: 127.0.0.1:8000 > > I clicked ‘view on site’ within the Django admin > flatpages > /about/ and > I get sent to http://localhost:8000/about/ which returns a 404. I opened > up a SQLite browser and I can see that my page is in the db. Am I missing > anything else? > > Thanks > > James > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b15140af-244f-4fb1-8cae-82058849d0d8%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Do you think Django's future is threatened by JS frameworks in both client & server?
This is something I've been thinking about myself lately. I'm working on a side project right now that is extremely JS heavy on the client side. I eventually found myself saying screw it, and am now in the process of rewriting the client side using backbone. Django is more or less becoming a restful endpoint for me that communicates to my various datastores. In my professional life this is pretty much the same, start with django / jinja templates and then once the jquery gets crazy, move to a real client side framework (such as backbone, angular, ember, etc). The next app we build is going to be backbone from the ground up on the client side. For anything much more complicated than some calender widgets this is going to be the pattern. For this app, we see something like 45% of our traffic coming from phones and other mobile devices, so creating views in django that are more rest based than page based makes a lot of sense and just let the client decide what to draw on the page, rather than the server. I think in the next year or two we will be talking about a MV > MVC paradigm. Where the MV is django / rails / flask / node and where the MVC is the client side. Right now the only MVC client side frameworks are written in javascript because the only way to manipulate the DOM is with JS. Therefore, if you are a startup or even an established company and you need to go out and hire some resources, it's more cost effective in the beginning to hire one person who knows javascript will and through them into node.js and backbone (or whatever). That said, this doesn't really conflict with django's mission to "receive an http request and send an http response". Templating in Django has always been more of a batteries included feature more than a core feature, at least for me. That said, right now node and js in general just aren't there yet to replace django / python or rails / ruby as a full on server side language for anything more complicated than ToDoMVC in my opinion. Considering in django it's easy for me to hook up to mysql, postgres, memcached, mongo, elasticsearch and rabbitmq all in the same app, and usually not much more config than a single line and pip install xyz. To my understanding, you don't get much of this in node. That could change in the future of course, but at the end of the day, JS is not a pure OOP language while python and ruby are, even though it does a good job at trying to get most of the way there via prototype. What's more, I just don't think there is a way to do serious numerical heavy lifting in server side JS like I can get with numpy / scipy - and be performant by modern web standards. I think the Dart project is interesting to give JS some competition on the client side, but I don't know a single dev who uses it in production. I didn't know about the mozilla project with python, but that sounds interesting. Maybe some day we will talk about dart being used on the server and client at the same time. For now, I don't see python or ruby going very far for serious server side development. For simple ecommerce stuff or blog like apps, node might gain some share. On Monday, January 27, 2014 5:44:12 PM UTC-5, damond...@gmail.com wrote: > > Hi, > > I would like to know if this community is somewhat worried about the > future relevance of Django (and other purely server-side MV* Python web > app frameworks such as web2py for that matter) given the current momentum > of JavaScript (JS) everywhere? > > There are many competing architecture patterns for a WHOLE web app today > ranging: > a) from client-heavy SPA with a client-side MVC framework synching its > models via a REST API with a server-side reduced to a database access layer > > b) to light client apps with a server-side MVC frameworks and very little > or no Ajax > > c) and everything in the middle. > > I guess it is not too controversial to say that which is best (or even > merely adequate) depends on the generally moving target of the app > requirements (especially the non-functional ones) and thus a long > lifecycle app can be expected to have to change pattern at some point. > > > Given that: > 1) full web apps following any pattern can today be developed exclusively > with JavaScript (JS) frameworks on both sides who have incorporated most > (if not all) great design ideas from Django (and Rails) > > 2) IDEs ranging from Visual Studio to browser-based ones are available to > support such development > > 3) Python in the browser projects do not yet provide productive debugging > support (and will they ever without support from a tech giant?) > > 4) Cloud giants (Amazon, Google, Heroku, Microsoft) all offering JS framework > running servers > > are the productivity gains from the more legible, concise and abstract > Python code as compared to JS code really compensate the productivity > loss of having to port part of the app from one language to other every
Django Channels 2 poor performance and high CPU usage
I'm using Channels 2 to build a shared 3D model viewing tool, but I'm running into performance issues where Channels can't keep up and uses 100% of a single core. This results in clients just receiving a slow trickle of messages rather than the fast stream I was expecting. I ended up stripping my consumer all the way back to basically a relay server, so a client sends a message, server broadcasts the exact data received to a group. I am sending a lot of data though (a message every 20ms or so) so not sure if that is causing my issues. Using node I built the same relay server and I have zero issues with speed or server performance. Is this down to how many workers I have running vs the data I'm sending, or perhaps the overhead of Django? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fecbabcc-2692-4d7f-ac6f-6de7c3631354%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Lazy ForeignKey references break in upgrade from 1.9 to 1.10
Hey everyone, While upgrading from 1.9 to 1.10, I got errors that lazy ForeignKey references cannot be resolved similar to the following (full stack trace is included below): ValueError: Related model 'appname.ModelName' cannot be resolved This occurs with anything from simple models to abstract models, referencing other models within the same app, other apps, and recursive relationships ('self'). In searching, I've found similar issues relating to migrations, however this happens when I call manage.py "runserver" or "shell". I haven't run or defined any migrations in 1.10 yet. Full stack trace (using Django 1.10; directories and the app name have been obfuscated from the original) Note: This error references a model using an abstract model, but as stated above this is just one instance where it doesn't work. If I were to temporarily comment out the field, it would just error out with the next one. user@host:/pwd$ python manage.py shell Traceback (most recent call last): File "./manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/site-packages/django/core/management/ __init__.py", line 367, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/site-packages/django/core/management/ __init__.py", line 341, in execute django.setup() File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/usr/local/lib/python2.7/site-packages/django/apps/config.py", line 199, in import_models self.models_module = import_module(models_module_name) File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/pwd/app/models.py", line 482, in class Employee(EmployeeDatedFieldsAbstractModel, AbstractBaseUser, PermissionsMixin): File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 309, in __new__ new_class._prepare() File "/usr/local/lib/python2.7/site-packages/django/db/models/base.py", line 349, in _prepare if not opts.managers or cls._requires_legacy_default_manager(): File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/usr/local/lib/python2.7/site-packages/django/db/models/options.py", line 374, in managers manager = copy.copy(manager) File "/usr/local/lib/python2.7/copy.py", line 88, in copy rv = reductor(2) File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 208, in __getstate__ self._fetch_all() File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 1085, in _fetch_all self._result_cache = list(self.iterator()) File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 54, in __iter__ results = compiler.execute_sql() File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler .py", line 824, in execute_sql sql, params = self.as_sql() File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler .py", line 369, in as_sql extra_select, order_by, group_by = self.pre_sql_setup() File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler .py", line 46, in pre_sql_setup self.setup_query() File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler .py", line 37, in setup_query self.select, self.klass_info, self.annotation_col_map = self.get_select() File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler .py", line 194, in get_select for c in self.get_default_columns(): File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler .py", line 516, in get_default_columns column = field.get_col(alias) File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/ related.py", line 954, in get_col return super(ForeignKey, self).get_col(alias, output_field or self.target_field) File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/ related.py", line 855, in target_field return self.foreign_related_fields[0] File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/ related.py", line 595, in foreign_related_fields return tuple(rhs_field for lhs_field, rhs_field in self.related_fields if rhs_field) File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/ related.py", line 582, in related_fields self._related_fields = self.resolve_related_fields() File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/ related.py", line 567, in resolve_related_fields raise ValueError('Related model %r cannot be resolved' % self.remote_field.model) ValueError: Related model 'app.Department' cannot be resolved --
Troubling installing Python 3 on my iMac
I downloaded the file from the python website and went through the entire installation process... accepting all of the default values. However, when I went to my Terminal window and typed python, it still shows the older version: Python 2.7.10 (default, Feb 22 2019, 21:17:52) [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin What did I do wrong? I need to get this all setup before I can start the Django tutorial. Thank you! -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d4a9335d-5067-4620-882e-e10a6d04dbcd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Troubling installing Python 3 on my iMac
Thanks Suresh! This did the trick. On Tuesday, April 30, 2019 at 7:36:30 AM UTC-6, Suresh Kannan wrote: > > Hi, > > Try these steps > > https://wsvincent.com/install-python3-mac/ > > https://stackoverflow.com/a/20868669/4037275 > > On Tue, Apr 30, 2019 at 8:39 AM James > > wrote: > >> I downloaded the file from the python website and went through the entire >> installation process... accepting all of the default values. However, when >> I went to my Terminal window and typed python, it still shows the older >> version: >> >> Python 2.7.10 (default, Feb 22 2019, 21:17:52) >> >> [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin >> >> What did I do wrong? I need to get this all setup before I can start the >> Django tutorial. >> >> Thank you! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django...@googlegroups.com . >> To post to this group, send email to django...@googlegroups.com >> . >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/d4a9335d-5067-4620-882e-e10a6d04dbcd%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/d4a9335d-5067-4620-882e-e10a6d04dbcd%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5e0cd72d-a09d-4597-81d8-036a7c3a952c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Missing staticfiles manifest entry on heroku app, runs fine locally
Hi everyone, I'm getting server error 500 when I deploy my app to heroku. The logs show an issue with staticfiles, even though I'm serving static and media from an S3 bucket: ValueError: Missing staticfiles manifest entry for 'images/favicon.ico' What's odd is that run I run locally, even with DEBUG=False, the app runs fine and I verified that the images are loading from the S3 bucket (both media and static). However, for some reason heroku is unable to load from S3. Settings.py: import os import storages import django_heroku # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '***' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = (os.environ.get('DEBUG_VALUE') == 'True') #DEBUG = False ALLOWED_HOSTS = ['localhost', 'testapp.herokuapp.com', 'testapp.tv'] # Application definition # NOTE: django_cleanup should be placed last in INSTALLED_APPS. INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'taggit', 'storages', 'post.apps.PostConfig', 'ckeditor', 'sorl.thumbnail', 'django_cleanup.apps.CleanupConfig', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'testapp.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'testapp.wsgi.application' # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } # Password validation # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/3.0/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ # STATIC_URL = '/static/' # # Add these new lines # STATICFILES_DIRS = ( # os.path.join(BASE_DIR, 'static'), # ) # STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') # Form messages from django.contrib.messages import constants as messages MESSAGE_TAGS= { messages.DEBUG: 'alert-info', messages.INFO: 'alert-info', messages.SUCCESS: 'alert-success', messages.WARNING: 'alert-warning', messages.ERROR: 'alert-danger', } # Memcached settings CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } # Amazon S3 settings and variables AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = 'testapp-files' AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = None AWS_LOCATION = 'static' AWS_S3_CUSTOM_DOMAIN='%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' #DEFAULT_FILE_STORAGE = 'testapp.storage_backends.MediaStorage' STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ] STATIC_URL='https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION) ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectori
Channel 1 and Django 2.2 compatibility
Hello guys just a quick question, I have a project running channel 1, we are looking at upgrading to django 2.2, does channel 1 work with django 2.2 without upgrading to channel 2? Cheers James -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b14f62fd-c8cb-4dc3-8a2a-58090ae2d56a%40googlegroups.com.
Re: Feature like "acts_as" in Django ORM or contrib ?
On Tue, Oct 21, 2008 at 12:45 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > In Elixir, when I add acts_as_list(qualifier=qualify) in Model I can > use move_higher, move_lower ... methods. Be careful about confusing multiple things here; there are applications available for Django which add features like this -- objects which behave like hierarchical lists/trees, taggable objects, etc. -- and if you like those features you should certainly go look them up. But those applications do not implement those features with precisely the same names or syntax as ActiveRecord (or Elixir, which deliberately borrows many such conventions from ActiveRecord). Which is a perfectly good thing; Django isn't Rails, isn't written in the same language and consciously tries to be idiomatic Python rather than idiomatic Ruby, so trying to simply apply a a feature from Rails using precisely the syntax Rails uses would cause it to stick out like a sore thumb in Django. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: from mysite.polls.models import Poll, Choice
On Thu, Oct 23, 2008 at 1:47 PM, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > It's indeed a pretty bad idea to refer to the project name in import > statements (as well as in a couple other places too FWIW), and I > defnitively fail to understand why it's documented that way. It's documented that way because it means we can have a tutorial that doesn't immediately dump import-path configuration issues onto people who are brand-new to Python; doing things the way the tutorial does them, everything automatically ends up on the Python path thanks to manage.py. This means, of course, that there is a need for followup documentation which explains that this isn't always the best way to develop real-world apps (in just the same way as the tutorial shows several "wrong" ways to do things like template rendering, etc., before showing the "right" way). Any volunteers to write it? -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ANN: Initial release timelines for Django 1.0.1 and Django 1.1
(putting on release manager hat...) We've just put up an entry over at the official Django project blog with details of the timelines for Django 1.0.1 and Django 1.1: http://www.djangoproject.com/weblog/2008/oct/24/upcoming-releases/ Please bear in mind the immediate consequences of these timelines: * Django 1.0.1 will release November 14, which means that any 1.0 bugfixes you'd like to see make it in will need to have patches and tests prior to that date. * If you have a feature proposal for Django 1.1 that you haven't already brought up on the django-developers list, you'll want to do so quickly; the window for feature proposals will close on November 15. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Equivalent to Rails Rumble
On Sat, Oct 25, 2008 at 10:45 AM, Keyton Weissinger <[EMAIL PROTECTED]> wrote: > Is there an equivalent to the Rails Rumble for the Django community? > Shouldn't there be one? What do you think? There was one a couple months ago: http://djangodash.com/ Google is your friend :) -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Receiving emails via app
On Sat, Oct 25, 2008 at 2:09 PM, Jeff Anderson <[EMAIL PROTECTED]> wrote: > We have an alias set up in postfix that sends the e-mail to our script > via a pipe. > > The python script imports our Django models, and parses the e-mail > message with the email module, and does what it needs to. You can also use Python's built-in SMTP server module to set up a lightweight server process, and have your regular MTA forward messages to it. This lets the entire mail-processing routine happen in Python, which is often a bit easier to set up. See Doug Hellmann's recent PyMOTW article on this for some basic details: http://blog.doughellmann.com/2008/10/pymotw-smtpd.html -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: database API from external tools?
On Sun, Oct 26, 2008 at 9:19 PM, Steve Holden <[EMAIL PROTECTED]> wrote: > Here's a specific example of a piece of code that uses a web app's > models. It should get you started - just dive in and write some code! > The tricky bit is providing the settings without using a "settings" > module. I can't remember who I got this code from, but the kudos belongs > to them, not me. Enjoy. I'm late to the party on this, but here's my writeup from last year (IIRC all this stuff is in the official docs, too): http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/ -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Easiest way to pass django documentation from rest to HTML?
On Mon, Oct 27, 2008 at 9:27 PM, Mr. Z <[EMAIL PROTECTED]> wrote: > Which is the easiest way to pass the new django documentation from > rest to HTML? This is covered in the documentation: http://docs.djangoproject.com/en/dev/internals/documentation/ -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Easiest way to pass django documentation from rest to HTML?
On Wed, Oct 29, 2008 at 5:59 AM, Mr. Z <[EMAIL PROTECTED]> wrote: > Thank you both. I'm trying to create a view that converts the ReST > documentation to HTML and shows it integrated with my templates, but > with docutils it gives out a lot of errors. And with sphinx it just > generates plain complete html files with links beteween them :( > > How could I do it? You probably want to read up on Sphinx to learn how to control its behavior, but keep in mind that it's probably not going to be a "press this button and it magically works" thing; most likely, it will be a "learn a bit about Sphinx and write some templates and configuration on your own" thing. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: changing the Manager the admin-site should use
On Thu, Oct 30, 2008 at 7:31 AM, Dennis Schmidt <[EMAIL PROTECTED]> wrote: > Well that does work, though in the Manager documentation it's said: > > "If you use custom Manager objects, take note that the first Manager > Django encounters (in the order in which they're defined in the model) > has a special status. Django interprets this first Manager defined in > a class as the "default" Manager, and several parts of Django (though > not the admin application) will use that Manager exclusively for that > model." This is actually incorrect (open a ticket as a reminder and I'll fix the docs); by default, the admin now uses the default manager for the model, same as everything else in Django. As to your original question, ModelAdmin has a method named 'queryset()', which is used to obtain the QuerySet of objects for display in the admin lists and for looking up objects to edit. Overriding that method on your ModelAdmin subclass is the correct way to do this. This method receives the incoming HTTP request as an argument, so you can use it to filter based on some attribute of the request (e.g., the logged-in user). This also means that when overriding, you must define the method as "def queryset(self, request)", not just "def queryset(self)". -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using settings.py mechanism for application settings
On Fri, Oct 31, 2008 at 8:29 PM, pk <[EMAIL PROTECTED]> wrote: > Am I missing something? Should that mechanism be refactored so that it > can be used for user applications? Is there a better way to do > application level configuration -- i.e. for app designed to be > distributed and reused? If you look in django.contrib, there are several applications which instruct you to fill in a setting which exists only for purposes of that application. And those are applications like any other application; it's perfectly acceptable for any application to do this, so long as its documentation clearly indicates which settings to supply and what values those settings can have. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Python package names
On Mon, Nov 3, 2008 at 6:23 AM, Dj Gilcrease <[EMAIL PROTECTED]> wrote: > Cause I actually like having the django_apps namespace so I can > quickly identify if something being imported is a django app or some > regular python module A Django application *is* a Python module. It's not some secret special format separate from normal Python modules, it's just a Python module. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using settings.py mechanism for application settings
On Mon, Nov 3, 2008 at 7:01 PM, pk <[EMAIL PROTECTED]> wrote: > James is right that for any of my own app, I can just tell the user > to put in some settings in the project level settings.py file. In fact > that is exactly what I do now. And that is what quite a number of popular third-party Django applications -- every one of them intended to be used and reused -- are doing. I don't really see a need for some system of forcing default values, since in many cases *not* supplying an explicit value for such a setting is an error (because not supplying it *or* falling back to a default can break the application or cause undesired behavior). Much better to simply document what's needed, and rely on the fact that trying to run without setting it will raise an error. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django admin - list filter - issues with model fields having name ending in 'y'
On Wed, Nov 5, 2008 at 11:31 PM, ammo <[EMAIL PROTECTED]> wrote: > Does this thing work for anyone else? Well, it works fine for me when I use "verbose_name_plural", which is the correct value and what's listed in the documentation (not "verbose_plural_name" as you've typed here). -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: post data and @login_required
On Thu, Nov 6, 2008 at 5:12 AM, coan <[EMAIL PROTECTED]> wrote: > Why isn't there an option to have the request object passed to the > login form? The login view in the Django admin actually used to do this; see our most recent security-oriented release for the reasons why it doesn't do that anymore... -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Installation of django in user account
On Wed, Nov 5, 2008 at 12:18 PM, Tim O'Toole <[EMAIL PROTECTED]> wrote: > But I obviously cant do the following without root access > > ln -s `pwd`/django-trunk/django SITE-PACKAGES-DIR/django > > Whilst I can set the PYTHONPATH, I can't then write to PythonPath in > the Apache configuration file. You may want to try out a deployment option other than Apache/mod_python, then, but I'm honestly a bit curious how you're planning to use mod_python at all if you don't have access to the Apache configuration file. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I display a template with Chinese characters in it?
On Sun, Nov 9, 2008 at 10:13 PM, Frank <[EMAIL PROTECTED]> wrote: > The charset I use in the html file is 'gb2312'. > > What do I have to do in order to be able to display Chinese language > content? You probably want to have a look at the settings documentation: http://docs.djangoproject.com/en/dev/ref/settings/#file-charset -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django and Python 2.6
I just use 2.5.2 and i might upgrade when needed On Mon, Nov 10, 2008 at 10:44 AM, Kegan <[EMAIL PROTECTED]> wrote: > > I am planning to host at WebFaction. Anyone using Django + Python2.6 > at WebFaction ? Care to share ? > > On Nov 10, 4:42 pm, m0nonoke <[EMAIL PROTECTED]> wrote: > > I am using Win32 and there are still quite a few Python 2.6 libs / > > binaries that are unavailable, such as mod_python. If you are on linux > > though, you should have no problems. > > > > On Nov 10, 8:08 am, Kegan <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > If I start a new Django project today. Should I not be using Python > > > 2.6 ? > > > > > I have read some threads here that ensure Django 1.0+ have no problem > > > with Python 2.6. However, is there any other reason you would > > > discourage using of Python 2.6 (if you 'do' discourage) ? Example, > > > inadequate 3rd party libraries, etc? > > > > > Thanks. > > > -- http://www.goldwatches.com/ http://www.jewelerslounge.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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---