Re: how to tell apache to see my projects database file?
On Tue, 2012-05-29 at 23:29 -0700, doniyor wrote: > okay, now it said nothing, the command went well. but the page is > still > showing me error: unable to open database file. you need to chown -R www-data:www-data /directory_in_which_the_dbfile_is/ -- regards Kenneth Gonsalves -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to tell apache to see my projects database file?
it says, invalid group www-data. but look, i am logged in as root with 'su'. and i am doing all the commands here. is it correct, or should i be a normal user? this doesnot make big difference right? Am Mittwoch, 30. Mai 2012 09:00:49 UTC+2 schrieb lawgon: > > On Tue, 2012-05-29 at 23:29 -0700, doniyor wrote: > > okay, now it said nothing, the command went well. but the page is > > still > > showing me error: unable to open database file. > > you need to chown -R > www-data:www-data /directory_in_which_the_dbfile_is/ > -- > regards > Kenneth Gonsalves > > -- 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/-/uGHT_50l140J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to tell apache to see my projects database file?
On Wed, 2012-05-30 at 00:37 -0700, doniyor wrote: > it says, invalid group www-data. but look, i am logged in as root > with > 'su'. and i am doing all the commands here. is it correct, or should i > be a > normal user? this doesnot make big difference right? in that case there is no need to use sudo. Try: chown -R www-data /directory_in_which_the_dbfile_is/ -- regards Kenneth Gonsalves -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to tell apache to see my projects database file?
hey man, problem solved. i did *chown www-data. . *then *chmod 777 dbfile *now everything is working fine. thank you so much for your time and help. r u from europe? Am Mittwoch, 30. Mai 2012 09:49:33 UTC+2 schrieb lawgon: > > On Wed, 2012-05-30 at 00:37 -0700, doniyor wrote: > > it says, invalid group www-data. but look, i am logged in as root > > with > > 'su'. and i am doing all the commands here. is it correct, or should i > > be a > > normal user? this doesnot make big difference right? > > in that case there is no need to use sudo. Try: > chown -R www-data /directory_in_which_the_dbfile_is/ > -- > regards > Kenneth Gonsalves > > -- 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/-/WMNVgbKU0AQJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to generate secure passwords
I want to sell passwords to users. If I can generate passwords for them that can last for a specific period of time (the time they have paid for) this would be good. If the user generates there own I cannot restrict them from viewing certain content don't want them to view... My problem is that a user has to pay some money to view content on my page for a certain period of time and this looks like a good way; a password that can expire... When it expires, they have to buy another pass word. Emily On Wed, May 30, 2012 at 9:51 AM, wrote: > Hi, > Are you trying to create passwords on behalf of users? This is usually a > bad idea. > > If I got your message wrong and you talk about secure password hashes, is > there something specific you did not like about the current Django auth > system? > > Or maybe you are interested in password complexity requirements? It's > really difficult to guess. Please describe the problem you're trying to > solve a bit better. > > Cheers > >Jirka > > > -Original Message- > From: Emily Namugaanyi > Sender: django-users@googlegroups.com > Date: Tue, 29 May 2012 23:03:39 > To: Django users > Reply-To: django-users@googlegroups.com > Subject: How to generate secure passwords > > Hi Django users, > > I am working on a project that as to generate secure passwords > (passwords that cannot be hacked) every time a user register and the > password lasts for a period of time. S,here I am wondering whether > django has a provision for this or I need to find another way... > Thank you for your time > > Emily. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to generate secure passwords
Like QR codes but those that can expire... Emily On Wed, May 30, 2012 at 11:18 AM, Emily wrote: > I want to sell passwords to users. If I can generate passwords > for them that can last for a specific period of time (the time they > have paid for) this would be good. > > If the user generates there own I cannot restrict them from viewing > certain content don't want them to view... > > My problem is that a user has to pay some money to view content on > my page for a certain period of time and this looks like a good way; a > password that can expire... When it expires, they have to buy another > pass word. > > Emily > > > On Wed, May 30, 2012 at 9:51 AM, wrote: > >> Hi, >> Are you trying to create passwords on behalf of users? This is usually >> a bad idea. >> >> If I got your message wrong and you talk about secure password hashes, >> is there something specific you did not like about the current Django auth >> system? >> >> Or maybe you are interested in password complexity requirements? It's >> really difficult to guess. Please describe the problem you're trying to >> solve a bit better. >> >> Cheers >> >>Jirka >> >> >> -Original Message- >> From: Emily Namugaanyi >> Sender: django-users@googlegroups.com >> Date: Tue, 29 May 2012 23:03:39 >> To: Django users >> Reply-To: django-users@googlegroups.com >> Subject: How to generate secure passwords >> >> Hi Django users, >> >> I am working on a project that as to generate secure passwords >> (passwords that cannot be hacked) every time a user register and the >> password lasts for a period of time. S,here I am wondering whether >> django has a provision for this or I need to find another way... >> Thank you for your time >> >> Emily. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- You received this message because you are subscribed to the Google 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.
Checkbox becomes combox ... why ?
Hi all. I want to create a checkbox in my user register page, all of my code as below: from django.utils.translation import ugettext as _ import sys import datetime reload(sys) sys.setdefaultencoding('utf8') from django.db import models from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from django.contrib.auth.models import Group from django.db.models.signals import post_save from django.contrib import admin from django.contrib.auth.forms import UserCreationForm from django import forms from django.contrib.admin import widgets from datetime import datetime from django.contrib.admin.filterspecs import FilterSpec, DateFieldFilterSpec from django.utils.translation import ugettext as _ from datetime import datetime from django.forms import ModelMultipleChoiceField TYPES = ( ('yes', 'Yes'), ('no', 'No'), ('maybe', 'Maybe'), ) class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) timestamp = models.DateTimeField(_("timestamp")) credit = models.DecimalField(_("credit"), max_digits = 8, decimal_places = 1) ipaddress = models.IPAddressField() nickname = models.CharField(_("nickname"), max_length = 8) game_type = models.CharField(choices = TYPES, max_length = 12) class UserProfileInline(admin.StackedInline): model = UserProfile class UserAdmin(UserAdmin): inlines = [UserProfileInline,] list_display = ('username', 'nickname', 'credit', 'leave', 'is_active', 'date_join', 'timestamp', 'ipaddress') list_filter = ('is_active',) def credit(self, instance): return instance.get_profile().credit def timestamp(self, instance): return instance.get_profile().timestamp.strftime('%Y/%m/%d %I:%H') def ipaddress(self, instance): return instance.get_profile().ipaddress def nickname(self, instance): return instance.get_profile().nickname def leave(self, instance): return instance.get_profile().credit - 1 def date_join(self, instance): return instance.date_joined.strftime('%Y/%m/%d %I:%H') credit.short_description = _("credit") nickname.short_description = _("nickname") timestamp.short_description = _("timestamp") leave.short_description = _("leave") date_join.short_description =_("date_join") class RegisterForm(UserCreationForm): timestamp = forms.DateTimeField(required=True, label=_("timestamp"), widget=widgets.AdminDateWidget()) credit = forms.DecimalField(label=_("credit")) nickname = forms.CharField(label=_("nickname")) game_type = forms.MultipleChoiceField(required=False, widget=forms.CheckboxSelectMultiple(), choices = TYPES) class Meta: model = User fields = ("username", _("timestamp"), _("credit"), _("nickname"), _("date_join"), _("game_type")) def save(self, commit=True): user = super(RegisterForm, self).save(commit=False) user.timestamp = self.cleaned_data["timestamp"] user.credit = self.cleaned_data["credit"] user.nickname = self.cleaned_data["nickname"] if commit: user.save() return user admin.site.unregister(User) admin.site.register(User, UserAdmin) Filed "game_type" is a check box widget, BUT when I render the register page, It doesn't render to a checkbot but a combobox. I don't why, thanks for reading my problem. -- 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/-/khHsVmf-ivwJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to tell apache to see my projects database file?
On Wed, 2012-05-30 at 01:11 -0700, doniyor wrote: > hey man, problem solved. i did *chown www-data. . *then *chmod 777 > dbfile *now > everything is working fine. thank you so much for your time and help. > > r u from europe? no -- regards Kenneth Gonsalves -- You received this message because you are subscribed to the Google 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.
Scaling django installation
As the subject suggests, wanted to discuss, acquire and share some knowledge on scaling django installation. Firstly, my current project is a product Reviews platform, and I wanted to benchmark or load test the current deployment. Currently the deployment/installation stands on a single server setup. - Single Amazon EC2 instance m1.xlarge - Apache Webserver (serving django and static) To load test I used loadimpact.com and the results of which can be found on: http://loadimpact.com/load-test/www.reviews42.com-18774e46e8f562a6eb4009495cf9d752 The test configuration consisted of 600 VUs with 10 mins step duration. Got around .1 millions requests and around 200+ requests/sec max. Is this good, bad, or at par? - What might be the possible suggestions for scaling this installation? - Does separating out media server helps much, and upto what extent? - Can a single server setup handle 1k to 10k requests/sec? - Some tools for benchmarking and performance testing? - Other cost effective ways to scale up the installation? - What sort of django installation needs to be there to handle 10k requests/sec and .1 million parallel users at all time? - Any good reads on scaling/scalable django deployment or installation. Sort of guide. -- Thanks, Subhranath Chunder. www.subhranath.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is Django Right for Me?
can you explain your question more clearly ? Djanjo is a *FULL STACK* web dev framework 2012/5/30 kenneth gonsalves > On Tue, 2012-05-29 at 09:05 -0500, Javier Guerra Giraldez wrote: > > On Tue, May 29, 2012 at 7:33 AM, KevinE > > wrote: > > > Just one question - why would django avoid an offline mode - is that > > a > > > completely unreasonable/undo-able extension? > > > > Django is a web server framework. when you're offline, you don't have > > a server. > > you can run a webserver on a netbook or laptop and run django too. If > you use sqllite, it is dead easy to sync your local db with the one on > the net the moment you get connectivity. > -- > regards > Kenneth Gonsalves > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django Generic Class Based Views - Change Content-Type
Hi there, Firstly I would like to say how awesome Django is and as a long time user I am stoked at the 1.4 changes and coming 1.5 :) I have a minor question and looking through the source (although maybe i missed it) I cant seem to see how to change the HttpResponse content_type of a Generic class based view. Anyone point me in the right direction or know the answer outright? all the best Ross -- 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/-/KNUT3wm_lW0J. 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 Django Right for Me?
On Wed, 2012-05-30 at 13:58 +0800, 马龙 wrote: > can you explain your question more clearly ? Djanjo is a *FULL STACK* > web > dev framework is this addressed to me or to the OP? If it is to me, as an example, I have a django site that monitors and reports on various construction and other activities. The supervisor goes to the villages with netbooks. If there is connectivity, he enters the data directly to the server on the internet. If not, he has a local copy of the site running on his netbook with a local copy of the database, synced before he leaves his office. So he enters the data on that and later syncs it with the server. It is not rocket science to write the scripts for syncing. -- regards Kenneth Gonsalves -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to generate secure passwords
30.5.2012 9:03, Emily Namugaanyi kirjoitti: Hi Django users, I am working on a project that as to generate secure passwords (passwords that cannot be hacked) every time a user register and the password lasts for a period of time. S,here I am wondering whether django has a provision for this or I need to find another way... Thank you for your time Emily. Sounds like your problem is not about generatic "secure passwords". But instead you need to build secure authorization behind that. So you have to build a system that checks is given username + password to protected content combination already expired. If that's the case, no access is granted to protected content. Then password wouldn't contain any information about it's validity. Only validity checks happens on your side of system - in your code, on your server. -- Jani Tiainen - Well planned is half done and a half done has been sufficient before... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to tell apache to see my projects database file?
On 5/30/12 1:11 AM, doniyor wrote: hey man, problem solved. i did *chown www-data. . *then *chmod 777 dbfile *now everything is working fine. thank you so much for your time and help. I've lost track of the early parts of this thread, but chmod 777 on a database rarely indicates that everything is fine. The chown did not matter much once you gave everyone in the universe write access to the database. This issue started as a permissions problem and still is a permissions problem. Figure out which user is actually accessing your database and get the permissions you need. 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-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.
form-wizard
Hi, I want to use a form wizard to modify instead of create an instance in the DDBB. I don't know exactly how I can do it because in the URL there is the information of the instance to modify and the step in the form, so I don't know how I can mix everything. I am using django-merlin for the wizard (older code), but I think I have the same problem in the wizard provided by django. How can I start a wizard with a form already filled? My code is like this: url(r"^event_management/modify/(?P\w+)/(?P[A-Za-z0-9_-]+)/$$", forms.EventManagementModifyWizard([Step('0', EventForm),]), ), And I would like to receive the pk and slug parameters, pk referes to the instance to modify, and slug is the step of the form. If you need further code information just let me know. Thanks, Xavi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to use an optional ForeignKey to sites.Site and admin's "View on site"?
Actually, you can have a nullable ForeignKey (and there can be good reasons for this). This is mentioned in the docs themselves; see: https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete I am not sure about the error that the OP is encountering. On May 29, 7:47 pm, Thomas Lockhart wrote: > ...> Hi, > > > I have a model which has a ForeignKey to the Django contrib sites.Site > > model. This field should be optional. > > If it is optional it is not a foreign key. You can put a constraint on > the field to have a non-null value be present in the other table, and > perhaps there is a way to do this from a django model but I haven't > looked at 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-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to use an optional ForeignKey to sites.Site and admin's "View on site"?
Indeed, I'm using optional (and nullable) ForeignKeys in other places as well. The problem with an optional ForeignKey to Django's contrib sites.Site model, is that it breaks the "View on site" button in the admin section. near line 60 in /django/contrib/contenttypes/views.py: object_domain = getattr(obj, field.name).domain So, is this a bug? Or did I miss something? Dirk On 30 mei 2012, at 15:24, Derek wrote: > Actually, you can have a nullable ForeignKey (and there can be good > reasons for this). This is mentioned in the docs themselves; see: > https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete > > I am not sure about the error that the OP is encountering. > > > On May 29, 7:47 pm, Thomas Lockhart wrote: >> ...> Hi, >> >>> I have a model which has a ForeignKey to the Django contrib sites.Site >>> model. This field should be optional. >> >> If it is optional it is not a foreign key. You can put a constraint on >> the field to have a non-null value be present in the other table, and >> perhaps there is a way to do this from a django model but I haven't >> looked at 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-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. > > > -- - Dirk van Oosterbosch de Wittenstraat 225 1052 AT Amsterdam the Netherlands http://labs.ixopusada.com - -- -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Python IDLE
On Mon, May 28, 2012 at 12:25 PM, Dennis Lee Bieber wrote: > On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid > declaimed the following in > gmane.comp.python.django.user: > >> I'm in a big mess now, I've lost my projects due to this errror. I'm >> on windows, This is how I encounter the problem; I try to edit my >> settings.py in IDLE. After right clicking on the files, I choose open >> program with these default file. I choose idle window bat file, and I >> clicked Ok. It didn't open, I try to run manage.py runserver on my >> DOS. Not working, it will pop up the IDLE Shell and mange.py script by >> displaying it in IDLE. It didn't run the server. The logo of my python >> files have changed. How can I revert it back to open with IDLE? And >> use it as default for my python script? > > IDLE itself is a Python script; though it sounds like you (or > someone) created a Windows BAT file to act as an intermediate. > > The main problem appears to be that you've associated the "open" > action with /IDLE/... The normal "open" action for Python (.py) script > files should be Python.exe (or Pythonw.exe for .pyw). For editing you > should have/create a "Edit" action that invokes your IDLE > BAT file. > > You'll need to work with the file association commands in Windows to > reset things so that "open" means RUN the script. > > Unfortunately, different installations have used different names for > the file types. Here are mine (I had to do "ftype" with no arguments and > scan the long output to find the Python entries): > > E:\UserData\Wulfraed\My Documents>ftype py_auto_file > py_auto_file="E:\Python25\python.exe" "%1" %* > > E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file > pyw_auto_file="E:\Python25\pythonw.exe" "%1" > > > Note that ftype only defines the "open"/"run" action for a file. > (Interesting -- the .pyw doesn't take command line arguments, probably > to be expected for a double-click open). > > The other half of the basic equation is the file extension to "file > type" association: > > E:\UserData\Wulfraed\My Documents>assoc .py > .py=py_auto_file > > E:\UserData\Wulfraed\My Documents>assoc .pyc > File association not found for extension .pyc > > E:\UserData\Wulfraed\My Documents>assoc .pyw > .pyw=pyw_auto_file > > (This is why I commented that the file type name may differ between > installs -- the assoc is > <.extension> = > and ftype is > = > As long as the same is used in both commands the linkage > works) > > That SHOULD clear up the double-click/Open/command line > running of Python scripts. Setting up an Edit action (on WinXP) requires > going through either the registry by hand, or opening a directory > window, > > Tools/Folder Options > File Types (tab) > scroll down to PY and PYW entries, select one > Details should show "Opens with: python" (or pythonw) > [Advanced] > the default action should be "open" (bold). If there is no "edit" > action, click [New...] > > Give it Action name "edit" (or "edit with IDLE") > Application used to perform action: full path to the IDLE.BAT file > (in quotes) followed by "%1" (with quotes) for the argument placeholder > (the file to be edited). > Might need to [x] Use DDE; set "Application" to IDLE, set Topic to > System > > {NOTE: I'm paraphrasing from the edit action on my system which uses > "E:\Python25\Lib\site-packages\pythonwin\Pythonwin.exe" "%1"} > {I'm not sure if you could skip the BAT file and use > "path/to/python.exe" "path/to/IDLE.py" "%1" > instead} > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ Last I used it (I've been blessedly Windows free for some time now), IDLE's editor was fine for editing Python (everyone has their own favorite code editor), at least giving nice syntax highlighting and correct (for Python) treatment of the tab key. But it is not really an IDE (except maybe for projects that are one file, or maybe one folder). I'm sure that there are many fine Windows specific solutions. (Someone mentioned NOTEPAD++. I can't comment, but the list is pretty good at that sort of judgement.) But let me suggest that you learn to use a tool that is available on multiple platforms. (If you deploy a site commercially, your costs, flexibility, and perhaps performance, will likely be better on a Linux or BSD based VPS or shared host.) My personal favorite is emacs, but it can be easier to use vim remotely, and it is more likely to be pre-installed. Yes, there are native Windows implementations of both, independent of running builds of *nix configurations under cygwin. While IDLE does run everywhere, it requires access to the GUI, which can be annoying on a VPS. Though you can edit locally and push your changes to your VPS using your revision control system, there are just some times that you have to edit on your VPS via an
Re: Python IDLE
You seriously have to give PyCharm a go. It's everything IDE should be and loves django. On 30 May 2012 23:40, Bill Freeman wrote: > On Mon, May 28, 2012 at 12:25 PM, Dennis Lee Bieber > wrote: > > On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid > > declaimed the following in > > gmane.comp.python.django.user: > > > >> I'm in a big mess now, I've lost my projects due to this errror. I'm > >> on windows, This is how I encounter the problem; I try to edit my > >> settings.py in IDLE. After right clicking on the files, I choose open > >> program with these default file. I choose idle window bat file, and I > >> clicked Ok. It didn't open, I try to run manage.py runserver on my > >> DOS. Not working, it will pop up the IDLE Shell and mange.py script by > >> displaying it in IDLE. It didn't run the server. The logo of my python > >> files have changed. How can I revert it back to open with IDLE? And > >> use it as default for my python script? > > > >IDLE itself is a Python script; though it sounds like you (or > > someone) created a Windows BAT file to act as an intermediate. > > > >The main problem appears to be that you've associated the "open" > > action with /IDLE/... The normal "open" action for Python (.py) script > > files should be Python.exe (or Pythonw.exe for .pyw). For editing you > > should have/create a "Edit" action that invokes your IDLE > > BAT file. > > > >You'll need to work with the file association commands in Windows > to > > reset things so that "open" means RUN the script. > > > >Unfortunately, different installations have used different names > for > > the file types. Here are mine (I had to do "ftype" with no arguments and > > scan the long output to find the Python entries): > > > > E:\UserData\Wulfraed\My Documents>ftype py_auto_file > > py_auto_file="E:\Python25\python.exe" "%1" %* > > > > E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file > > pyw_auto_file="E:\Python25\pythonw.exe" "%1" > > > > > >Note that ftype only defines the "open"/"run" action for a file. > > (Interesting -- the .pyw doesn't take command line arguments, probably > > to be expected for a double-click open). > > > >The other half of the basic equation is the file extension to > "file > > type" association: > > > > E:\UserData\Wulfraed\My Documents>assoc .py > > .py=py_auto_file > > > > E:\UserData\Wulfraed\My Documents>assoc .pyc > > File association not found for extension .pyc > > > > E:\UserData\Wulfraed\My Documents>assoc .pyw > > .pyw=pyw_auto_file > > > > (This is why I commented that the file type name may differ between > > installs -- the assoc is > ><.extension> = > > and ftype is > > = > > As long as the same is used in both commands the linkage > > works) > > > >That SHOULD clear up the double-click/Open/command > line > > running of Python scripts. Setting up an Edit action (on WinXP) requires > > going through either the registry by hand, or opening a directory > > window, > > > > Tools/Folder Options > > File Types (tab) > >scroll down to PY and PYW entries, select one > >Details should show "Opens with: python" (or pythonw) > > [Advanced] > >the default action should be "open" (bold). If there is no "edit" > > action, click [New...] > > > >Give it Action name "edit" (or "edit with IDLE") > >Application used to perform action: full path to the IDLE.BAT file > > (in quotes) followed by "%1" (with quotes) for the argument placeholder > > (the file to be edited). > >Might need to [x] Use DDE; set "Application" to IDLE, set Topic to > > System > > > > {NOTE: I'm paraphrasing from the edit action on my system which uses > > "E:\Python25\Lib\site-packages\pythonwin\Pythonwin.exe" "%1"} > > {I'm not sure if you could skip the BAT file and use > >"path/to/python.exe" "path/to/IDLE.py" "%1" > > instead} > > > > -- > >Wulfraed Dennis Lee Bieber AF6VN > >wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ > > Last I used it (I've been blessedly Windows free for some time now), > IDLE's editor was fine for editing Python (everyone has their own > favorite code editor), at least giving nice syntax highlighting and > correct (for Python) treatment of the tab key. But it is not really > an IDE (except maybe for projects that are one file, or maybe one > folder). > > I'm sure that there are many fine Windows specific solutions. > (Someone mentioned NOTEPAD++. I can't comment, but the list is pretty > good at that sort of judgement.) But let me suggest that you learn to > use a tool that is available on multiple platforms. (If you deploy a > site commercially, your costs, flexibility, and perhaps performance, > will likely be better on a Linux or BSD based VPS or shared host.) My > personal favorite is emacs, but it can be easier to use vim remotely, > and it is more likely to be pre-installed. Yes, there are native > Win
Re: A signal, or equivalent, for when all apps are loaded?
On Tue, May 29, 2012 at 7:35 PM, Russell Keith-Magee wrote: > On Wed, May 30, 2012 at 4:42 AM, Bill Freeman wrote: >> I continue to struggle with occasional circular import problems >> (caused by a combination of haystack, filebrowser, and a model which >> both has a search_indexes.py and a model that has a filebrowser >> field). >> >> I had thought that I had patched the issue by importing haystack in my >> root urlconf (the problem doesn't happen under the development server >> because it "validates models" early, but the import order was >> different in production). But: 1, I kept having to add "import >> haystack" to my management commands; and 2, it still occasionally >> fails on restart (a timing hazard of some kind). >> >> It strikes me that one fix would be to defer haystack's scan of the >> INSTALLED_APPS until all the apps have been loaded. But when is that? >> I can ask django.db.models.loading.app_cache_ready(), but it will say >> False when haystack (or its models.py, which it has, despite not >> having any models) is being imported (since the list of apps being >> cached can't be finished until haystack.models import has finished). >> So when could I run it again? It would be nice to register for an >> "apps are loaded" signal, but I don't see on in the docs, and there is >> no evidence of sending one in django.db.models.loading.AppCache. >> >> Is there a right way to get something called after all the models have >> been imported? (Django 1.3) > > Unfortunately, there isn't. This is a long standing problem, and one > that the app-refactor was looking into; however, that effort hasn't > come to fruition. Django's startup sequence is an area where some work > is required. The closest thing to a "signal" you're going to get is to > hook into the URL configuration, in the same way the admin > registration process does -- but it looks like you've tried that and > haven't had any luck. > > One trick that I'm aware of that *might* work in your case is to force > the validation code to run in your production stack -- for example, as > a call in your WSGI container. From a functional perspective, this is > an expensive no-op. The validation won't ever return a different > result, which is why Django's WSGI handler doesn't call validate. > However, the process of validation *does* cause the startup sequence > to be a little more predictable, because the validation mechanism > imports *all* your app modules in your project in a predictable order. > If your problem is being caused by an unpredictable import order, > forcing a specific import order may work around your problem (or at > least make the side effects more predictable, and match the behaviour > of the development server). > > Yours > Russ Magee %-) Thanks Russ. I guess that I could just try importing django.db.models in my wsgi file (in turn imports django.db.models.loading, which initializes the AppCache) as a validation equivalent? Bill -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to tell apache to see my projects database file?
what do you mean? should i do better chmod 755 which is more secure than 777? Am Mittwoch, 30. Mai 2012 14:29:14 UTC+2 schrieb Thomas: > On 5/30/12 1:11 AM, doniyor wrote: > > hey man, problem solved. i did *chown www-data. . *then *chmod 777 > dbfile *now everything is working fine. thank you so much for your time > and help. > > I've lost track of the early parts of this thread, but chmod 777 on a > database rarely indicates that everything is fine. The chown did not matter > much once you gave everyone in the universe write access to the database. > > This issue started as a permissions problem and still is a permissions > problem. Figure out which user is actually accessing your database and get > the permissions you need. > > hth > >- Tom > > -- 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/-/UOlT738Mi6gJ. 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: Python IDLE
@somecallitblues: pycharm is not free, right? but i am really willing to give a try for this. i am using for years Aptana studio which is completely fullfulling my wishes, but "pycharm loves django" sounds great! Am Mittwoch, 30. Mai 2012 15:59:13 UTC+2 schrieb somecallitblues: > You seriously have to give PyCharm a go. It's everything IDE should be and > loves django. > > On 30 May 2012 23:40, Bill Freeman wrote: > >> On Mon, May 28, 2012 at 12:25 PM, Dennis Lee Bieber >> wrote: >> > On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid >> > declaimed the following in >> > gmane.comp.python.django.user: >> > >> >> I'm in a big mess now, I've lost my projects due to this errror. I'm >> >> on windows, This is how I encounter the problem; I try to edit my >> >> settings.py in IDLE. After right clicking on the files, I choose open >> >> program with these default file. I choose idle window bat file, and I >> >> clicked Ok. It didn't open, I try to run manage.py runserver on my >> >> DOS. Not working, it will pop up the IDLE Shell and mange.py script by >> >> displaying it in IDLE. It didn't run the server. The logo of my python >> >> files have changed. How can I revert it back to open with IDLE? And >> >> use it as default for my python script? >> > >> >IDLE itself is a Python script; though it sounds like you (or >> > someone) created a Windows BAT file to act as an intermediate. >> > >> >The main problem appears to be that you've associated the "open" >> > action with /IDLE/... The normal "open" action for Python (.py) script >> > files should be Python.exe (or Pythonw.exe for .pyw). For editing you >> > should have/create a "Edit" action that invokes your IDLE >> > BAT file. >> > >> >You'll need to work with the file association commands in >> Windows to >> > reset things so that "open" means RUN the script. >> > >> >Unfortunately, different installations have used different names >> for >> > the file types. Here are mine (I had to do "ftype" with no arguments and >> > scan the long output to find the Python entries): >> > >> > E:\UserData\Wulfraed\My Documents>ftype py_auto_file >> > py_auto_file="E:\Python25\python.exe" "%1" %* >> > >> > E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file >> > pyw_auto_file="E:\Python25\pythonw.exe" "%1" >> > >> > >> >Note that ftype only defines the "open"/"run" action for a file. >> > (Interesting -- the .pyw doesn't take command line arguments, probably >> > to be expected for a double-click open). >> > >> >The other half of the basic equation is the file extension to >> "file >> > type" association: >> > >> > E:\UserData\Wulfraed\My Documents>assoc .py >> > .py=py_auto_file >> > >> > E:\UserData\Wulfraed\My Documents>assoc .pyc >> > File association not found for extension .pyc >> > >> > E:\UserData\Wulfraed\My Documents>assoc .pyw >> > .pyw=pyw_auto_file >> > >> > (This is why I commented that the file type name may differ between >> > installs -- the assoc is >> ><.extension> = >> > and ftype is >> > = >> > As long as the same is used in both commands the linkage >> > works) >> > >> >That SHOULD clear up the double-click/Open/command >> line >> > running of Python scripts. Setting up an Edit action (on WinXP) requires >> > going through either the registry by hand, or opening a directory >> > window, >> > >> > Tools/Folder Options >> > File Types (tab) >> >scroll down to PY and PYW entries, select one >> >Details should show "Opens with: python" (or pythonw) >> > [Advanced] >> >the default action should be "open" (bold). If there is no "edit" >> > action, click [New...] >> > >> >Give it Action name "edit" (or "edit with IDLE") >> >Application used to perform action: full path to the IDLE.BAT >> file >> > (in quotes) followed by "%1" (with quotes) for the argument placeholder >> > (the file to be edited). >> >Might need to [x] Use DDE; set "Application" to IDLE, set Topic >> to >> > System >> > >> > {NOTE: I'm paraphrasing from the edit action on my system which uses >> > "E:\Python25\Lib\site-packages\pythonwin\Pythonwin.exe" "%1"} >> > {I'm not sure if you could skip the BAT file and use >> >"path/to/python.exe" "path/to/IDLE.py" "%1" >> > instead} >> > >> > -- >> >Wulfraed Dennis Lee Bieber AF6VN >> >wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ >> >> Last I used it (I've been blessedly Windows free for some time now), >> IDLE's editor was fine for editing Python (everyone has their own >> favorite code editor), at least giving nice syntax highlighting and >> correct (for Python) treatment of the tab key. But it is not really >> an IDE (except maybe for projects that are one file, or maybe one >> folder). >> >> I'm sure that there are many fine Windows specific solutions. >> (Someone mentioned NOTEPAD++. I can't comment, but the list is pretty >> good at that sort of
Re: Django Generic Class Based Views - Change Content-Type
Hi Ross, On Wed, May 30, 2012 at 3:59 AM, Ross C wrote: > I have a minor question and looking through the source (although maybe i > missed it) I cant seem to see how to change the HttpResponse content_type of > a Generic class based view. > > Anyone point me in the right direction or know the answer outright? First of all check out the TemplateResponse[0] and then the TemplateResponseMixin[1] specifically render_to_response() where you can subclass and call super() with new kwargs. In the case you are looking for adding 'content_type' to the kwargs, to change it to whatever you want. Simply add the following to your view: def render_to_response(self, context, **response_kwargs): response_kwargs.update({'content_type': 'yyy/xxx'}) return super(MyView, self).render_to_response(context, **response_kwargs) Regards, Iván [0] https://docs.djangoproject.com/en/dev/ref/template-response/ [1] https://docs.djangoproject.com/en/dev/ref/class-based-views/#templateresponsemixin -- You received this message because you are subscribed to the Google 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: Python IDLE
It's not free but they have a 30 day trial period On 31 May 2012 00:09, doniyor wrote: > @somecallitblues: pycharm is not free, right? but i am really willing to > give a try for this. i am using for years Aptana studio which is completely > fullfulling my wishes, but "pycharm loves django" sounds great! > > Am Mittwoch, 30. Mai 2012 15:59:13 UTC+2 schrieb somecallitblues: > >> You seriously have to give PyCharm a go. It's everything IDE should be >> and loves django. >> >> On 30 May 2012 23:40, Bill Freeman wrote: >> >>> On Mon, May 28, 2012 at 12:25 PM, Dennis Lee Bieber >>> wrote: >>> > On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid >>> > declaimed the following in >>> > gmane.comp.python.django.user: >>> > >>> >> I'm in a big mess now, I've lost my projects due to this errror. I'm >>> >> on windows, This is how I encounter the problem; I try to edit my >>> >> settings.py in IDLE. After right clicking on the files, I choose open >>> >> program with these default file. I choose idle window bat file, and I >>> >> clicked Ok. It didn't open, I try to run manage.py runserver on my >>> >> DOS. Not working, it will pop up the IDLE Shell and mange.py script by >>> >> displaying it in IDLE. It didn't run the server. The logo of my python >>> >> files have changed. How can I revert it back to open with IDLE? And >>> >> use it as default for my python script? >>> > >>> >IDLE itself is a Python script; though it sounds like you (or >>> > someone) created a Windows BAT file to act as an intermediate. >>> > >>> >The main problem appears to be that you've associated the "open" >>> > action with /IDLE/... The normal "open" action for Python (.py) script >>> > files should be Python.exe (or Pythonw.exe for .pyw). For editing you >>> > should have/create a "Edit" action that invokes your IDLE >>> > BAT file. >>> > >>> >You'll need to work with the file association commands in >>> Windows to >>> > reset things so that "open" means RUN the script. >>> > >>> >Unfortunately, different installations have used different >>> names for >>> > the file types. Here are mine (I had to do "ftype" with no arguments >>> and >>> > scan the long output to find the Python entries): >>> > >>> > E:\UserData\Wulfraed\My Documents>ftype py_auto_file >>> > py_auto_file="E:\Python25\**python.exe" "%1" %* >>> > >>> > E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file >>> > pyw_auto_file="E:\Python25\**pythonw.exe" "%1" >>> > >>> > >>> >Note that ftype only defines the "open"/"run" action for a file. >>> > (Interesting -- the .pyw doesn't take command line arguments, probably >>> > to be expected for a double-click open). >>> > >>> >The other half of the basic equation is the file extension to >>> "file >>> > type" association: >>> > >>> > E:\UserData\Wulfraed\My Documents>assoc .py >>> > .py=py_auto_file >>> > >>> > E:\UserData\Wulfraed\My Documents>assoc .pyc >>> > File association not found for extension .pyc >>> > >>> > E:\UserData\Wulfraed\My Documents>assoc .pyw >>> > .pyw=pyw_auto_file >>> > >>> > (This is why I commented that the file type name may differ between >>> > installs -- the assoc is >>> ><.extension> = >>> > and ftype is >>> > = >>> > As long as the same is used in both commands the linkage >>> > works) >>> > >>> >That SHOULD clear up the double-click/**Open/command >>> line >>> > running of Python scripts. Setting up an Edit action (on WinXP) >>> requires >>> > going through either the registry by hand, or opening a directory >>> > window, >>> > >>> > Tools/Folder Options >>> > File Types (tab) >>> >scroll down to PY and PYW entries, select one >>> >Details should show "Opens with: python" (or pythonw) >>> > [Advanced] >>> >the default action should be "open" (bold). If there is no >>> "edit" >>> > action, click [New...] >>> > >>> >Give it Action name "edit" (or "edit with IDLE") >>> >Application used to perform action: full path to the IDLE.BAT >>> file >>> > (in quotes) followed by "%1" (with quotes) for the argument placeholder >>> > (the file to be edited). >>> >Might need to [x] Use DDE; set "Application" to IDLE, set Topic >>> to >>> > System >>> > >>> > {NOTE: I'm paraphrasing from the edit action on my system which uses >>> > "E:\Python25\Lib\site-**packages\pythonwin\Pythonwin.**exe" "%1"} >>> > {I'm not sure if you could skip the BAT file and use >>> >"path/to/python.exe" "path/to/IDLE.py" "%1" >>> > instead} >>> > >>> > -- >>> >Wulfraed Dennis Lee Bieber AF6VN >>> >wlfr...@ix.netcom.com >>> > HTTP://wlfraed.home.netcom.**com/ >>> >>> Last I used it (I've been blessedly Windows free for some time now), >>> IDLE's editor was fine for editing Python (everyone has their own >>> favorite code editor), at least giving nice syntax highlighting and >>> correct (for Python) treatment of the tab key. But it is not really >>> an IDE (excep
Re: How to generate secure passwords
On Wed, May 30, 2012 at 8:17 AM, Jani Tiainen wrote: > 30.5.2012 9:03, Emily Namugaanyi kirjoitti: > >> Hi Django users, >> >> I am working on a project that as to generate secure passwords >> (passwords that cannot be hacked) every time a user register and the >> password lasts for a period of time. S,here I am wondering whether >> django has a provision for this or I need to find another way... >> Thank you for your time >> >> Emily. >> > > Sounds like your problem is not about generatic "secure passwords". But > instead you need to build secure authorization behind that. > > So you have to build a system that checks is given username + password to > protected content combination already expired. If that's the case, no access > is granted to protected content. > > Then password wouldn't contain any information about it's validity. Only > validity checks happens on your side of system - in your code, on your > server. > > -- > Jani Tiainen > > - Well planned is half done and a half done has been sufficient before... django.contrib.auth.models.User has support for being tied to a "profile" model of your design. You can include an expiration date field (or several, if the user separately pays for different areas of the site) in this model. While you might allow the user to edit other fields in his profile, you do not permit him to change these fields. Instead they are set by you payment system. The user then identifies himself with a standard django username and passowrd, and the controlled page views check the (appropriate to the section) expiration date. This seems better to me than changing the password at renewal. Bill -- You received this message because you are subscribed to the Google 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: Python IDLE
Does it do emacs key bindings ;^) On Wed, May 30, 2012 at 10:13 AM, Mario Gudelj wrote: > It's not free but they have a 30 day trial period > > > On 31 May 2012 00:09, doniyor wrote: >> >> @somecallitblues: pycharm is not free, right? but i am really willing to >> give a try for this. i am using for years Aptana studio which is completely >> fullfulling my wishes, but "pycharm loves django" sounds great! >> >> Am Mittwoch, 30. Mai 2012 15:59:13 UTC+2 schrieb somecallitblues: >>> >>> You seriously have to give PyCharm a go. It's everything IDE should be >>> and loves django. >>> >>> On 30 May 2012 23:40, Bill Freeman wrote: On Mon, May 28, 2012 at 12:25 PM, Dennis Lee Bieber wrote: > On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid > declaimed the following in > gmane.comp.python.django.user: > >> I'm in a big mess now, I've lost my projects due to this errror. I'm >> on windows, This is how I encounter the problem; I try to edit my >> settings.py in IDLE. After right clicking on the files, I choose open >> program with these default file. I choose idle window bat file, and I >> clicked Ok. It didn't open, I try to run manage.py runserver on my >> DOS. Not working, it will pop up the IDLE Shell and mange.py script >> by >> displaying it in IDLE. It didn't run the server. The logo of my >> python >> files have changed. How can I revert it back to open with IDLE? And >> use it as default for my python script? > > IDLE itself is a Python script; though it sounds like you (or > someone) created a Windows BAT file to act as an intermediate. > > The main problem appears to be that you've associated the > "open" > action with /IDLE/... The normal "open" action for Python (.py) script > files should be Python.exe (or Pythonw.exe for .pyw). For editing you > should have/create a "Edit" action that invokes your IDLE > BAT file. > > You'll need to work with the file association commands in > Windows to > reset things so that "open" means RUN the script. > > Unfortunately, different installations have used different > names for > the file types. Here are mine (I had to do "ftype" with no arguments > and > scan the long output to find the Python entries): > > E:\UserData\Wulfraed\My Documents>ftype py_auto_file > py_auto_file="E:\Python25\python.exe" "%1" %* > > E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file > pyw_auto_file="E:\Python25\pythonw.exe" "%1" > > > Note that ftype only defines the "open"/"run" action for a > file. > (Interesting -- the .pyw doesn't take command line arguments, probably > to be expected for a double-click open). > > The other half of the basic equation is the file extension to > "file > type" association: > > E:\UserData\Wulfraed\My Documents>assoc .py > .py=py_auto_file > > E:\UserData\Wulfraed\My Documents>assoc .pyc > File association not found for extension .pyc > > E:\UserData\Wulfraed\My Documents>assoc .pyw > .pyw=pyw_auto_file > > (This is why I commented that the file type name may differ between > installs -- the assoc is > <.extension> = > and ftype is > = > As long as the same is used in both commands the linkage > works) > > That SHOULD clear up the double-click/Open/command > line > running of Python scripts. Setting up an Edit action (on WinXP) > requires > going through either the registry by hand, or opening a directory > window, > > Tools/Folder Options > File Types (tab) > scroll down to PY and PYW entries, select one > Details should show "Opens with: python" (or pythonw) > [Advanced] > the default action should be "open" (bold). If there is no > "edit" > action, click [New...] > > Give it Action name "edit" (or "edit with IDLE") > Application used to perform action: full path to the IDLE.BAT > file > (in quotes) followed by "%1" (with quotes) for the argument > placeholder > (the file to be edited). > Might need to [x] Use DDE; set "Application" to IDLE, set Topic > to > System > > {NOTE: I'm paraphrasing from the edit action on my system which uses > "E:\Python25\Lib\site-packages\pythonwin\Pythonwin.exe" "%1"} > {I'm not sure if you could skip the BAT file and use > "path/to/python.exe" "path/to/IDLE.py" "%1" > instead} > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfr...@ix.netcom.com HTTP://wlfraed.home.netcom.com/ Last I used it (I've been blessedly Windows free f
Re: How to generate secure passwords
thanx On Wed, May 30, 2012 at 5:16 PM, Bill Freeman wrote: > On Wed, May 30, 2012 at 8:17 AM, Jani Tiainen wrote: > > 30.5.2012 9:03, Emily Namugaanyi kirjoitti: > > > >> Hi Django users, > >> > >> I am working on a project that as to generate secure passwords > >> (passwords that cannot be hacked) every time a user register and the > >> password lasts for a period of time. S,here I am wondering whether > >> django has a provision for this or I need to find another way... > >> Thank you for your time > >> > >> Emily. > >> > > > > Sounds like your problem is not about generatic "secure passwords". But > > instead you need to build secure authorization behind that. > > > > So you have to build a system that checks is given username + password to > > protected content combination already expired. If that's the case, no > access > > is granted to protected content. > > > > Then password wouldn't contain any information about it's validity. Only > > validity checks happens on your side of system - in your code, on your > > server. > > > > -- > > Jani Tiainen > > > > - Well planned is half done and a half done has been sufficient before... > > django.contrib.auth.models.User has support for being tied to a > "profile" model of your design. You can include an expiration date > field (or several, if the user separately pays for different areas of > the site) in this model. While you might allow the user to edit other > fields in his profile, you do not permit him to change these fields. > Instead they are set by you payment system. The user then identifies > himself with a standard django username and passowrd, and the > controlled page views check the (appropriate to the section) > expiration date. This seems better to me than changing the password > at renewal. > > Bill > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Python IDLE
i dont know, but that would be awesome, do you know if aptana has it? i never thought of key binding til now in aptana. Am Mittwoch, 30. Mai 2012 16:19:15 UTC+2 schrieb ke1g: > Does it do emacs key bindings ;^) > > On Wed, May 30, 2012 at 10:13 AM, Mario Gudelj > wrote: > > It's not free but they have a 30 day trial period > > > > > > On 31 May 2012 00:09, doniyor wrote: > >> > >> @somecallitblues: pycharm is not free, right? but i am really willing > to > >> give a try for this. i am using for years Aptana studio which is > completely > >> fullfulling my wishes, but "pycharm loves django" sounds great! > >> > >> Am Mittwoch, 30. Mai 2012 15:59:13 UTC+2 schrieb somecallitblues: > >>> > >>> You seriously have to give PyCharm a go. It's everything IDE should be > >>> and loves django. > >>> > >>> On 30 May 2012 23:40, Bill Freeman wrote: > > On Mon, May 28, 2012 at 12:25 PM, Dennis Lee Bieber > wrote: > > On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid > > declaimed the following in > > gmane.comp.python.django.user: > > > >> I'm in a big mess now, I've lost my projects due to this errror. > I'm > >> on windows, This is how I encounter the problem; I try to edit my > >> settings.py in IDLE. After right clicking on the files, I choose > open > >> program with these default file. I choose idle window bat file, > and I > >> clicked Ok. It didn't open, I try to run manage.py runserver on my > >> DOS. Not working, it will pop up the IDLE Shell and mange.py > script > >> by > >> displaying it in IDLE. It didn't run the server. The logo of my > >> python > >> files have changed. How can I revert it back to open with IDLE? > And > >> use it as default for my python script? > > > >IDLE itself is a Python script; though it sounds like you > (or > > someone) created a Windows BAT file to act as an intermediate. > > > >The main problem appears to be that you've associated the > > "open" > > action with /IDLE/... The normal "open" action for Python (.py) > script > > files should be Python.exe (or Pythonw.exe for .pyw). For editing > you > > should have/create a "Edit" action that invokes your > IDLE > > BAT file. > > > >You'll need to work with the file association commands in > > Windows to > > reset things so that "open" means RUN the script. > > > >Unfortunately, different installations have used different > > names for > > the file types. Here are mine (I had to do "ftype" with no > arguments > > and > > scan the long output to find the Python entries): > > > > E:\UserData\Wulfraed\My Documents>ftype py_auto_file > > py_auto_file="E:\Python25\python.exe" "%1" %* > > > > E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file > > pyw_auto_file="E:\Python25\pythonw.exe" "%1" > > > > > >Note that ftype only defines the "open"/"run" action for a > > file. > > (Interesting -- the .pyw doesn't take command line arguments, > probably > > to be expected for a double-click open). > > > >The other half of the basic equation is the file extension > to > > "file > > type" association: > > > > E:\UserData\Wulfraed\My Documents>assoc .py > > .py=py_auto_file > > > > E:\UserData\Wulfraed\My Documents>assoc .pyc > > File association not found for extension .pyc > > > > E:\UserData\Wulfraed\My Documents>assoc .pyw > > .pyw=pyw_auto_file > > > > (This is why I commented that the file type name may differ between > > installs -- the assoc is > ><.extension> = > > and ftype is > > = > > As long as the same is used in both commands the > linkage > > works) > > > >That SHOULD clear up the > double-click/Open/command > > line > > running of Python scripts. Setting up an Edit action (on WinXP) > > requires > > going through either the registry by hand, or opening a directory > > window, > > > > Tools/Folder Options > > File Types (tab) > >scroll down to PY and PYW entries, select one > >Details should show "Opens with: python" (or pythonw) > > [Advanced] > >the default action should be "open" (bold). If there is no > > "edit" > > action, click [New...] > > > >Give it Action name "edit" (or "edit with IDLE") > >Application used to perform action: full path to the > IDLE.BAT > > file > > (in quotes) followed by "%1" (with quotes) for the argument > > placeholder > > (the file to be edited). > >Might need to [x] Use
Re: Python IDLE
As someone who has burned in some of the more obscure emacs commands, I find that I'm seldom satisfied with what a vendor calls emacs bindings (eclipse comes to mind - I wind up setting my source code files to be edited externally), but its usually still more comfortable than the native bindings. On Wed, May 30, 2012 at 10:23 AM, doniyor wrote: > i dont know, but that would be awesome, do you know if aptana has it? i > never thought of key binding til now in aptana. > > > Am Mittwoch, 30. Mai 2012 16:19:15 UTC+2 schrieb ke1g: >> >> Does it do emacs key bindings ;^) >> >> On Wed, May 30, 2012 at 10:13 AM, Mario Gudelj >> wrote: >> > It's not free but they have a 30 day trial period >> > >> > >> > On 31 May 2012 00:09, doniyor wrote: >> >> >> >> @somecallitblues: pycharm is not free, right? but i am really willing >> >> to >> >> give a try for this. i am using for years Aptana studio which is >> >> completely >> >> fullfulling my wishes, but "pycharm loves django" sounds great! >> >> >> >> Am Mittwoch, 30. Mai 2012 15:59:13 UTC+2 schrieb somecallitblues: >> >>> >> >>> You seriously have to give PyCharm a go. It's everything IDE should be >> >>> and loves django. >> >>> >> >>> On 30 May 2012 23:40, Bill Freeman wrote: >> >> On Mon, May 28, 2012 at 12:25 PM, Dennis Lee Bieber >> wrote: >> > On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid >> > declaimed the following in >> > gmane.comp.python.django.user: >> > >> >> I'm in a big mess now, I've lost my projects due to this errror. >> >> I'm >> >> on windows, This is how I encounter the problem; I try to edit my >> >> settings.py in IDLE. After right clicking on the files, I choose >> >> open >> >> program with these default file. I choose idle window bat file, >> >> and I >> >> clicked Ok. It didn't open, I try to run manage.py runserver on my >> >> DOS. Not working, it will pop up the IDLE Shell and mange.py >> >> script >> >> by >> >> displaying it in IDLE. It didn't run the server. The logo of my >> >> python >> >> files have changed. How can I revert it back to open with IDLE? >> >> And >> >> use it as default for my python script? >> > >> > IDLE itself is a Python script; though it sounds like you >> > (or >> > someone) created a Windows BAT file to act as an intermediate. >> > >> > The main problem appears to be that you've associated the >> > "open" >> > action with /IDLE/... The normal "open" action for Python (.py) >> > script >> > files should be Python.exe (or Pythonw.exe for .pyw). For editing >> > you >> > should have/create a "Edit" action that invokes your >> > IDLE >> > BAT file. >> > >> > You'll need to work with the file association commands in >> > Windows to >> > reset things so that "open" means RUN the script. >> > >> > Unfortunately, different installations have used different >> > names for >> > the file types. Here are mine (I had to do "ftype" with no >> > arguments >> > and >> > scan the long output to find the Python entries): >> > >> > E:\UserData\Wulfraed\My Documents>ftype py_auto_file >> > py_auto_file="E:\Python25\python.exe" "%1" %* >> > >> > E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file >> > pyw_auto_file="E:\Python25\pythonw.exe" "%1" >> > >> > >> > Note that ftype only defines the "open"/"run" action for a >> > file. >> > (Interesting -- the .pyw doesn't take command line arguments, >> > probably >> > to be expected for a double-click open). >> > >> > The other half of the basic equation is the file extension >> > to >> > "file >> > type" association: >> > >> > E:\UserData\Wulfraed\My Documents>assoc .py >> > .py=py_auto_file >> > >> > E:\UserData\Wulfraed\My Documents>assoc .pyc >> > File association not found for extension .pyc >> > >> > E:\UserData\Wulfraed\My Documents>assoc .pyw >> > .pyw=pyw_auto_file >> > >> > (This is why I commented that the file type name may differ between >> > installs -- the assoc is >> > <.extension> = >> > and ftype is >> > = >> > As long as the same is used in both commands the >> > linkage >> > works) >> > >> > That SHOULD clear up the >> > double-click/Open/command >> > line >> > running of Python scripts. Setting up an Edit action (on WinXP) >> > requires >> > going through either the registry by hand, or opening a directory >> > window, >> > >> > Tools/Folder Options >> > File Types (tab) >> > scroll down to PY and PYW entries, select one >> > Details should show "Opens with: python" (or pythonw) >> > [Advanced
Re: Python IDLE
Yea, PyCharm is the stuff. Also have python open python files; the easy way: Right click any pyton file->Left Click->Open With->Browse->c:\pythonX\bin\python.exe, for example->make sure you tick "always use the selected program to open this kind of file"->Ok On Wed, May 30, 2012 at 5:33 PM, Bill Freeman wrote: > As someone who has burned in some of the more obscure emacs commands, > I find that I'm seldom satisfied with what a vendor calls emacs > bindings (eclipse comes to mind - I wind up setting my source code > files to be edited externally), but its usually still more comfortable > than the native bindings. > > On Wed, May 30, 2012 at 10:23 AM, doniyor > wrote: > > i dont know, but that would be awesome, do you know if aptana has it? i > > never thought of key binding til now in aptana. > > > > > > Am Mittwoch, 30. Mai 2012 16:19:15 UTC+2 schrieb ke1g: > >> > >> Does it do emacs key bindings ;^) > >> > >> On Wed, May 30, 2012 at 10:13 AM, Mario Gudelj > >> wrote: > >> > It's not free but they have a 30 day trial period > >> > > >> > > >> > On 31 May 2012 00:09, doniyor wrote: > >> >> > >> >> @somecallitblues: pycharm is not free, right? but i am really willing > >> >> to > >> >> give a try for this. i am using for years Aptana studio which is > >> >> completely > >> >> fullfulling my wishes, but "pycharm loves django" sounds great! > >> >> > >> >> Am Mittwoch, 30. Mai 2012 15:59:13 UTC+2 schrieb somecallitblues: > >> >>> > >> >>> You seriously have to give PyCharm a go. It's everything IDE should > be > >> >>> and loves django. > >> >>> > >> >>> On 30 May 2012 23:40, Bill Freeman wrote: > >> > >> On Mon, May 28, 2012 at 12:25 PM, Dennis Lee Bieber > >> wrote: > >> > On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid > >> > declaimed the following in > >> > gmane.comp.python.django.user: > >> > > >> >> I'm in a big mess now, I've lost my projects due to this errror. > >> >> I'm > >> >> on windows, This is how I encounter the problem; I try to edit > my > >> >> settings.py in IDLE. After right clicking on the files, I choose > >> >> open > >> >> program with these default file. I choose idle window bat file, > >> >> and I > >> >> clicked Ok. It didn't open, I try to run manage.py runserver on > my > >> >> DOS. Not working, it will pop up the IDLE Shell and mange.py > >> >> script > >> >> by > >> >> displaying it in IDLE. It didn't run the server. The logo of my > >> >> python > >> >> files have changed. How can I revert it back to open with IDLE? > >> >> And > >> >> use it as default for my python script? > >> > > >> >IDLE itself is a Python script; though it sounds like you > >> > (or > >> > someone) created a Windows BAT file to act as an intermediate. > >> > > >> >The main problem appears to be that you've associated the > >> > "open" > >> > action with /IDLE/... The normal "open" action for Python (.py) > >> > script > >> > files should be Python.exe (or Pythonw.exe for .pyw). For editing > >> > you > >> > should have/create a "Edit" action that invokes your > >> > IDLE > >> > BAT file. > >> > > >> >You'll need to work with the file association commands in > >> > Windows to > >> > reset things so that "open" means RUN the script. > >> > > >> >Unfortunately, different installations have used different > >> > names for > >> > the file types. Here are mine (I had to do "ftype" with no > >> > arguments > >> > and > >> > scan the long output to find the Python entries): > >> > > >> > E:\UserData\Wulfraed\My Documents>ftype py_auto_file > >> > py_auto_file="E:\Python25\python.exe" "%1" %* > >> > > >> > E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file > >> > pyw_auto_file="E:\Python25\pythonw.exe" "%1" > >> > > >> > > >> >Note that ftype only defines the "open"/"run" action for a > >> > file. > >> > (Interesting -- the .pyw doesn't take command line arguments, > >> > probably > >> > to be expected for a double-click open). > >> > > >> >The other half of the basic equation is the file extension > >> > to > >> > "file > >> > type" association: > >> > > >> > E:\UserData\Wulfraed\My Documents>assoc .py > >> > .py=py_auto_file > >> > > >> > E:\UserData\Wulfraed\My Documents>assoc .pyc > >> > File association not found for extension .pyc > >> > > >> > E:\UserData\Wulfraed\My Documents>assoc .pyw > >> > .pyw=pyw_auto_file > >> > > >> > (This is why I commented that the file type name may differ > between > >> > installs -- the assoc is > >> ><.extension> = > >> > and ftype is > >> > = > >> > As long as the same is used in both
Re: how to tell apache to see my projects database file?
On 12-05-30 7:04 AM, doniyor wrote: what do you mean? should i do better chmod 755 which is more secure than 777? You can do whatever you want. But the advice from the list is to figure out what account is actually accessing the database and keep the permissions on the DB the way they should be. That may be different for different databases. So you have two things to figure out: 1) What is the effective user for your database accesses? 2) What permissions should be set on the database directories and files? hth - Tom Am Mittwoch, 30. Mai 2012 14:29:14 UTC+2 schrieb Thomas: On 5/30/12 1:11 AM, doniyor wrote: hey man, problem solved. i did *chown www-data. . *then *chmod 777 dbfile *now everything is working fine. thank you so much for your time and help. I've lost track of the early parts of this thread, but chmod 777 on a database rarely indicates that everything is fine. The chown did not matter much once you gave everyone in the universe write access to the database. This issue started as a permissions problem and still is a permissions problem. Figure out which user is actually accessing your database and get the permissions you need. hth - Tom -- 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/-/UOlT738Mi6gJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Python IDLE
Personally, I'd rather have clicking on a python file open it in my favorite editor. If I really wanted click to run for a Django project on Windows, I'd create a .bat file (or whatever the modern equivalent is). On Wed, May 30, 2012 at 11:32 AM, Timothy Makobu wrote: > Yea, PyCharm is the stuff. > > Also have python open python files; the easy way: > > Right click any pyton file->Left Click->Open > With->Browse->c:\pythonX\bin\python.exe, for example->make sure you tick > "always use the selected program to open this kind of file"->Ok > > > On Wed, May 30, 2012 at 5:33 PM, Bill Freeman wrote: >> >> As someone who has burned in some of the more obscure emacs commands, >> I find that I'm seldom satisfied with what a vendor calls emacs >> bindings (eclipse comes to mind - I wind up setting my source code >> files to be edited externally), but its usually still more comfortable >> than the native bindings. >> >> On Wed, May 30, 2012 at 10:23 AM, doniyor >> wrote: >> > i dont know, but that would be awesome, do you know if aptana has it? i >> > never thought of key binding til now in aptana. >> > >> > >> > Am Mittwoch, 30. Mai 2012 16:19:15 UTC+2 schrieb ke1g: >> >> >> >> Does it do emacs key bindings ;^) >> >> >> >> On Wed, May 30, 2012 at 10:13 AM, Mario Gudelj >> >> wrote: >> >> > It's not free but they have a 30 day trial period >> >> > >> >> > >> >> > On 31 May 2012 00:09, doniyor wrote: >> >> >> >> >> >> @somecallitblues: pycharm is not free, right? but i am really >> >> >> willing >> >> >> to >> >> >> give a try for this. i am using for years Aptana studio which is >> >> >> completely >> >> >> fullfulling my wishes, but "pycharm loves django" sounds great! >> >> >> >> >> >> Am Mittwoch, 30. Mai 2012 15:59:13 UTC+2 schrieb somecallitblues: >> >> >>> >> >> >>> You seriously have to give PyCharm a go. It's everything IDE should >> >> >>> be >> >> >>> and loves django. >> >> >>> >> >> >>> On 30 May 2012 23:40, Bill Freeman wrote: >> >> >> >> On Mon, May 28, 2012 at 12:25 PM, Dennis Lee Bieber >> >> wrote: >> >> > On Mon, 28 May 2012 05:37:43 -0700 (PDT), coded kid >> >> > declaimed the following in >> >> > gmane.comp.python.django.user: >> >> > >> >> >> I'm in a big mess now, I've lost my projects due to this >> >> >> errror. >> >> >> I'm >> >> >> on windows, This is how I encounter the problem; I try to edit >> >> >> my >> >> >> settings.py in IDLE. After right clicking on the files, I >> >> >> choose >> >> >> open >> >> >> program with these default file. I choose idle window bat file, >> >> >> and I >> >> >> clicked Ok. It didn't open, I try to run manage.py runserver on >> >> >> my >> >> >> DOS. Not working, it will pop up the IDLE Shell and mange.py >> >> >> script >> >> >> by >> >> >> displaying it in IDLE. It didn't run the server. The logo of my >> >> >> python >> >> >> files have changed. How can I revert it back to open with IDLE? >> >> >> And >> >> >> use it as default for my python script? >> >> > >> >> > IDLE itself is a Python script; though it sounds like you >> >> > (or >> >> > someone) created a Windows BAT file to act as an intermediate. >> >> > >> >> > The main problem appears to be that you've associated the >> >> > "open" >> >> > action with /IDLE/... The normal "open" action for Python (.py) >> >> > script >> >> > files should be Python.exe (or Pythonw.exe for .pyw). For >> >> > editing >> >> > you >> >> > should have/create a "Edit" action that invokes >> >> > your >> >> > IDLE >> >> > BAT file. >> >> > >> >> > You'll need to work with the file association commands in >> >> > Windows to >> >> > reset things so that "open" means RUN the script. >> >> > >> >> > Unfortunately, different installations have used >> >> > different >> >> > names for >> >> > the file types. Here are mine (I had to do "ftype" with no >> >> > arguments >> >> > and >> >> > scan the long output to find the Python entries): >> >> > >> >> > E:\UserData\Wulfraed\My Documents>ftype py_auto_file >> >> > py_auto_file="E:\Python25\python.exe" "%1" %* >> >> > >> >> > E:\UserData\Wulfraed\My Documents>ftype pyw_auto_file >> >> > pyw_auto_file="E:\Python25\pythonw.exe" "%1" >> >> > >> >> > >> >> > Note that ftype only defines the "open"/"run" action for >> >> > a >> >> > file. >> >> > (Interesting -- the .pyw doesn't take command line arguments, >> >> > probably >> >> > to be expected for a double-click open). >> >> > >> >> > The other half of the basic equation is the file >> >> > extension >> >> > to >> >> > "file >> >> > type" association: >> >> > >> >> > E:\UserData\Wulfraed\My Documents>ass
Foreign Key Chicken/Egg Inline Fu
Hi- I'm new to Django, but so far I think it is the bee's knees. I could use some insight into a problem I'm working on. Given the following... - # models.py from django.db import models class Team(models.Model): name = models.CharField(max_length=30) # captain is a player- but there can only be one captain per team. # null and blank are true to allow the team to be saved despite not having a captain captain = models.ForeignKey('Player', related_name='team_captain', null=True, blank=True) def __unicode__(self): return u'{0}'.format(self.name) class Player(models.Model): first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=30) team = models.ForeignKey('Team') def __unicode__(self): return u'{0} {1}'.format(self.first_name, self.last_name) # admin.py from league.models import * from django.contrib import admin class PlayerInline(admin.TabularInline): model = Player extra = 8 class TeamAdmin(admin.ModelAdmin): inlines = [PlayerInline] list_display = ('name', 'captain') - As is, when I create a new team in the admin interface I can add the players inline, but I have to leave the team captain blank, save the team, and then go back and change the team and set the captain to one of the players added previously. This is kind of a drag though. Is there a way that I can make the team captain be automatically set to the first player entered inline when the team is saved the first time? I 've thought about adding a boolean field to the Player model called "is_captain", but I want to enforce only one captain per team. If I were to go this route, is there a way I could make the is_captain field default to True for the first inline entry but false for the rest? Thanks, -Patrick -- You received this message because you are subscribed to the Google 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.
Tough finding a form with dynamic fields out there
Hi, Trying a form with dynamic fields, but having no luck. Also not finding any working examples out there :/ This is what I'm currently trying to use: class MboxReg(forms.Form): def __init__(self, mailboxes, *args, **kwargs): super(MboxReg, self).__init__(*args, **kwargs) # now we add each question individually for i in range(int(mailboxes)): self.fields["mailbox_"+str(i)] = forms.CharField(max_length=128) self.fields["firstname_"+str(i)] = forms.CharField(max_length=128) self.fields["lastname_"+str(i)] = forms.CharField(max_length=128) self.fields["password_"+str(i)] = forms.CharField(max_length=128) domain = forms.CharField(max_length=128) customer = forms.CharField(max_length=128) licenses = forms.IntegerField() Called with: form = MboxReg(request.POST, int(mailboxes)) mailboxes is the amount of mailboxes requested to be added. Error: Exception Value: int() argument must be a string or a number, not 'QueryDict' On the for i in range(int(mailboxes)): -- Mike -- * * *Tradepage, now part of the Cloud Group, is an Authorised Google Apps for Business Reseller. For only R485 per user per year, get Business Email, Calendars, Documents, syncing with mobile devices and much more. Find out more: http://www.tradepage.co.za/google-apps-for-business* This email and all contents are subject to the following disclaimer: http://www.tradepage.co.za/disclaimer -- You received this message because you are subscribed to the Google 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.
agon_ratings newbie help
I'm new to django and AJAX-level web development, so pardon my non-orthodox lingo :) Any ideas what I might be doing wrong if the AJAX form for rating in agon_ratings added per instructions ( http://agon-ratings.readthedocs.org/en/latest/usage.html) doesn't seem to really do much? I get the stars to show OK, but selecting a star does nothing AJAX-y, only sticks the star selection. I'm guessing the POST never happens, or there's some silent fail at some point. -- 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/-/JLX6ZHKayAcJ. 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 ModelForm user best practices
Say there's a model: class Notification(models.Model): user = models.ForeignKey(User) board = models.ForeignKey(Board) post = models.ForeignKey(Post) name = models.CharField() class Meta: unique_together = ('user', 'name', 'post', 'board') #i know this is funny.. just for purpose of this post In every post there's a form that you can fill with "name" value. This way the logged in user gets notification on every post update. What is the best way to save the "user", "board", "post" data ? 1. Saving in the views directly (CBV): class NotificationModelForm(forms.ModelForm): class Meta: model = Notification fields = ["name"] class CreateNotificationView(CreateView): model = Notification form_class = NotificationForm def form_valid(self, form): data = form.save(commit=False) data.user = self.request.user data.board = ... data.post = ... data.save() * if you have model validators (unique_together for user... this won't no longer work when submitting the form) 2. Displaying all the fields in the form, with some fields hidden class NotificationModelForm(forms.ModelForm): class Meta: fields = ["user", "board", "post", "name"] def __init__(self, *args, **kwargs): super(NotificationModelForm, self).__init__(*args, **kwargs) for field in ["user", "board", "post"]: forms.field['field'].widget = forms.HiddenInput() #I know this can be done other ways too Now we need to prepopulate fields with initial data for these fields class CreateNotificationView(CreateView): model = Notification form_class = NotificationModelForm def get_initial(self): initial = super(CreateNotificationView, self).get_initial() initial['user'] = self.request.user initial['board'] = ... initial['post'] = return initial If the same field pattern (user, board, post) is used in more forms/views... I can also create a MixinView class CommonUserFormMixin(object): def get_form(self, form_class): form = super(CommonUserFormMixin, self).get_form(form_class) for field in ['user', 'board', 'post']: form.fields[field].widget = forms.HiddenInput() Then: class NotifcationModelForm(forms.ModelForm): class Meta: model = Notification fields = ["user", "board", "post", "name"] class CreateNotificationView(CommonUserFormMixin, CreateView): form_class = NotificationModelForm model = Notification * in 2 above scenarios we get model validators working. 3. Sending values to the form directly and overriding the form.save() method class CreateNotificationView(CreateView): model = Notification form_class = NotificationModelForm def get_form_kwargs(**kwargs): kwargs = super(CreateNotificationView, self).get_form_kwargs(**kwargs) kwargs['user'] = self.request.user kwargs['board'] = ... kwargs['post'] = ... return kwargs class NotificationModelForm(forms.ModelForm): class Meta: model = Notification fields = ["name"] def __init__(self, *args, **kwargs): self.user = kwargs.pop('user') self.post = kwargs.pop('post') self.board = kwargs.pop('board') super(NotificationModelForm, self).__init__(*args, **kwargs) def save(*args, **kwargs): n = super(NotificationModelForm, self).save(commit=False) n.user = self.user n.post = self.post n.board = self.board n.save() return n I'm sure there are more ways to achive the same result. What are your thoughts on that ? When should I 'hide' (by using HiddenInput() widget) ModelForm fields? when should I save them directly in view? Does it all depend on needs or maybe there are some "best" standards ? -- 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/-/xn6xNGKJ2CEJ. 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 ModelForm user best practices
I tend to put as much functionality in my forms as possible. I've asked a similar question before (many months ago) and I believe that was the consensus. One advantage is you can re-use your forms (and its save functionality) for your Create and Update views. On Wed, May 30, 2012 at 3:45 PM, RM wrote: > Say there's a model: > > class Notification(models.Model): > user = models.ForeignKey(User) > board = models.ForeignKey(Board) > post = models.ForeignKey(Post) > name = models.CharField() > > class Meta: > unique_together = ('user', 'name', 'post', 'board') > #i know this is funny.. just for purpose of this post > > In every post there's a form that you can fill with "name" value. > This way the logged in user gets notification on every post update. > > What is the best way to save the "user", "board", "post" data ? > > 1. Saving in the views directly (CBV): > > class NotificationModelForm(forms.ModelForm): > class Meta: > model = Notification > fields = ["name"] > > class CreateNotificationView(CreateView): > model = Notification > form_class = NotificationForm > def form_valid(self, form): > data = form.save(commit=False) > data.user = self.request.user > data.board = ... > data.post = ... > data.save() > > * if you have model validators (unique_together for user... this won't no > longer work when submitting the form) > > 2. Displaying all the fields in the form, with some fields hidden > > class NotificationModelForm(forms.ModelForm): > class Meta: > fields = ["user", "board", "post", "name"] > > def __init__(self, *args, **kwargs): > super(NotificationModelForm, self).__init__(*args, **kwargs) > for field in ["user", "board", "post"]: > forms.field['field'].widget = forms.HiddenInput() > #I know this can be done other ways too > > Now we need to prepopulate fields with initial data for these fields > > class CreateNotificationView(CreateView): > model = Notification > form_class = NotificationModelForm > > def get_initial(self): > initial = super(CreateNotificationView, self).get_initial() > initial['user'] = self.request.user > initial['board'] = ... > initial['post'] = > return initial > > If the same field pattern (user, board, post) is used in more forms/views... > I can also create a MixinView > > class CommonUserFormMixin(object): > > def get_form(self, form_class): > form = super(CommonUserFormMixin, self).get_form(form_class) > for field in ['user', 'board', 'post']: > form.fields[field].widget = forms.HiddenInput() > > Then: > > class NotifcationModelForm(forms.ModelForm): > class Meta: > model = Notification > fields = ["user", "board", "post", "name"] > > class CreateNotificationView(CommonUserFormMixin, CreateView): > form_class = NotificationModelForm > model = Notification > > * in 2 above scenarios we get model validators working. > 3. Sending values to the form directly and overriding the form.save() method > > class CreateNotificationView(CreateView): > model = Notification > form_class = NotificationModelForm > > def get_form_kwargs(**kwargs): > kwargs = super(CreateNotificationView, > self).get_form_kwargs(**kwargs) > kwargs['user'] = self.request.user > kwargs['board'] = ... > kwargs['post'] = ... > return kwargs > > class NotificationModelForm(forms.ModelForm): > class Meta: > model = Notification > fields = ["name"] > > def __init__(self, *args, **kwargs): > self.user = kwargs.pop('user') > self.post = kwargs.pop('post') > self.board = kwargs.pop('board') > > super(NotificationModelForm, self).__init__(*args, **kwargs) > > def save(*args, **kwargs): > n = super(NotificationModelForm, self).save(commit=False) > n.user = self.user > n.post = self.post > n.board = self.board > n.save() > return n > > > I'm sure there are more ways to achive the same result. > What are your thoughts on that ? > > When should I 'hide' (by using HiddenInput() widget) ModelForm fields? when > should I save them directly > in view? > > Does it all depend on needs or maybe there are some "best" standards ? > > > -- > 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/-/xn6xNGKJ2CEJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To
Re: Django ModelForm user best practices
I think that the first method is the most usefull. On second method some experience users can override hidden data. And it's a bad idea to override __init__ and save method in my humble opinion/ 2012/5/31 RM : > Say there's a model: > > class Notification(models.Model): > user = models.ForeignKey(User) > board = models.ForeignKey(Board) > post = models.ForeignKey(Post) > name = models.CharField() > > class Meta: > unique_together = ('user', 'name', 'post', 'board') > #i know this is funny.. just for purpose of this post > > In every post there's a form that you can fill with "name" value. > This way the logged in user gets notification on every post update. > > What is the best way to save the "user", "board", "post" data ? > > 1. Saving in the views directly (CBV): > > class NotificationModelForm(forms.ModelForm): > class Meta: > model = Notification > fields = ["name"] > > class CreateNotificationView(CreateView): > model = Notification > form_class = NotificationForm > def form_valid(self, form): > data = form.save(commit=False) > data.user = self.request.user > data.board = ... > data.post = ... > data.save() > > * if you have model validators (unique_together for user... this won't no > longer work when submitting the form) > > 2. Displaying all the fields in the form, with some fields hidden > > class NotificationModelForm(forms.ModelForm): > class Meta: > fields = ["user", "board", "post", "name"] > > def __init__(self, *args, **kwargs): > super(NotificationModelForm, self).__init__(*args, **kwargs) > for field in ["user", "board", "post"]: > forms.field['field'].widget = forms.HiddenInput() > #I know this can be done other ways too > > Now we need to prepopulate fields with initial data for these fields > > class CreateNotificationView(CreateView): > model = Notification > form_class = NotificationModelForm > > def get_initial(self): > initial = super(CreateNotificationView, self).get_initial() > initial['user'] = self.request.user > initial['board'] = ... > initial['post'] = > return initial > > If the same field pattern (user, board, post) is used in more forms/views... > I can also create a MixinView > > class CommonUserFormMixin(object): > > def get_form(self, form_class): > form = super(CommonUserFormMixin, self).get_form(form_class) > for field in ['user', 'board', 'post']: > form.fields[field].widget = forms.HiddenInput() > > Then: > > class NotifcationModelForm(forms.ModelForm): > class Meta: > model = Notification > fields = ["user", "board", "post", "name"] > > class CreateNotificationView(CommonUserFormMixin, CreateView): > form_class = NotificationModelForm > model = Notification > > * in 2 above scenarios we get model validators working. > 3. Sending values to the form directly and overriding the form.save() method > > class CreateNotificationView(CreateView): > model = Notification > form_class = NotificationModelForm > > def get_form_kwargs(**kwargs): > kwargs = super(CreateNotificationView, > self).get_form_kwargs(**kwargs) > kwargs['user'] = self.request.user > kwargs['board'] = ... > kwargs['post'] = ... > return kwargs > > class NotificationModelForm(forms.ModelForm): > class Meta: > model = Notification > fields = ["name"] > > def __init__(self, *args, **kwargs): > self.user = kwargs.pop('user') > self.post = kwargs.pop('post') > self.board = kwargs.pop('board') > > super(NotificationModelForm, self).__init__(*args, **kwargs) > > def save(*args, **kwargs): > n = super(NotificationModelForm, self).save(commit=False) > n.user = self.user > n.post = self.post > n.board = self.board > n.save() > return n > > > I'm sure there are more ways to achive the same result. > What are your thoughts on that ? > > When should I 'hide' (by using HiddenInput() widget) ModelForm fields? when > should I save them directly > in view? > > Does it all depend on needs or maybe there are some "best" standards ? > > > -- > 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/-/xn6xNGKJ2CEJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this grou
Re: Foreign Key Chicken/Egg Inline Fu
Unless a player can play for multiple teams (which I'm doubting since Team is a ForeignKey for a Player), why not remove that 'captain' attribute from your Team and put it into your Player model as a boolean field? You could create a ModelManager or class-level model method to grab the associated team caption if you want to access it easily. Otherwise, it's just a matter of: Team.objects.get('team_name').player_set.filter(captain=True) # Or something along those lines... Just an idea anyways :) Good luck! On Wed, May 30, 2012 at 2:15 PM, Patrick Gavin wrote: > Hi- > > I'm new to Django, but so far I think it is the bee's knees. > > I could use some insight into a problem I'm working on. > > Given the following... > > - > # models.py > > from django.db import models > > class Team(models.Model): > name = models.CharField(max_length=30) > > # captain is a player- but there can only be one captain per team. > # null and blank are true to allow the team to be saved despite > not having a captain > captain = models.ForeignKey('Player', related_name='team_captain', > null=True, blank=True) > > def __unicode__(self): > return u'{0}'.format(self.name) > > class Player(models.Model): > first_name = models.CharField(max_length=20) > last_name = models.CharField(max_length=30) > team = models.ForeignKey('Team') > > def __unicode__(self): > return u'{0} {1}'.format(self.first_name, self.last_name) > > > # admin.py > > from league.models import * > from django.contrib import admin > > class PlayerInline(admin.TabularInline): > model = Player > extra = 8 > > class TeamAdmin(admin.ModelAdmin): > inlines = [PlayerInline] > list_display = ('name', 'captain') > > - > > As is, when I create a new team in the admin interface I can add the > players inline, but I have to leave the team captain blank, save the > team, and then go back and change the team and set the captain to one > of the players added previously. This is kind of a drag though. > > Is there a way that I can make the team captain be automatically set > to the first player entered inline when the team is saved the first > time? > > I 've thought about adding a boolean field to the Player model called > "is_captain", but I want to enforce only one captain per team. If I > were to go this route, is there a way I could make the is_captain > field default to True for the first inline entry but false for the > rest? > > Thanks, > > -Patrick > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Foreign Key Chicken/Egg Inline Fu
Sorry, I completely mis-read the last part of your problem. You already thought about the same solution, haha. You might be able to modify the Player model's clean (or save) method to prohibit any Team from having more than one team captain. However, I'd probably just check it in the Form you're using (outside of Admin) On Wed, May 30, 2012 at 4:02 PM, Kurtis Mullins wrote: > Unless a player can play for multiple teams (which I'm doubting since > Team is a ForeignKey for a Player), why not remove that 'captain' > attribute from your Team and put it into your Player model as a > boolean field? You could create a ModelManager or class-level model > method to grab the associated team caption if you want to access it > easily. Otherwise, it's just a matter of: > > Team.objects.get('team_name').player_set.filter(captain=True) # Or > something along those lines... > > Just an idea anyways :) Good luck! > > On Wed, May 30, 2012 at 2:15 PM, Patrick Gavin wrote: >> Hi- >> >> I'm new to Django, but so far I think it is the bee's knees. >> >> I could use some insight into a problem I'm working on. >> >> Given the following... >> >> - >> # models.py >> >> from django.db import models >> >> class Team(models.Model): >> name = models.CharField(max_length=30) >> >> # captain is a player- but there can only be one captain per team. >> # null and blank are true to allow the team to be saved despite >> not having a captain >> captain = models.ForeignKey('Player', related_name='team_captain', >> null=True, blank=True) >> >> def __unicode__(self): >> return u'{0}'.format(self.name) >> >> class Player(models.Model): >> first_name = models.CharField(max_length=20) >> last_name = models.CharField(max_length=30) >> team = models.ForeignKey('Team') >> >> def __unicode__(self): >> return u'{0} {1}'.format(self.first_name, self.last_name) >> >> >> # admin.py >> >> from league.models import * >> from django.contrib import admin >> >> class PlayerInline(admin.TabularInline): >> model = Player >> extra = 8 >> >> class TeamAdmin(admin.ModelAdmin): >> inlines = [PlayerInline] >> list_display = ('name', 'captain') >> >> - >> >> As is, when I create a new team in the admin interface I can add the >> players inline, but I have to leave the team captain blank, save the >> team, and then go back and change the team and set the captain to one >> of the players added previously. This is kind of a drag though. >> >> Is there a way that I can make the team captain be automatically set >> to the first player entered inline when the team is saved the first >> time? >> >> I 've thought about adding a boolean field to the Player model called >> "is_captain", but I want to enforce only one captain per team. If I >> were to go this route, is there a way I could make the is_captain >> field default to True for the first inline entry but false for the >> rest? >> >> Thanks, >> >> -Patrick >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django ModelForm user best practices
> On second method some experience users can > override hidden data For the second method, you'd just use -- class Meta: fields = ('board', 'post', 'name') to prohbit anyone from trying to override the 'user', if that's what you're talking about. > And it's a bad idea to > override __init__ and save method in my humble opinion/ What better purpose for the save() method than to save? :) I'm not sure why it's a bad idea to override __init__, though. Feel free to elaborate. I'm always open for new 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Tough finding a form with dynamic fields out there
So, compare this: def __init__(self, mailboxes, *args, **kwargs): > with how you're calling it: > form = MboxReg(request.POST, int(mailboxes)) > > and you should see why you're getting this: > Error: > Exception Value: > > int() argument must be a string or a number, not 'QueryDict' > > On the > > for i in range(int(mailboxes)): > > -- Mike > > -- DR. -- 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/-/z68uQEeQ4fsJ. 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: Foreign Key Chicken/Egg Inline Fu
I just checked on my own code that does something in a different context but kinda performs the same check. I thought I'd share it with you in case it helps out at all. def clean_title(self): # Grab the data to verify this Title is unique to this user. title = self.cleaned_data['title'] owner = self.request.user slug = slugify(title) # Grab all user pages query for validation user_pages = AbstractPage.objects.filter(owner = owner) user_pages = user_pages.exclude(pk = self.instance.pk) # Validate Uniqueness if user_pages.filter(title = title).exists(): raise ValidationError("The page title must be unique. It appears " + "you already have a page with this title.") elif user_pages.filter(slug = slug).exists(): raise ValidationError("It appears that you're trying to use two " + " pages with titles that are too similar.") else: return title Of course, you'd want to 'clean' the Captain boolean field and make sure that no other player in the same team is a captain before allowing it to pass. Different context, but hopefully this approach can help. On Wed, May 30, 2012 at 4:05 PM, Kurtis Mullins wrote: > Sorry, I completely mis-read the last part of your problem. You > already thought about the same solution, haha. You might be able to > modify the Player model's clean (or save) method to prohibit any Team > from having more than one team captain. However, I'd probably just > check it in the Form you're using (outside of Admin) > > On Wed, May 30, 2012 at 4:02 PM, Kurtis Mullins > wrote: >> Unless a player can play for multiple teams (which I'm doubting since >> Team is a ForeignKey for a Player), why not remove that 'captain' >> attribute from your Team and put it into your Player model as a >> boolean field? You could create a ModelManager or class-level model >> method to grab the associated team caption if you want to access it >> easily. Otherwise, it's just a matter of: >> >> Team.objects.get('team_name').player_set.filter(captain=True) # Or >> something along those lines... >> >> Just an idea anyways :) Good luck! >> >> On Wed, May 30, 2012 at 2:15 PM, Patrick Gavin wrote: >>> Hi- >>> >>> I'm new to Django, but so far I think it is the bee's knees. >>> >>> I could use some insight into a problem I'm working on. >>> >>> Given the following... >>> >>> - >>> # models.py >>> >>> from django.db import models >>> >>> class Team(models.Model): >>> name = models.CharField(max_length=30) >>> >>> # captain is a player- but there can only be one captain per team. >>> # null and blank are true to allow the team to be saved despite >>> not having a captain >>> captain = models.ForeignKey('Player', related_name='team_captain', >>> null=True, blank=True) >>> >>> def __unicode__(self): >>> return u'{0}'.format(self.name) >>> >>> class Player(models.Model): >>> first_name = models.CharField(max_length=20) >>> last_name = models.CharField(max_length=30) >>> team = models.ForeignKey('Team') >>> >>> def __unicode__(self): >>> return u'{0} {1}'.format(self.first_name, self.last_name) >>> >>> >>> # admin.py >>> >>> from league.models import * >>> from django.contrib import admin >>> >>> class PlayerInline(admin.TabularInline): >>> model = Player >>> extra = 8 >>> >>> class TeamAdmin(admin.ModelAdmin): >>> inlines = [PlayerInline] >>> list_display = ('name', 'captain') >>> >>> - >>> >>> As is, when I create a new team in the admin interface I can add the >>> players inline, but I have to leave the team captain blank, save the >>> team, and then go back and change the team and set the captain to one >>> of the players added previously. This is kind of a drag though. >>> >>> Is there a way that I can make the team captain be automatically set >>> to the first player entered inline when the team is saved the first >>> time? >>> >>> I 've thought about adding a boolean field to the Player model called >>> "is_captain", but I want to enforce only one captain per team. If I >>> were to go this route, is there a way I could make the is_captain >>> field default to True for the first inline entry but false for the >>> rest? >>> >>> Thanks, >>> >>> -Patrick >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group
Re: Python IDLE
Back to the original question, Did you try running "python manage.py runserver" from the command prompt? As far as changing those icons back to Python, I believe you have to change your 'Default Program'. I'm not sure which version of Widnows you're using (or even how to do it in Windows, I'm running Linux) but I'm sure you could use Google (or duckduckgo.com) for a quick answer there. If you still can't run 'runserver', try using your command prompt to do something along the following (your paths may/will be different) c:\python27\bin\python.exe c:\my_directory\my_project\manage.py runserver Basically, you're just telling the Python interpreter (python.exe or python27.exe) to execute the "manage.py" file. Also, please note: Python Versions > 2.7.x (3+) will not work with Django at the moment. Good luck! On Mon, May 28, 2012 at 8:37 AM, coded kid wrote: > I'm in a big mess now, I've lost my projects due to this errror. I'm > on windows, This is how I encounter the problem; I try to edit my > settings.py in IDLE. After right clicking on the files, I choose open > program with these default file. I choose idle window bat file, and I > clicked Ok. It didn't open, I try to run manage.py runserver on my > DOS. Not working, it will pop up the IDLE Shell and mange.py script by > displaying it in IDLE. It didn't run the server. The logo of my python > files have changed. How can I revert it back to open with IDLE? And > use it as default for my python script? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google 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 ModelForm user best practices
For example on second method i can change post, board id's via html, and write to board where i can be banned. I think we shoudn't override standart methods if we con don't override them(this about third method) P.S. sorry for my terrible english. 2012/5/31 Kurtis Mullins : >> On second method some experience users can >> override hidden data > > For the second method, you'd just use -- class Meta: fields = > ('board', 'post', 'name') to prohbit anyone from trying to override > the 'user', if that's what you're talking about. > >> And it's a bad idea to >> override __init__ and save method in my humble opinion/ > > What better purpose for the save() method than to save? :) I'm not > sure why it's a bad idea to override __init__, though. Feel free to > elaborate. I'm always open for new 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 > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Adding values to formdata of ModelForm before saving
Is it possible to put missing data into the data of a form before calling form.save() ? I want to add the calendar-id (calid/in_calendar) before saving to the model. http://susepaste.org/23451355 I tried adding it after instantiating the form with form.in_calendar_id = kalender but it didn't work I don't want to use hidden fields because manipulating them is easy Maybe https://groups.google.com/forum/?fromgroups#!topic/django-users/F5yHH-G5QLM describes how to solve it but I didn't understand it. PS: If you find very ugly code please correct me -- I'm a beginner -- 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/-/v0GYTeLYPAsJ. 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: Adding values to formdata of ModelForm before saving
Yes, it is possible: obj = form.save(commit=False) obj.in_calender-id = kalender obj.save() On Wed, May 30, 2012 at 2:56 PM, Schmidtchen Schleicher < spiolli...@googlemail.com> wrote: > Is it possible to put missing data into the data of a form before calling > form.save() ? > I want to add the calendar-id (calid/in_calendar) before saving to the > model. > > http://susepaste.org/23451355 > > I tried adding it after instantiating the form with form.in_calendar_id = > kalender but it didn't work > I don't want to use hidden fields because manipulating them is easy > > Maybe > https://groups.google.com/forum/?fromgroups#!topic/django-users/F5yHH-G5QLMdescribes > how to solve it but I didn't understand it. > > PS: If you find very ugly code please correct me -- I'm a beginner > > -- > 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/-/v0GYTeLYPAsJ. > 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. > -- Jonathan D. Baker Developer http://jonathandbaker.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Foreign Key Chicken/Egg Inline Fu
Thanks Kurtis! That is helpful. -Patrick On May 30, 1:14 pm, Kurtis Mullins wrote: > I just checked on my own code that does something in a different > context but kinda performs the same check. I thought I'd share it with > you in case it helps out at all. > > def clean_title(self): > > # Grab the data to verify this Title is unique to this user. > title = self.cleaned_data['title'] > owner = self.request.user > slug = slugify(title) > > # Grab all user pages query for validation > user_pages = AbstractPage.objects.filter(owner = owner) > user_pages = user_pages.exclude(pk = self.instance.pk) > > # Validate Uniqueness > if user_pages.filter(title = title).exists(): > raise ValidationError("The page title must be unique. It appears " > + "you already have a page with this > title.") > elif user_pages.filter(slug = slug).exists(): > raise ValidationError("It appears that you're trying to use two " > + " pages with titles that are too > similar.") > else: return title > > Of course, you'd want to 'clean' the Captain boolean field and make > sure that no other player in the same team is a captain before > allowing it to pass. Different context, but hopefully this approach > can help. > > On Wed, May 30, 2012 at 4:05 PM, Kurtis Mullins > > > > > > > > wrote: > > Sorry, I completely mis-read the last part of your problem. You > > already thought about the same solution, haha. You might be able to > > modify the Player model's clean (or save) method to prohibit any Team > > from having more than one team captain. However, I'd probably just > > check it in the Form you're using (outside of Admin) > > > On Wed, May 30, 2012 at 4:02 PM, Kurtis Mullins > > wrote: > >> Unless a player can play for multiple teams (which I'm doubting since > >> Team is a ForeignKey for a Player), why not remove that 'captain' > >> attribute from your Team and put it into your Player model as a > >> boolean field? You could create a ModelManager or class-level model > >> method to grab the associated team caption if you want to access it > >> easily. Otherwise, it's just a matter of: > > >> Team.objects.get('team_name').player_set.filter(captain=True) # Or > >> something along those lines... > > >> Just an idea anyways :) Good luck! > > >> On Wed, May 30, 2012 at 2:15 PM, Patrick Gavin wrote: > >>> Hi- > > >>> I'm new to Django, but so far I think it is the bee's knees. > > >>> I could use some insight into a problem I'm working on. > > >>> Given the following... > > >>> - > >>> # models.py > > >>> from django.db import models > > >>> class Team(models.Model): > >>> name = models.CharField(max_length=30) > > >>> # captain is a player- but there can only be one captain per team. > >>> # null and blank are true to allow the team to be saved despite > >>> not having a captain > >>> captain = models.ForeignKey('Player', related_name='team_captain', > >>> null=True, blank=True) > > >>> def __unicode__(self): > >>> return u'{0}'.format(self.name) > > >>> class Player(models.Model): > >>> first_name = models.CharField(max_length=20) > >>> last_name = models.CharField(max_length=30) > >>> team = models.ForeignKey('Team') > > >>> def __unicode__(self): > >>> return u'{0} {1}'.format(self.first_name, self.last_name) > > >>> # admin.py > > >>> from league.models import * > >>> from django.contrib import admin > > >>> class PlayerInline(admin.TabularInline): > >>> model = Player > >>> extra = 8 > > >>> class TeamAdmin(admin.ModelAdmin): > >>> inlines = [PlayerInline] > >>> list_display = ('name', 'captain') > > >>> - > > >>> As is, when I create a new team in the admin interface I can add the > >>> players inline, but I have to leave the team captain blank, save the > >>> team, and then go back and change the team and set the captain to one > >>> of the players added previously. This is kind of a drag though. > > >>> Is there a way that I can make the team captain be automatically set > >>> to the first player entered inline when the team is saved the first > >>> time? > > >>> I 've thought about adding a boolean field to the Player model called > >>> "is_captain", but I want to enforce only one captain per team. If I > >>> were to go this route, is there a way I could make the is_captain > >>> field default to True for the first inline entry but false for the > >>> rest? > > >>> Thanks, > > >>> -Patrick > > >>> -- > >>> You received this message because you are subscribed to the Google 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
Re: A signal, or equivalent, for when all apps are loaded?
On Wed, May 30, 2012 at 9:59 PM, Bill Freeman wrote: > On Tue, May 29, 2012 at 7:35 PM, Russell Keith-Magee > wrote: >> On Wed, May 30, 2012 at 4:42 AM, Bill Freeman wrote: >>> I continue to struggle with occasional circular import problems >>> (caused by a combination of haystack, filebrowser, and a model which >>> both has a search_indexes.py and a model that has a filebrowser >>> field). >>> >>> I had thought that I had patched the issue by importing haystack in my >>> root urlconf (the problem doesn't happen under the development server >>> because it "validates models" early, but the import order was >>> different in production). But: 1, I kept having to add "import >>> haystack" to my management commands; and 2, it still occasionally >>> fails on restart (a timing hazard of some kind). >>> >>> It strikes me that one fix would be to defer haystack's scan of the >>> INSTALLED_APPS until all the apps have been loaded. But when is that? >>> I can ask django.db.models.loading.app_cache_ready(), but it will say >>> False when haystack (or its models.py, which it has, despite not >>> having any models) is being imported (since the list of apps being >>> cached can't be finished until haystack.models import has finished). >>> So when could I run it again? It would be nice to register for an >>> "apps are loaded" signal, but I don't see on in the docs, and there is >>> no evidence of sending one in django.db.models.loading.AppCache. >>> >>> Is there a right way to get something called after all the models have >>> been imported? (Django 1.3) >> >> Unfortunately, there isn't. This is a long standing problem, and one >> that the app-refactor was looking into; however, that effort hasn't >> come to fruition. Django's startup sequence is an area where some work >> is required. The closest thing to a "signal" you're going to get is to >> hook into the URL configuration, in the same way the admin >> registration process does -- but it looks like you've tried that and >> haven't had any luck. >> >> One trick that I'm aware of that *might* work in your case is to force >> the validation code to run in your production stack -- for example, as >> a call in your WSGI container. From a functional perspective, this is >> an expensive no-op. The validation won't ever return a different >> result, which is why Django's WSGI handler doesn't call validate. >> However, the process of validation *does* cause the startup sequence >> to be a little more predictable, because the validation mechanism >> imports *all* your app modules in your project in a predictable order. >> If your problem is being caused by an unpredictable import order, >> forcing a specific import order may work around your problem (or at >> least make the side effects more predictable, and match the behaviour >> of the development server). >> >> Yours >> Russ Magee %-) > > Thanks Russ. > > I guess that I could just try importing django.db.models in my wsgi > file (in turn imports django.db.models.loading, which initializes the > AppCache) as a validation equivalent? I mentioned the validation thing because I know that it works. I'd have to check the models import to make sure it has exactly the same side effects, but it stands to reason that it might. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Checkbox becomes combox ... why ?
Thanks, but not main problems. Even if I remove "maybe" items, same incorrect outputs. Dennis Lee Bieber於 2012年5月31日星期四UTC+8上午12時09分44秒寫道: > > On Wed, 30 May 2012 02:24:53 -0700 (PDT), yillkid > declaimed the following in gmane.comp.python.django.user: > > > > > Filed "game_type" is a check box widget, BUT when I render the register > > page, > > It doesn't render to a checkbot but a combobox. > > I don't why, thanks for reading my problem. > > Off-hand... Checkboxes are two-state items: On/Off (Yes/No; 1/0; > checked/unchecked). BUT you are providing a three-state value for it -- > how is a checkbox supposed to render "Maybe"? > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/ -- 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/-/Qrf9QVpE7HwJ. 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: Tough finding a form with dynamic fields out there
Daniel has point out the issue, but have a look at this speech from Django Con last year http://blip.tv/djangocon/advanced-django-form-usage-5573287. It has some great stuff in there. -m On 31 May 2012 06:14, Daniel Roseman wrote: > So, compare this: > > > def __init__(self, mailboxes, *args, **kwargs): >> > > with how you're calling it: > > >> form = MboxReg(request.POST, int(mailboxes)) >> >> > and you should see why you're getting this: > > >> Error: >> Exception Value: >> >> int() argument must be a string or a number, not 'QueryDict' >> >> On the >> >> for i in range(int(mailboxes)): >> >> -- Mike >> >> > -- > DR. > > -- > 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/-/z68uQEeQ4fsJ. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Python IDLE
On Thu, 2012-05-31 at 00:13 +1000, Mario Gudelj wrote: > It's not free but they have a 30 day trial period if you have an active open source project they will give you a free license -- regards Kenneth Gonsalves -- You received this message because you are subscribed to the Google 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 Django Right for Me?
On Wed, 2012-05-30 at 12:01 -0400, Dennis Lee Bieber wrote: > > other activities. The supervisor goes to the villages with netbooks. > If > > there is connectivity, he enters the data directly to the server on > the > > internet. If not, he has a local copy of the site running on his > netbook > > with a local copy of the database, synced before he leaves his > office. > > So he enters the data on that and later syncs it with the server. It > is > > not rocket science to write the scripts for syncing. > > If there is only one "supervisor" doing this, it may not be > difficult... > > that is the use case of the OP - and I do not see a big problem if multiple people do it. Yet to test it out in practice. After all that is what a dvcs does. -- regards Kenneth Gonsalves -- You received this message because you are subscribed to the Google 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 ModelForm user best practices
Good point. You can display the value but again.. you need to make sure it's a proper (not changed via post) value (clean() / save()) W dniu środa, 30 maja 2012 22:25:35 UTC+2 użytkownik Alexandr Aibulatov napisał: > > For example on second method i can change post, board id's via html, > and write to board where i can be banned. > I think we shoudn't override standart methods if we con don't override > them(this about third method) > > > -- 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/-/joNBMZyeXnMJ. 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.