"Building you first Django app, Part 1" example not working
When I'm in the command line, and run the command django-admin.py startproject mysite, I don't get an error, but nothing happens... as far as I can tell! When I cd'd into the directory I'm working in, I did exactly what the tut said – I'm on OS X Leopard with Python 2.5, if that helps anyone help me. I have no idea what is going on, so a helping hand would be appreciated! Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySpace clone using Django? Is it possible?
A clone lot of sense if is very specific. That is, you can have a Facebook/MyEspace/whatever clone for example in your own company (think in a company with 1000+ employees in diferent locations) where you can provide an interface that some people could be familiar with. This was once a time called an Intranet, but now has evolved to the put-your-company-here social network. As this kind of application usually needs to get/save data from legacy systems, in my oppinion is better to buid the solution agains components, like Pinax does, so you have more chances to adapt the application to your users and company needs that getting a pre-built solution and just change the css. -- Antoni Aloy López Blog: http://trespams.com Site: http://apsl.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Limiting HTTP request size
On Dec 19, 11:45 pm, Graham Dumpleton wrote: > It hasn't got anything to do with LimitRequestBody. That this but > exists in current versions of mod_python and can crop up at random > times is a good reason why you don't want to be using mod_python. I've never seen it happen at random, but it happens consistently every time the LimitRequestBody limit is exceeded. If mod_python is this broken, perhaps it shouldn't be Django's recommended deployment method. -- Andreas Gustafsson, g...@gson.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Limiting HTTP request size
On Dec 20, 9:19 pm, Andreas Gustafsson wrote: > On Dec 19, 11:45 pm, Graham Dumpleton > wrote: > > > It hasn't got anything to do with LimitRequestBody. That this but > > exists in current versions of mod_python and can crop up at random > > times is a good reason why you don't want to be using mod_python. > > I've never seen it happen at random, but it happens consistently every > time > the LimitRequestBody limit is exceeded. It may be possible that LimitRequestBody is a more reliable way of triggering the problem in some situations. The bad argument error has been reported on mod_python list a number of times, some not linked to LimitRequestBody at all. See for example: http://www.modpython.org/pipermail/mod_python/2007-June/023795.html Note that although it was random, it rarely happened. The way I phrased things was perhaps poor, in that the issue is not connected with just LimitRequestBody, but is a much deeper problem in how mod_python code is written as explained in: http://issues.apache.org/jira/browse/MODPYTHON-234 Graham --~--~-~--~~~---~--~~ 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: cross table querying
On Dec 20, 3:58 am, Shuge Lee wrote: > how to do following querying in Django 1.0 ? > > mysql> select product.name, os.name from product inner join os where > product.id = os.id ; > +-+-+ > | name| name| > +-+-+ > | MS Word | All | > | Open Office | Windows | > +-+-+ > 2 rows in set (0.02 sec) Why do you not read the documentation? It's quite clear. http://docs.djangoproject.com/en/dev/topics/db/queries/ -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Delete multiple items from an admin change list
Thanks, that's it On 19 dic, 18:04, Jeff Kowalczyk wrote: > On Dec 19, 6:15 am, bcurtu wrote: > > > Is it possible to get the admin item list with a kind of checkboxes in > > order to select multiple items and delete them all together? > > http://code.google.com/p/django-batchadmin/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Saving a query set to a model
Any thoughts or ideas on doing this? Can I just pickle the query set to a string and save it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MySpace clone using Django? Is it possible?
oh for that you will need to use Fusebox On Fri, Dec 19, 2008 at 7:41 PM, lekvar...@gmail.com wrote: > > Hi, I wanna know wich of the well known frameworks is the best choice > for myspace-clone community website. > > CakePHP ? Zend Framework? Symfony? > Django :)? > RubyOnRails? > > or maybe > Kohana? Prado? or something else? > > Is it better to use PHP or Ruby or Python? I will pay a webdesigner > for this job, but I want to know which lang and framework is in your > opinion the best for this kind of application. > I expect about 10 000 or more unique visitors each day so I want to > know words from You, the professionals. > > It is important that the user can change the css, like on myspace.com. > > Then I want to know if is it better to provide for users profile page > this URL > /I have 4 letters in my domain name./ > - > > username..com > > or > > .com/username > > > thanks in advance > > > > --~--~-~--~~~---~--~~ 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: Restricting add in the admin
just a thought: you might consider allowing multiple front page objects and having a way to select the current one. this could come in handy to switch what is currently the front page (or to audition the new front page). otherwise : create one using initial_data so that your application automatically creates it and then set the add permissions to false for everybody. you can only edit The One. a super user could still add one, but don't set your client/end-user to super user. check on save and throw an error if you like. -fx On Fri, Dec 19, 2008 at 6:21 PM, Peter wrote: > > > > > > What I was looking for was a global permission that could be set on a > > > model when it was defined which set > > > default permissions for 'staff' on the model (or even for superuser) > > > on that model. > > > > Why not just create another group? > > Because being a singleton (and not removable) should be, I think, an > *attribute* of the > class/model not of a particular user or a group. > > Cheers, Peter > > > --~--~-~--~~~---~--~~ 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: SyncDB failure
On Fri, Dec 19, 2008 at 2:29 PM, James PIC wrote: > > On 12/17/08, Russell Keith-Magee wrote: > > > > > A better solution would be to come up with a name munging scheme that > > guaranteed to give unique permission names that will always fit into > > the available space. 50 characters is plenty to establish a unique > > name; we already perform a similar munging with the names for database > > constraints. > > That would be much smarter indeed! here, btw. is a bug I found, confirmed and submitted regarding that munging: http://code.djangoproject.com/ticket/9253 the hash munging may vary depending on the OS you are on, and in my case on the deployment server it overflowed MySQL's allowable constraint identifier size. just FYI munging the constraint name is fine IMO, but I the the foreign keys to be readable. the easiest thing to do is > > Of course, the simplest solution is for you to pick shorter class > > names, and for us to document the limitation. > Just for kidding: > class Lot(Mandat, Bien, PourLocation, PourVente, LotAddresse, > AvecEquipementsAnnexes, Textes, Immeuble): > It was that, or models with thousands of similar fields, high WTF/hour :) just be thankful you aren't coding in german :) --~--~-~--~~~---~--~~ 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: SyncDB failure
here's the exact ticket you are looking for: http://code.djangoproject.com/ticket/1820 On Sat, Dec 20, 2008 at 2:19 PM, felix wrote: > > On Fri, Dec 19, 2008 at 2:29 PM, James PIC wrote: > >> >> On 12/17/08, Russell Keith-Magee wrote: >> > >> > > >> > A better solution would be to come up with a name munging scheme that >> > guaranteed to give unique permission names that will always fit into >> > the available space. 50 characters is plenty to establish a unique >> > name; we already perform a similar munging with the names for database >> > constraints. >> >> That would be much smarter indeed! > > > --~--~-~--~~~---~--~~ 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: Admin Site
I checked my source code alot, but nothing is wrong in it. Also as I mentioned it is work on my local.Shall I set something on site for it? On Dec 17, 8:43 pm, "Jeremy Dunck" wrote: > On Wed, Dec 17, 2008 at 11:34 AM, samira wrote: > > > I activeadminsitefor Django 1.0.2, it is correct on my local, but > > I > > see below error on server: > > > emplateSyntaxError at /mywebSite/admin/ > > > Caught an exception while rendering: Tried activateAccount in module > > mywebSite.mywebSite_app.views. Error was: 'module' object has no > > attribute > > 'activateAccount' > > > can anu body knows about activeAccount attribute? > > That must be in your source code. > Within mywebSite_app.views, do you, in face, have an activateAccount > object (usually a function)? > > If you think you do, please paste your views module to dpaste.com and > share the link so we can further troubleshoot.- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Restricting add in the admin
On Dec 20, 1:03 pm, felix wrote: > just a thought: > > you might consider allowing multiple front page objects and having a way to > select the current one. > this could come in handy to switch what is currently the front page (or to > audition the new front page). > Yes - perhaps add a Boolean field (not shown in the admin) 'is_active' Thanks, Peter --~--~-~--~~~---~--~~ 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: Admin Site
This is what I done for activate my admin site: in Urls.py I write this: from django.contrib import admin admin.autodiscover() urlpatterns += patterns('', (r'^' + PROJECT_URL + '/media/(?P.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}), (r'^' + PROJECT_URL + '/admin/(.*)', admin.site.root), ) which PROJECT_URL = 'mywebSite' In models.py class Task(models.Model): id = models.AutoField(primary_key=True, db_column='id') calendar = models.TextField(db_column='Calendar') class Meta: db_table = 'tasks' and in admin.py: class TaskAdmin(admin.ModelAdmin): list_display = ("id","calendar","task","taskType") search_fields = ['task'] admin.site.register(Task, TaskAdmin) I also place admin.py in mywebSite_app near models.py. I didn't add anything to views for admin. what is wrong you think? On Dec 20, 5:02 pm, samira wrote: > I checked my source code alot, but nothing is wrong in it. Also as I > mentioned it is work on my local.Shall I set something on site for it? > > On Dec 17, 8:43 pm, "Jeremy Dunck" wrote: > > > > > On Wed, Dec 17, 2008 at 11:34 AM, samira wrote: > > > > I activeadminsitefor Django 1.0.2, it is correct on my local, but > > > I > > > see below error on server: > > > > emplateSyntaxError at /mywebSite/admin/ > > > > Caught an exception while rendering: Tried activateAccount in module > > > mywebSite.mywebSite_app.views. Error was: 'module' object has no > > > attribute > > > 'activateAccount' > > > > can anu body knows about activeAccount attribute? > > > That must be in your source code. > > Within mywebSite_app.views, do you, in face, have an activateAccount > > object (usually a function)? > > > If you think you do, please paste your views module to dpaste.com and > > share the link so we can further troubleshoot.- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin Site
Hi Samira! On Dec 17, 5:34 pm, samira wrote: > Caught an exception while rendering: Tried activateAccount in module > mywebSite.mywebSite_app.views. Error was: 'module' object has no > attribute > 'activateAccount' > > can anu body knows about activeAccount attribute? As Jeremy said, ``activateAccount`` is not a part of the Django code base. It has to be part of your code or any dependencies in your project. You need to find out where activateAccount exists and what's calling it. If you need a hand, it would be helpful if you started out by pasting a full traceback that can be obtained from your Django debug page (use the paste-friendly form). Regards, Friðrik Már --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
admin: datetime field as date (not date and time)
Is it possible to configure the admin site to render datetime fields as a date only? I have no need of the time at all, in this instance. --~--~-~--~~~---~--~~ 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: database sqlite3
I too have this error... Windows XP... Django 1.0.2... Sqllite3 (as it comes with Python 2.5). The sqlite3.dll file was also installed with Firefox. I wonder if that has something to do with this. C:\Django\mysite>manage.py dbshell Error: You appear not to have the 'sqlite3' program installed or on your path. Did you ever figure it out? On Dec 12, 1:51 pm, ben852 wrote: > C:\Users\Benjamin\Desktop\mysite\sqlite3 > SQLite3 version 3.6.6.2 > Enter".help" for instructions... > > C:\Users\Benjamin\Desktop\mysite\python manage.py dbshell > Error: You appear not to have the 'sqlite3'program installed or on > your path > > I have the latest version of django (SVNsubversion) and I thought > SQLite3 was automatically installed with this version. > > I installed SQLite3 within the mysite directory but it appears it > does'nt work (the command "python manage.py dbshell"). > I can't make changes to my database schema (chapter 5). > In SQLite3, when I execute an ALTER TABLE statement to add a new > column, I have an SQL error: no such table: books_book (book is a > class of my model). > > Do I have to add a path to another directory? > Do I have to reinstall SQLite3? or to change of db? How do I do? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin Site
You are right, I find that by mistake I user active account. thanks alot On Dec 20, 5:55 pm, Fridrik Mar Jonsson wrote: > Hi Samira! > > On Dec 17, 5:34 pm, samira wrote: > > > Caught an exception while rendering: Tried activateAccount in module > > mywebSite.mywebSite_app.views. Error was: 'module' object has no > > attribute > > 'activateAccount' > > > can anu body knows about activeAccount attribute? > > As Jeremy said, ``activateAccount`` is not a part of the Django code > base. It has to be part of your code or any dependencies in your > project. You need to find out where activateAccount exists and what's > calling it. > > If you need a hand, it would be helpful if you started out by pasting > a full traceback that can be obtained from your Django debug page (use > the paste-friendly form). > > Regards, > Friðrik Már --~--~-~--~~~---~--~~ 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: admin: datetime field as date (not date and time)
Hi Mel, Have you considered switching to a ``DateField``? Regards, Friðrik Már On Dec 20, 11:05 am, Mel wrote: > Is it possible to configure the admin site to render datetime fields > as a date only? I have no need of the time at all, in this instance. --~--~-~--~~~---~--~~ 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: Help with batch processing
Check out: http://www.doughellmann.com/PyMOTW/contents.html He's got tutorials on quite a lot of the python stdlib--very handy resource. csv and zipfile are on there. -Jeff On Dec 19, 9:40 pm, Brandon Taylor wrote: > I've been looking at the methods from those libs. Glad to know I'm on > the right track. > > Thanks, > b > > On Dec 19, 7:27 pm, Masklinn wrote: > > > On 19 déc. 08, at 23:50, Brandon Taylor > > wrote: > > > > Hi everyone, > > > > My client needs some batch processing capabilities that I haven't > > > coded in Python/Django yet, and I need advice on the best way to read > > > images contained in a .zip file. I'm pretty comfortable extending > > > Django admin, just not working with files this way. > > > > I will need to: > > > > 1. Read and parse a .csv file. (this I can do) > > > 2. Unpack a .zip into a directory > > > 3. Find files with names that correspond to a column in my .csv > > > 4. Update my database with values from the .csv and the images > > > > Advice greatly appreciated! > > > - Brandon > > > It shouldn't be too hard to do what you need with the csv and zipfile > > modules from the python stdlib --~--~-~--~~~---~--~~ 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 Session Variables
Looking at http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/__init__.py#L46 it doesn't look like it clears the session. It *does* generate a new key, but that shouldn't affect anything. It should only take you about two minutes to test it though--just try it out. -Jeff On Dec 19, 6:18 pm, "j...@zigzap.com" wrote: > Does django maintain session variables when logging in or does it > generate a new session when you use the built in authentication. > Essentially I want to be able to assign session values to an Anonymous > User and be able to carry them through when they log in. --~--~-~--~~~---~--~~ 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: newie, django and apache, somethings are not working
> the last line of the error is > > * > OperationalError: unable to open database file > ** > > NOtes: I have put the complete path for the DB /home/XXX/djangoProys/ > mysite2/DBmysite2, and I tried change permissions for database file Make sure that apache can read and write the database file *and* the directory that the file is in. It took me while to figure that one out, but SQLite requires that. > When I usehttp://127.0.1.1/mysite2/polls or > http://127.0.1.1/mysite2/polls/1 > > they works fine > > 2) except when I send the form to check for results from the poll, the > error is > * > Not Found. The requested URL /polls/2/vote/ was not found on this > server. > * > It looks like you're directing the user to the wrong URL--it should be: /mysite2/polls/2/vote/ I'm assuming that you're hardcoding your URLs in your templates/views --use the {% url %} tag and reverse() instead. http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse -Jeff --~--~-~--~~~---~--~~ 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: del session variables
Wow, you're right. I've been programming Python for years, and I somehow never noticed that. I'll be quiet not :-) On Dec 17, 6:33 pm, Malcolm Tredinnick wrote: > On Wed, 2008-12-17 at 15:09 -0800, Jeff FW wrote: > > You've got a space in between "HttpResponseRedirect" and "('../ > > shop')" . > > Which is perfectly legal and unambiguous in Python. That isn't a > problem. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
urls.py password reset view.
Hello, I have the following entry in urls.py file: (r'^forgotpassword/$', password_reset, { 'template_name': 'users/forgotpassword.html', 'email_template_name': 'users/forgotpassword_template.html' }), Whenever i try to load it, i get: Reverse for '' with arguments '()' and keyword arguments '{}' not found. I have reinstalled a clean version of django and tried everything but i cannot seem to get it to work. I have searched other posts but none were helpful. Any help would be great! Kevin P.S. Im new to django so im trying to learn my way around :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
template inheritance miff
Hello, I have two templates in this example, page_base.html http://dpaste.com/101058/ and intro.html http://dpaste.com/101059/ . intro.html inherits from page_base.html, but the content_head block does not get inherited. what am i doing wrong or mis-understanding? Thanks for your help, Milan --~--~-~--~~~---~--~~ 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: urls.py password reset view.
That error is occuring because you don't have a URL defined for password_reset_done, which, presumably, is being referred to in your forgotpassword.html in a {% url %} tag. Check out this brief tutorial, it's rather handy: http://www.rkblog.rk.edu.pl/w/p/password-reset-django-10/ -Jeff On Dec 20, 12:01 pm, kev wrote: > Hello, > I have the following entry in urls.py file: > > (r'^forgotpassword/$', password_reset, { > 'template_name': 'users/forgotpassword.html', > 'email_template_name': 'users/forgotpassword_template.html' > }), > > Whenever i try to load it, i get: > Reverse for '' with > arguments '()' and keyword arguments '{}' not found. > > I have reinstalled a clean version of django and tried everything but > i cannot seem to get it to work. I have searched other posts but none > were helpful. > > Any help would be great! > > Kevin > > P.S. Im new to django so im trying to learn my way around :) --~--~-~--~~~---~--~~ 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: SyncDB failure
>> Just for kidding: >> class Lot(Mandat, Bien, PourLocation, PourVente, LotAddresse, >> AvecEquipementsAnnexes, Textes, Immeuble): >> It was that, or models with thousands of similar fields, high WTF/hour :) > > just be thankful you aren't coding in german :) It's very business-specific, i ignore 90% of the terms in english. Also, the program is country-legislation specific. But as you can see, not using acronyms is part of the coding standart. --~--~-~--~~~---~--~~ 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: Restricting add in the admin
On Sat, Dec 20, 2008 at 3:17 PM, Peter wrote: > > > > On Dec 20, 1:03 pm, felix wrote: >> just a thought: >> >> you might consider allowing multiple front page objects and having a way to >> select the current one. >> this could come in handy to switch what is currently the front page (or to >> audition the new front page). >> > > Yes - perhaps add a Boolean field (not shown in the admin) > 'is_active' Very relevant, don't forgot to overload the save method to set other is_active to 0! 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 -~--~~~~--~~--~--~---
Admin formatting
I am learning Django under Windows Vista. I am using Python 2.5 and Wamp5. The document root for Apache is set to c:/wamp/www/ I have a project under c:/wamp/www/DjangoProjects/mysite If I run it using the Django built-in server it works fine. If I run it using Apache and wsgi-python the application works fine but the admin does not look the same, I suspect it does not make use of the admin css files. I am not familiar with Apache but suspect it is a problem of configuration of the server. Help most welcome MS --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: template inheritance miff
On 20 déc, 18:48, "Milan Andric" wrote: > Hello, > > I have two templates in this example, > page_base.htmlhttp://dpaste.com/101058/and intro.html > http://dpaste.com/101059/. > intro.html inherits from page_base.html, but the content_head block > does not get inherited. what am i doing wrong or mis-understanding? Remove the first {% endblock %} (the one just after the call to {{block.super}} > Thanks for your help, > > Milan --~--~-~--~~~---~--~~ 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: mod_wsgi // Stack trace does not show in log files or gets sent by email
So I spent the last few days debugging and was able to solve half the problem, i.e. the mails-not-getting-sent one: Turns out that the mail server I was told to use does swallow messages containing a stack trace, presumably due to spam filtering. The nice thing was that a) the sys admin told me that this was not happening and b) I first tested only by using mail_admins from the shell with a simple subject/body combination, which did work and fooled me into believing that there was indeed nothing wrong with the mail sever. That was a hard lesson learned. But, the problem of the traceback not showing in the log files is still there and I have been unable to make anymore progress in tracking this one down. Can someone enlighten me where the traceback is supposed to get logged in django.core.handlers.WSGIHandler (which I understand to be the "root" of Django when running under WSGI)? I've tried to follow how that works, and it seems eventually an exception ends up in django.core.handlers.base.handle_uncaught_exception, which is where the mail is sent and the pretty http500 page gets returned. But I cannot figure out where the stack trace would be sent to the error log in this case? Does that even happen by default or do I need to customize something? In basehttp.py things are clear - there is log_exception which prints out the stack trace. Not clear at all for me in the case of WSGI. I'd very much appreciate if someone could point me to the right direction so I can poke around some more in the right place for what's going on. Thanks! Stefan On Dec 14, 5:50 am, Stefan Wallner wrote: > Hi, > I am running Django 1.0 on Windows Server 2003, Python 2.5 with > mod_wsgi. I am having trouble capturing any exceptions in my code > either through Apache's error log or by having an email sent to me. > > As a simple test I added > a = [1,2,3] > b = a[4] > to the top of one of my views, which does generate an IndexError > exception, but is not being reported in the error log or by email > either. > > The mod_wsgi configuration is stricly as described on mod_wsgi's > website (http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango), > but even with LogLevel info in my Apache conf I do not see anything in > my error log (related to the exception in the Django code, a bunch of > other Apache messages do get printed). > > As for receiving the stack traces via email I have SERVER_EMAIL, etc. > setup and can confirm that it works when I am running it with the > development server and I can send email on this server (tested both on > the dev server and the production server by a different part of code > in my application). > > If DEBUG is set to True I can see the stack trace in the browser, but > with true production mode all errors are silently lost. > > Any ideas or pointers on what is going on or what else I should do? > > Thanks, > Stefan --~--~-~--~~~---~--~~ 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: urls.py password reset view.
Thank you! :) Kevin On Dec 20, 12:54 pm, Jeff FW wrote: > That error is occuring because you don't have a URL defined for > password_reset_done, which, presumably, is being referred to in your > forgotpassword.html in a {% url %} tag. Check out this brief > tutorial, it's rather handy: > > http://www.rkblog.rk.edu.pl/w/p/password-reset-django-10/ > > -Jeff > > On Dec 20, 12:01 pm, kev wrote: > > > Hello, > > I have the following entry in urls.py file: > > > (r'^forgotpassword/$', password_reset, { > > 'template_name': 'users/forgotpassword.html', > > 'email_template_name': 'users/forgotpassword_template.html' > > }), > > > Whenever i try to load it, i get: > > Reverse for '' with > > arguments '()' and keyword arguments '{}' not found. > > > I have reinstalled a clean version of django and tried everything but > > i cannot seem to get it to work. I have searched other posts but none > > were helpful. > > > Any help would be great! > > > Kevin > > > P.S. Im new to django so im trying to learn my way around :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Advanced Permissions and States
Hi i'm developing an e-commerce site with Django, and have situations like this : - A user can execute different operations in different time-intervals if he has the right privileges. Ex : A user can edit only his products Ex : A user can edit only his orders when he has bought the product. The solution may seem straightforward you have a view and do these : def some_view(request): if not first_requirement_ok: raise Error if not second_requirement_ok: raise Error #all other requirements . . . . In the past i developed a forum app and did the same thing as above. However when put the app in production i saw that there were some security issues. Some users were able to edit others posts and etc. I think that time i need sth better and more dynamic. Do someone knows some way to do things cooler ? Some pattern or way that will let me manage that user privilage interaction easier. What i think for now is to write lots of security decorators and use them. Sth like that : @is_user_owner @did_he_buy_product def some_view(request): #do the operation Another way i think about is to use the State Pattern (using the state diagrams) and move that code somewhere else for more flexibility. For example: class SomeState: @is_user_owner @did_he_buy_product def change_state(*args): #do stuff Does some of you manage that kind of big projects and how do you manage it ? Any advices recommendations will be appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Restricting add in the admin
> Very relevant, don't forgot to overload the save method to set > other is_active to 0! > > Regards, James. Ah - yes that would seem a good idea :-). P. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django model filter
Hello, Im a bit confused with django model api and cannot seem to figure out how to do: SQL WHERE (user == username AND friend == friend) OR (user == friend AND friend == user). How would django model api write that code? Thanks, Kevin --~--~-~--~~~---~--~~ 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 model filter
Hi Kev, > Im a bit confused with django model api and cannot seem to figure out > how to do: > > SQL WHERE (user == username AND friend == friend) OR (user == friend > AND friend == user). Please see the following piece of documentation: http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects Regards, Friðrik Már --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Can anyone explain why reverse() never seems to work?
Given the following code, can anyone explain why Django can't reverse this, because I'm of the opinion that reverse is the flakiest function ever: << models.py >> class Post(models.Model): """created is a datetime object""" @permalink def get_absolute_url(self): params = dict(year=self.created.year, month=self.created.month, slug=self.slug) return reverse('post', kwargs=params) << urls.py >> urlpatterns = patterns('apps.article.views', url( r'^entries/(?P\d{4})/(?P\d{2})/(?P[-\w]+)/ $', 'entry_detail', name='post', ), ) I get the following error when trying to call post.get_absolute_url(): == ERROR: tests that monkeypatch to model works -- Traceback (most recent call last): File "./../apps/stream/tests/stream.py", line 45, in testCreatedPatch print article.get_absolute_url() File "/Users/REDACTED/Projects/django/trunk/django/utils/ functional.py", line 55, in _curried return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs)) File "/Users/REDACTED/Library/Python/2.5/site-packages/django/db/ models/base.py", line 532, in get_absolute_url return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' % (opts.app_label, opts.module_name), func)(self, *args, **kwargs) File "/Users/REDACTED/Projects/django/trunk/django/db/models/ __init__.py", line 30, in inner return reverse(bits[0], None, *bits[1:3]) File "/Users/REDACTED/Library/Python/2.5/site-packages/django/core/ urlresolvers.py", line 256, in reverse *args, **kwargs))) TypeError: reverse() argument after ** must be a dictionary I swear it's a dictionary, so why does it always fail? It drives me mad. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Can anyone explain why reverse() never seems to work?
On Sat, Dec 20, 2008 at 3:02 PM, Bradley Wright wrote: > Given the following code, can anyone explain why Django can't reverse > this, because I'm of the opinion that reverse is the flakiest function > ever: The permalink decorator is a shortcut which will, on its own, apply reverse() to what the function returns. Since you're already calling reverse() in the function, you're essentially passing the result of reverse() into another reverse() call. Consult the documentation to see how the decorator is normally used. -- "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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
custom templatetags and problem with importing photologue.models - namespace collision?
Hi all I've experienced problems with import photologue.models into my templatetag module. When I loop over sys.modules in templatetags/pobierz.py there's django.templatetags.photologue, so probably that's why "from photologue.models import Gallery" throws ImportException - there's not models in django.templatetags.photologue Anyway in sys.modules there's photologue.models as well. Is there any way to import models from photologue? It seems solution is easy, but I spent some time on it and got confused... All I want to do is inclusion tag that renders some objects from my models in flatpages... I've done it with my own models, the only problem is photologue. Thanks in advance. -- Bartosz Radwan jid: bar...@sq9mev.info spamtrap: http://sq9mev.info/spamtrap.html --~--~-~--~~~---~--~~ 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: Admin formatting
MS wrote: > I am learning Django under Windows Vista. > > I am using Python 2.5 and Wamp5. The document root for Apache is set > to c:/wamp/www/ > > I have a project under c:/wamp/www/DjangoProjects/mysite > Don't do that. You don't need your python code in the document root, and it's a bad idea to make it available to the world. > If I run it using the Django built-in server it works fine. If I run > it using Apache and wsgi-python the application works fine but the > admin does not look the same, I suspect it does not make use of the > admin css files. Correct. You have to tell apache that the location of the admin media should be handled with the default handler, and then make an alias for that location to point to the correct location on disk. This is in the docs: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1 Cheers, and happy coding! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: "Building you first Django app, Part 1" example not working
Chris wrote: > When I'm in the command line, and run the command django-admin.py > startproject mysite, I don't get an error, but nothing happens... as > far as I can tell! Did you check to see if the 'mysite' directory was created? Here's what it looks like on my osx terminal: jeffe...@pax:~$ django-admin.py startproject mysite jeffe...@pax:~$ cd mysite/ jeffe...@pax:~/mysite$ Cheers! Jeff Anderson signature.asc Description: OpenPGP digital signature
image uploading, validation by using form
Here is my model: class Book(models.Model): title = models.CharField(max_length=150) category = models.CharField(max_length=50) description = models.CharField(max_length=2000) image1 = models.ImageField(upload_to='img/bk', blank=True) image2 = models.ImageField(upload_to='img/bk', blank=True) image3 = models.ImageField(upload_to='img/bk', blank=True) I want to create a form to add/edit a book which can upload image files (I want to make sure it is an image file and individual image file is within size limit, e.g. 500kb, and dimension limit, e.g. 800X600 px). I don't think I can use ModelForm because this validation requirement, also because I want to automatically set the category value for the form on the fly. But don't know 1) how to save uploaded images in view along with the new Model object. 2) how to do validation on the uploaded image files. I found a close reference: http://www.oluyede.org/blog/2007/03/18/django-image-uploading-validation-and-newforms/ But it reads: "This post is outdated now - if you’re using the latest django, do not follow this post." I don't know what to follow for Django 1.0.2 that I am using. The Django document on forms: http://docs.djangoproject.com/en/dev/topics/forms/ does not even mention how to ceate a form for ImageField in Model. Can anyone help with some code snippets? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: image uploading, validation by using form
Hi, You can do validation on images by using a custom form for your admin Model. This example validates that a thumbnail image is a specific dimension, file type and file size, from django.core.files.images import get_image_dimensions class MyModelAdminForm(forms.ModelForm): model = MyModel def clean_thumbnail(self): thumbnail_image = self.cleaned_data['thumbnail'] try: main, sub = thumbnail_image.content_type.split('/') w, h = get_image_dimensions(thumbnail_image) if w != 128 or h != 96: raise forms.ValidationError(u'Please use an image that is 128 x 96 pixels for thumbnails') if not (main == 'image' and sub in ['jpeg', 'pjpeg']): raise forms.ValidationError(u'Please use a JPEG image.') if len(thumbnail_image) > 20480: #bytes raise forms.ValidationError(u'Thumbnail file size must not exceed 20 KB.') except AttributeError: pass return thumbnail_image class MyModelAdmin(admin.ModelAdmin): form = MyModelAdminForm HTH, Brandon On Dec 20, 8:00 pm, Chuck22 wrote: > Here is my model: > > class Book(models.Model): > title = models.CharField(max_length=150) > category = models.CharField(max_length=50) > description = models.CharField(max_length=2000) > image1 = models.ImageField(upload_to='img/bk', blank=True) > image2 = models.ImageField(upload_to='img/bk', blank=True) > image3 = models.ImageField(upload_to='img/bk', blank=True) > > I want to create a form to add/edit a book which can upload image > files (I want to make sure it is an image file and individual image > file is within size limit, e.g. 500kb, and dimension limit, e.g. > 800X600 px). > > I don't think I can use ModelForm because this validation requirement, > also because I want to automatically set the category value for the > form on the fly. But don't know 1) how to save uploaded images in view > along with the new Model object. 2) how to do validation on the > uploaded image files. > > I found a close reference: > > http://www.oluyede.org/blog/2007/03/18/django-image-uploading-validat... > > But it reads: "This post is outdated now - if you’re using the latest > django, do not follow this post." I don't know what to follow for > Django 1.0.2 that I am using. The Django document on > forms:http://docs.djangoproject.com/en/dev/topics/forms/ > does not even mention how to ceate a form for ImageField in Model. Can > anyone help with some code snippets? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Admin formatting
On Dec 21, 12:54 pm, Jeff Anderson wrote: > MS wrote: > > I am learning Django under Windows Vista. > > > I am using Python 2.5 and Wamp5. The document root for Apache is set > > to c:/wamp/www/ > > > I have a project under c:/wamp/www/DjangoProjects/mysite > > Don't do that. You don't need your python code in the document root, and > it's a bad idea to make it available to the world.> If I run it using the > Django built-in server it works fine. If I run > > it using Apache and wsgi-python the application works fine but the > > admin does not look the same, I suspect it does not make use of the > > admin css files. > > Correct. You have to tell apache that the location of the admin media > should be handled with the default handler, and then make an alias for > that location to point to the correct location on disk. This is in the > docs:http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id1 If when they say 'wsgi-python' they mean Apache/mod_wsgi, then the information on the mod_python documentation will not be of use. For mod_wsgi see: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#Hosting_Of_Static_Files When using mod_wsgi you do not need to do the Location/SetHandler None hack that is required in mod_python to have Alias directive honoured. In mod_wsgi for case of static media at sub URL of Django site, just use Alias directives and they will correctly take precedence. Graham --~--~-~--~~~---~--~~ 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: reverse foreign key lookup in extra()
On Fri, 2008-12-19 at 11:10 -0800, Fereshteh wrote: > Hi, > I am trying to add a filtering functionality to my web application. I > create a WHERE clouse text in the client side as text and post it to > the server. > > My Django modele lookes like this: > class Projects(models.Model): > id = models.AutoField(primary_key=True) > name = models.TextField() > class Meta: > db_table = 'projects' > > class Timesheet(models.Model): > ts_id = models.AutoField(primary_key=True) > user = models.ForeignKey(Users, db_column='ts_user', > related_name='ts_user_child') > project = models.ForeignKey(Projects, db_column='project', > related_name='project_child', null='true') > class Meta: > db_table = 'timesheet' > > I use the following in my Django view to retrieve the data according > to the filtering argument received: > filter_str = request.POST['filter_str'] > #filter_str contains something like this: "project__name = 'Django > supported web app'" > Timesheet.objects.filter(user = id).extra(where = [filter_str]) > > But it gives me the error: > > column "project__name" does not exist > > Without using extra the same query works fine so the column does > exist. Your conclusion here is incorrect. There is no column in the database table called "project__name". When you pass that string to a filter() call, Django does a lot of processing and works out the right database table and column name to use for the query. Have a look at the output of Timesheet.objects.filter(project__name="foo").query.as_sql() for example. You will not see any reference to a column called "project__name" there. If you are using extra(), you need to use the correct column names: extra() only exists as a way to write almost raw SQL portions. It sounds a lot like you really want to be using a second filter() call, not an extra() call. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: cross table querying
On Fri, 2008-12-19 at 19:58 -0800, Shuge Lee wrote: [...] It's not really necessary to post all that SQL and Python, since you're only really asking about a couple of the models. If you can reduce your example to the smallest case possible, it's easier for everybody to read (just a tip). > how to do following querying in Django 1.0 ? > > mysql> select product.name, os.name from product inner join os where > product.id = os.id ; > +-+-+ > | name| name| > +-+-+ > | MS Word | All | > | Open Office | Windows | > +-+-+ > 2 rows in set (0.02 sec) So you are after *all* the product names and their associated os names. All the product objects is Product.objects.all() That will return you a sequence of Product objects. But if you only want the product names, you could use the values() call: Product.objects.values('name', 'os__name') That is documented here: http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Need help writing file to specific directory
Hi everyone, I'm unpacking files in a .zip and need to save each file into a particular directory, but I can't seem to find a way to set the directory to save into. Here is part of my code where I'm opening the .zip and iterating over the files: thumb_zip_file = zipfile.ZipFile(obj.thumbnail_image_zip_archive, 'r') for thumbnail_file in thumb_zip_file.infolist(): fname = thumbnail_file.filename data = thumb_zip_file.read(fname) fout = open(fname, 'w') fout.write(data) # <-- here's where I need to specify a directory fout.close() thumb_zip_file.close() Can anyone explain how to set the directory to write into? The above code writes out the files from the .zip, but it writes them to my project root. TIA, Brandon --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Formset and Classes with ForeignKeys
Here are what my models look like == # Standard Header for application models from django.db import models from django.forms import ModelForm #imported for use of "USPhoneNumberField" and "USStateField" from django.contrib.localflavor.us.models import * class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) # employer = models.CharField(max_length=100) # position = models.CharField(max_length=50) email = models.EmailField() class Address(models.Model): line_1 = models.CharField(max_length=60) # line_2 = models.CharField(max_length=60,blank=True,null=True) city = models.CharField(max_length=30) state = USStateField() zip = models.CharField(max_length=10) # newsletter = models.BooleanField() # mail_opt_out = models.BooleanField() # phone_primary = models.CharField(max_length=12) # phone_secondary = models.CharField (max_length=12,blank=True,null=True) # phone_primary_type = models.ForeignKey(contact_phone_types, related_name='primary_set',blank=True,null=True) # phone_secondary_type = models.ForeignKey(contact_phone_types, related_name='secondary_set',blank=True,null=True) # email = models.EmailField(max_length=30,blank=True) # preferred = models.ForeignKey (contact_preferred,blank=True,null=True) class AddressForm(ModelForm): class Meta: model = Address class PersonForm(ModelForm): class Meta: model = Person # Create your models here. class Lead(models.Model): # a lead is a person person = models.ForeignKey(Person); # a lead has address information address = models.ForeignKey(Address); # definitions def __unicode__(self): return '%s %s' % (self.first_name, self.last_name) def full_name(self): return '%s %s' % (self.first_name, self.last_name) def get_absolute_url(self): return "/contacts/%i/" % self.id #-- class Admin: pass class LeadForm(ModelForm): class Meta: model = Lead == Here is my views.py of the app "leads" == from django.db.models import Q from django.shortcuts import render_to_response from base.leads.models import * from django.forms.models import modelformset_factory from django.forms.models import inlineformset_factory def manage_lead (request): lead_id=1 person = Person.objects.get(pk=lead_id) address = Address.objects.get(pk=lead_id) LeadFormSet = inlineformset_factory(Lead, Address, Person) # If data was POSTed we're adding new lead if request.method == 'POST': formset = LeadFormSet(request.POST, request.FILES, instance=person, instance=address) if formset.is_valid(): # Form processing formset.save() # otherwise we're adding a form to be filled out else: formset = LeadFormSet() return render_to_response('leads/manage.html', { "formset": formset, }) == I know my "manage_lead" def isn't good, I'm still trying to find out how to do this. Basically what I want to do is get it so that I pass one formset to the render that is composed of both Person and Address forms. Thanks everyone! Also if there is a resource I can use to find answers to this 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 -~--~~~~--~~--~--~---
Using FormSet to deal with ForeignKey
Here's what my models.py class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) # employer = models.CharField(max_length=100) # position = models.CharField(max_length=50) email = models.EmailField() class Address(models.Model): line_1 = models.CharField(max_length=60) # line_2 = models.CharField(max_length=60,blank=True,null=True) city = models.CharField(max_length=30) state = USStateField() zip = models.CharField(max_length=10) # newsletter = models.BooleanField() # mail_opt_out = models.BooleanField() # phone_primary = models.CharField(max_length=12) # phone_secondary = models.CharField (max_length=12,blank=True,null=True) # phone_primary_type = models.ForeignKey(contact_phone_types, related_name='primary_set',blank=True,null=True) # phone_secondary_type = models.ForeignKey(contact_phone_types, related_name='secondary_set',blank=True,null=True) # email = models.EmailField(max_length=30,blank=True) # preferred = models.ForeignKey (contact_preferred,blank=True,null=True) class AddressForm(ModelForm): class Meta: model = Address class PersonForm(ModelForm): class Meta: model = Person class Lead(models.Model): # a lead is a person person = models.ForeignKey(Person); # a lead has address information address = models.ForeignKey(Address); # definitions def __unicode__(self): return '%s %s' % (self.first_name, self.last_name) def full_name(self): return '%s %s' % (self.first_name, self.last_name) def get_absolute_url(self): return "/contacts/%i/" % self.id #-- class LeadForm(ModelForm): class Meta: model = Lead class Admin: pass == views.py == def manage_lead (request): lead_id=1 person = Person.objects.get(pk=lead_id) address = Address.objects.get(pk=lead_id) LeadFormSet = inlineformset_factory(Lead, Address, Person) # If data was POSTed we're adding new lead if request.method == 'POST': formset = LeadFormSet(request.POST, request.FILES, instance=person, instance=address) if formset.is_valid(): # Form processing formset.save() # otherwise we're adding a form to be filled out else: formset = LeadFormSet() return render_to_response('leads/manage.html', { "formset": formset, }) What I have clealry won't work, but I'm wondering how to handle this situation. What I want is one formset that has the two ForeignKey's that are in Lead. Thanks so much. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need help writing file to specific directory
solved: os.chdir(path) Hope that helps someone! On Dec 20, 10:13 pm, Brandon Taylor wrote: > Hi everyone, > > I'm unpacking files in a .zip and need to save each file into a > particular directory, but I can't seem to find a way to set the > directory to save into. Here is part of my code where I'm opening > the .zip and iterating over the files: > > thumb_zip_file = zipfile.ZipFile(obj.thumbnail_image_zip_archive, 'r') > > for thumbnail_file in thumb_zip_file.infolist(): > fname = thumbnail_file.filename > data = thumb_zip_file.read(fname) > fout = open(fname, 'w') > fout.write(data) # <-- here's where I need to specify a > directory > fout.close() > > thumb_zip_file.close() > > Can anyone explain how to set the directory to write into? The above > code writes out the files from the .zip, but it writes them to my > project root. > > TIA, > Brandon --~--~-~--~~~---~--~~ 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: Formset and Classes with ForeignKeys
Think I found an answer here: http://www.djangosnippets.org/snippets/1248/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---