Re: django-registration with my custom user profile
any help:? On Jun 13, 6:02 pm, Chr1s <[EMAIL PROTECTED]> wrote: > Hi thanks for your replay, > It is the second situation, I re-write the form.py like this > > class RegistrationForm(forms.Form): > (other stuff ) > def save(self, profile_callback=None): > > new_user = > RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], > > password=self.cleaned_data['password1'], > > email=self.cleaned_data['email'], > > nickname = self.cleaned_data['nickname'], > > country = self.cleaned_data['country'], > > province = self.cleaned_data['province'], > > city = self.cleaned_data['city'], > > gender = self.cleaned_data['gender'], > > phone = self.cleaned_data['phone'], > > bio = self.cleaned_data['bio'], > > profile_callback=profile_callback) > return new_user > > and then I changed the models.py in this way. > > def create_inactive_user(self, username, password, > email,dob,nickname,country,province, > city,gender,phone,bio,send_email=True, > profile_callback=None): > new_user = > User.objects.create_user(username,last_name,first_name, email, > password) > new_user.is_active = False > new_user.save() > > registration_profile = self.create_profile(new_user) > userdetail = > UserDetail(new_user,nickname,dob,country,province,city,gender,phone,bio) > userdetail.save() > if profile_callback is not None: > profile_callback(user=new_user) > > but the browser throw the error like this > > TypeError at /veryuser/register/ > create_inactive_user() takes at least 12 non-keyword arguments (4 > given) > > thanks > > On Jun 13, 5:17 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > > > > > > > 2008/6/13 Chr1s <[EMAIL PROTECTED]>: > > > > But still I don't know how to implement this, anyone could give me a > > > simple example? thanks very much > > > This feature is intended for a situation where each of the following is > > true: > > > 1. You have a custom user-profile model. > > 2. The user-profile model has been written in such a way that an > > instance can be created using nothing but default values (e.g., with > > no input whatsoever from the user). > > > If that is the case, simply write a function which can create an > > instance using nothing but default values, and pass that as the > > argument. > > > If that is not the case, you will either need to write a more complex > > custom form (to handle any additional information you want to collect) > > or create the profile in a separate step (e.g., using > > django-profiles). > > > -- > > "Bureaucrat Conrad, you are technically correct -- the best kind of > > correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django HTML Editor
Forgot to mention, it would be definitely helpful if there is a WYSIWYG editor available. Thanks On Jun 14, 2:06 pm, Ngu Soon Hui <[EMAIL PROTECTED]> wrote: > I want a free HTML editor that is compatible with Django template's > syntax. I just want to edit my Django power application's HTML faster. > When I say compatible, I mean that the editor shouldn't screw up all > the Django template's tags and variables. > > I used some HTML editors out there, but they are not compatible with > Django template in that they don't recognize the tags. I am not sure > whether there are any HTML editor that can do this job. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django HTML Editor
I want a free HTML editor that is compatible with Django template's syntax. I just want to edit my Django power application's HTML faster. When I say compatible, I mean that the editor shouldn't screw up all the Django template's tags and variables. I used some HTML editors out there, but they are not compatible with Django template in that they don't recognize the tags. I am not sure whether there are any HTML editor that can do this job. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Disconnected ORM objects
Well, my objects start out as something disconnected (eg, an email message and its associated email addresses are download via POP3), and only then am I adding everything to the database. So the download_email_messages method of my EmailClient class would return a Python list of EmailMessage objects, each containing a few lists of EmailAddress objects, and then the user of the EmailClient would save it in a database. I want to use these ORM objects both for database access and for other purposes. Is that approach discouraged? If so, what would be a good alternative? On Jun 14, 12:06 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Fri, Jun 13, 2008 at 11:01 PM, Karish <[EMAIL PROTECTED]> wrote: > > I want to be able to use my ORM objects (eg, EmailMessage, > > EmailAddress) in some cases without a database. For example, I want to > > write a function like download_email_messages that will download email > > messages and return an EmailMessage object which has a set of > > EmailAddress objects (for the To, From, etc.). The database is not > > involved at this stage. > > If an object doesn't represent something backed by a relational store, > why are you using an object-relational mapper to handle it? > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Disconnected ORM objects
On Fri, Jun 13, 2008 at 11:01 PM, Karish <[EMAIL PROTECTED]> wrote: > I want to be able to use my ORM objects (eg, EmailMessage, > EmailAddress) in some cases without a database. For example, I want to > write a function like download_email_messages that will download email > messages and return an EmailMessage object which has a set of > EmailAddress objects (for the To, From, etc.). The database is not > involved at this stage. If an object doesn't represent something backed by a relational store, why are you using an object-relational mapper to handle it? -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Extending User model with model inheritance?
On Fri, Jun 13, 2008 at 10:54 PM, meppum <[EMAIL PROTECTED]> wrote: > With the query refactoring branch being merged to the trunk I wanted > to finally move some of the data I had put on my user profiles to a > derrived user model. I didn't see this mentioned in the documentation > and I wanted to know if this is possible now? Will the admin tool pick > up new fields? The admin interface does not currently support inheritance; support is planned in newforms-admin, slated to merge to trunk within the next couple of months. In the meantime, subclassing User to add fields offers no performance advantage whatsoever over using a related model, because the subclassing is implemented under the hood as a related table with a foreign key back to the parent class. In many cases it also offers little conceptual advantage, because the great majority of things people typically do with user profiles have little or nothing to do with user authentication. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Cascading updates/inserts
I want to create a bunch of objects that are interconnected in my model (eg, one Book and three Author objects) and then call save() on the Book object to add everything to the database. In other words, I don't want to have to call save() on each and every object (not only will it result in excessive code, but I would have to be very careful to insert them in the right order according to the foreign key relations. Is there any way to achieve this with Django ORM? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Disconnected ORM objects
Hi, I want to be able to use my ORM objects (eg, EmailMessage, EmailAddress) in some cases without a database. For example, I want to write a function like download_email_messages that will download email messages and return an EmailMessage object which has a set of EmailAddress objects (for the To, From, etc.). The database is not involved at this stage. While I can easily create the EmailMessage object and its corresponding EmailAddress objects, when I try to iterate over the EmailMessage object's EmailAddresses objects I get an error because Django ORM tries to access the database. Is there any way to use Django ORM in a disconnected mode, or something like that? (this is what I used to do with SQLAlchemy in all my applications and it works great...) This is what I wanted to do: messages = download_messages() for message in messages: # accessing message.from_address raises django.db.models.base.DoesNotExist message.from_address.save() for address in messages.to_addresses: address.save() message.save() Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Handling unknown data
Thanks guys... to be a little more clear. Each event will have a x of entrants... probably around 30, but I don't really know In event A, they'll have scores in 3 different scored categories, an overall score, there's a couple of fields about them (name, home, etc). No classes. Event B doesn't have different categories, but it does have different classes the entrants fall in, and there's some fields about them. Event C could be anything. Don't know. Eventually, I'd like to pull entrants from the user list, but I can't do that yet (some aren't in there) I was thinking something structured somewhat like django-survey (although hopefully simpler) might work.. where I have a survey, define the questions (in my case, the columns in the results table) then fill in the answers (the rows that match the columns). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Form Validation for GET Request
Maybe because you actually have to pass `action`? ;) Pass it through your form. Maybe my use of 'action' confused you with the 's action property. Not what I meant, sorry. I didn't realize you had an actual form (Wait, why do you .. Ok, beyond the point) but in this case you can just check for any value within your form and see if it's True If your form has a "name" field you could do: if request.GET.get('name'): ... Your initial problem is when you load a page, that Is a GET request so that's why it was going through. On Fri, Jun 13, 2008 at 10:45 PM, ichbindev <[EMAIL PROTECTED]> wrote: > > This is what my template looks like: > > {{ form.as_table }} table> > > This is what my view looks like: > > ... > myform = MyForm() > if request.method=="GET": >myform = MyForm(request.GET) > if request.GET.get('action') == True: > if myform.is_valid(): >... > ... > return render_to_response ('template.html', {'form' : myform}) > > When I first go to the page, requet.GET.get('action') is None. When I > click the 'submit' button, again requet.GET.get('action') is None. I > used HttpResponse to return requet.GET.get('action') as a string. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Form Validation for GET Request
This is what my template looks like: {{ form.as_table }} This is what my view looks like: ... myform = MyForm() if request.method=="GET": myform = MyForm(request.GET) if request.GET.get('action') == True: if myform.is_valid(): ... ... return render_to_response ('template.html', {'form' : myform}) When I first go to the page, requet.GET.get('action') is None. When I click the 'submit' button, again requet.GET.get('action') is None. I used HttpResponse to return requet.GET.get('action') as a string. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: VM mentioned in Where2.0 GeoDjango talk
Hi Pedro, I uploaded it today. It is linked on the front page of http://geodjango.org. Cheers, Travis On Jun 13, 1:36 pm, "Pedro Valente" <[EMAIL PROTECTED]> wrote: > Hello, > > I was reading the presentation "Rapid Geographic Web Application > Development with GeoDjango" > (http://en.oreilly.com/where2008/public/schedule/detail/1666). > > In it there is mention to a Virtual Machine with everything > pre-installed. Does anyone know if it's available for download > somewhere? > It would be great to be able to reproduce that environment without the > hassle of installing and configuring everything. > > Thanks,PedroValente --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Tutorial Clarification
On 13-Jun-08, at 7:23 PM, shabda wrote: >> I have never used generic views, so share your confusion > > Well you really should. :) true - I *do* feel guilty about it, but not guilty enough to go find out how to use them > -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Form Validation for GET Request
If errors are showing when you first load the page then you need to check that the user has actually completed an action before validating the form. In this case, doing something like if request.GET.get('action') == True: # your form validation here In your links back to the system, simply add an ?action=true (or whatever) and that'll fix your issue there. On Fri, Jun 13, 2008 at 10:03 PM, ichbindev <[EMAIL PROTECTED]> wrote: > > The problem is when I use > > myform = MyForm(request.GET) > if myform.is_valid(): > ... > > Any fields which are required have their error message activated on > first visit to page. Also, any 'initial' value that I put in the forms > is not shown. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Form Validation for GET Request
The problem is when I use myform = MyForm(request.GET) if myform.is_valid(): ... Any fields which are required have their error message activated on first visit to page. Also, any 'initial' value that I put in the forms is not shown. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Form Validation for GET Request
On Sat, Jun 14, 2008 at 9:05 AM, ichbindev <[EMAIL PROTECTED]> wrote: > > However, form.is_valid() is for POST only. Is there an is_valid() kind > of thing for forms where method is GET so that data may be validated? I don't know what gave you the idea that is_valid() is just for POST data. There is nothing in the newforms framework that is tied specifically to POST data. You can bind _any_ data to a form, whatever the source. Most of the examples you will see use POST data, because that's the most common way to use forms. However, if you can call: myform = MyForm(request.POST) if myform.is_valid(): ... you could also call: myform = MyForm(request.GET) if myform.is_valid(): ... Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Roadmap to 1.0 and internationalization in db
On Sat, Jun 14, 2008 at 6:57 AM, James Bennett <[EMAIL PROTECTED]> wrote: > > On Fri, Jun 13, 2008 at 5:38 PM, Adrián Ribao <[EMAIL PROTECTED]> wrote: >> I think I can make this work in three weeks, If I do, could it be >> considered for Django 1.0? > > Since it appears that it wouldn't introduce any backwards-incompatible > changes, I'd be against putting it on a 1.0 timeline; it could just as > easily be added in a 1.x release afterward. Also, as I understand it, there isn't consensus in the community about the 'right way' to do this. I haven't been keeping tabs on the very latest developments in these areas, but as I understand it, there are at least two camps that disagree with each other on the right way to put i18n data in the database. This came up during the recent TWID podcast on I18N/L10N; the TWID guys (who are doing a great job, by the way) gave some time to one camp, and apparently got flooded with emails asking why they didn't give the other side the same opportunity. Anything where there is a still a disagreement about the 'right way' to do something is definitely off the table for 1.0. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Form Validation for GET Request
I am writing a report page where users get to enter data in a form and based on it search results are provided. There are at least four fields in the form and all are used in searching. We are not making any changes to data, we should use GET instead of POST as form method. Since this input is going to be used to search database, we need to make sure it is valid before even thinking of sending it further. However, form.is_valid() is for POST only. Is there an is_valid() kind of thing for forms where method is GET so that data may be validated? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Value Error after update to latest Django
I just updated the the latest version of Django and I started getting the following error in the admin interface: Caught an exception while rendering: invalid literal for int() with base 10: 'None' It seems to be the result of a model I have with a DateTimeField with both null and blank set to True, and a date_hierarchy set on the same field. Here is an example model that can re-produce the error: class Post(models.Model): title = models.CharField(max_length=100) publish_date = models.DateTimeField(null=True, blank=True) def __unicode__(self): return unicode(self.title) class Admin: date_hierarchy = 'publish_date' If I revert to a version of Django from before the qs-rf merge the error goes away. I have looked through the Backwards Incompatible changes and can't seem to find anything that would explain it. Is there some sort of work-around, or is this a bug? Thanks, Steven --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Modeling complex ER-diagrams with Django. How to get started?
giovanni wrote: Hello: I am new to Django. I am intrigued by the possibility of providing a web front-end to complex databases. Let's say I have a database with more than 10 or 20 related tables, with a complex ER-diagram, such as, for example, the picture here: http://blog.hundhausen.com/files/AdventureWorksLT.jpg. There are many tables with multiple one-to-many and many-to-one relationships. How easy it is to quickly develop a web front-end for database searches and updates (add,delete,edit records) using Django or some other web application framework? And how would I get started? I only have the ER-diagram and the actual database tables and relationships between the various keys to get started. Once you know the ropes a web front-end can be developed using django fairly quickly. It sounds like you are trying to hook django into an existing database? You can use the 'inspectdb' feature to start creating django models for your specific existing database-- I've heard of some bugs when detecting foreign key, many to many, etc... The first thing to do would be to learn the ins and outs of the django ORM using a blank database-- just get comfortable working with the API. Play with the foreignkey, manytomany, etc... Once you are comfortable with creating django models, the database introspection won't be as beastly to take on-- you'll already be in familiar territory. As for creating the various views for presenting information in the user's browser, it is fairly straightforward. Good luck! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: Can I loop over attributes in model.attribute?
Works like a charm, thank you very much! On Jun 12, 2:09 am, Johannes Dollinger <[EMAIL PROTECTED]> wrote: > You are looking for setattr():http://docs.python.org/lib/built-in- > funcs.html#l2h-66 > > for attr in ('groupon', 'companyon', 'addressfirst', 'extendnames', > 'clubfieldson'): > setattr(settings, attr, attr in data) > > Am 12.06.2008 um 00:48 schriebWimFeijen: > > > > > Thanks Russell! > > > I suppose the code I want to get looks like: > > > settings = Settings.objects.get(owner=userid) > > for switchable in ['groupon', 'companyon', 'addressfirst', > > 'extendnames', 'clubfieldson']: > > if switchable in data: > > settings._meta.get_field(switchable). = True > > else: > > settings._meta.get_field(switchable). = False > > > My remaining question is, as you may have understood, what text do I > > use instead of ? > > > I imagine I could have been using a python function to list some > > options, but I was unable to find out how. I apologize for being > > stupid. > > > Yours sincerely, > > >Wim > > > PS Another thing is, _meta is apparently a hidden function I am not > > supposed to be using. Do you recommend filing this conversation as a > > bug/feature request? Because I would be delighted when we could > > address object columns as settings['groupson'] = False, in order to > > open up all kinds of possible interactions. > > > On Jun 10, 3:38 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> > > wrote: > >> On Tue, Jun 10, 2008 at 9:25 PM,WimFeijen<[EMAIL PROTECTED]> wrote: > > >>> Coding happily away... > > >>> And wondering, can I write better code, using a loop, perhaps? In > >>> other words: can I set settings.groupon while using a variable in > >>> stead of groupon? > > >>> Thanks for any recommendations you are willing to make! > > >> Looks like you might want to have a look at the contents of > >> Settings._meta, also called the Options object. This object > >> contains a > >> lot of meta-data about the class, such as the various names that can > >> be used to refer to the class, the fields on the class, and so on. > >> The > >> meta object is available on the class and on instances. > > >> In particular, you're probably looking to iterate over > >> settings._meta.fields; each member of this list will be a Field > >> object, from which you can get field.name, field.attname, and many > >> other useful details. > > >> Yours, > >> Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Add filters to the Users List/Page in the admin app
lps you decide. > > Hi Rajesh, > > Is it possible for present admin and nf-admin to co-exist? No. > > i.e I change my apps/models to nf-admin one-by-one. So a app/model will > have old admin until it is changed to nf-admin > > Is it possible? You could instead use the following snippet to convert your old admin options to nfa Admin classes: http://www.djangosnippets.org/snippets/603/ I haven't used that snippet personally but it looks like, at a minimum, it will save you loads of time even if it doesn't emit the perfect nfa Admin classes. -RD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: SQLobject vs SQLAlchemy
I'm wondering - are there any performance related reasons to switch from Django ORM to say sqlalchemy? Why does this discussion reoccur every once in a while if there is nothing to gain? Are there other Good Reasons (tm) to switch? Oscar On Fri, Jun 13, 2008 at 8:49 AM, James Bennett <[EMAIL PROTECTED]> wrote: > > On Fri, Jun 13, 2008 at 1:15 AM, Pepsi330ml <[EMAIL PROTECTED]> wrote: > > i shall go read more about SqlObject then. > > If you're planning to use Django, and if you do not already have a > very strong attachment to another ORM, consider just using the one > that comes with Django. It will make your life easier. > > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of > correct." > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Add filters to the Users List/Page in the admin app
Rajesh Dhawan wrote: > Hi Rishabh, > > >> This is what I was thinking, but I thought there was a glimmer of hope of >> achieving this without moving over to newforms-admin. Is there absolutely no >> way to do this using trunk?? >> > > There is: > > 1. You can tweak the django.contrib.auth models.py file in your local > installation i.e. tweak list_filters to your needs in User.Admin inner > class there. > > 2. You can disable the auth application, make a copy of it in your own > Python path, say /my/pythonapps/auth and tweak it there. > > 3. You can "monkey patch" the list_filters option on the Admin inner > class This is highly ugly but won't require you to change the Django > Admin class. Basically, in one of your root level Python modules' > __init__.py insert this: > > from django.contrib.auth.models import User > User._meta.admin.list_filter = None # <--- or replace with whatever > filter you want > > >> I'll give newforms-admin a shot on my dev box over the weekend and see what >> comes out of it. I will research this too, but are there any backwards >> incompatible changes between the current trunk and the newforms-admin >> branch?? I'm thinking the qs-rf merge maybe introduced some issues... >> > > Apart from the admin classes being specified in a different way and > the URLs.py syntax for including admin being different, there should > be no backward incompatible changes. The newforms-admin (nfa) branch > fairly frequently imports latest trunk changes. Here's the last merge > from trunk to nfa: (http://code.djangoproject.com/changeset/7604) In > particular, all qs-rf changes from trunk are already in nfa. > > Hope this helps you decide. > > Hi Rajesh, Is it possible for present admin and nf-admin to co-exist? i.e I change my apps/models to nf-admin one-by-one. So a app/model will have old admin until it is changed to nf-admin Is it possible? Thanks in advance Regards Ganesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Roadmap to 1.0 and internationalization in db
On Fri, Jun 13, 2008 at 5:38 PM, Adrián Ribao <[EMAIL PROTECTED]> wrote: > I think I can make this work in three weeks, If I do, could it be > considered for Django 1.0? Since it appears that it wouldn't introduce any backwards-incompatible changes, I'd be against putting it on a 1.0 timeline; it could just as easily be added in a 1.x release afterward. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Roadmap to 1.0 and internationalization in db
Hello, Here I'm again with the same subject, internationalization in db. I think this should be included in 1.0, it's not so hard, I have thought a way to make it work: We have a class like this: class Book(models.Model): name = models.CharField( max_length=255, i18n=True) And the following line in settings.py LANGUAGES = ( 'en', ugettext(u'English'), 'es', ugettext(u'Spanish') ) Note that name field has an attribute i18n= True. when creating the columns in the db, if i18n=True is found, the extra name_es,... columns is created. I don't like to have separate tables for this for many reasons: 1.- Not easy to interact with the db from a client 2.- Not needed 3.- Decreasing performance the column name contains the string in the first language defined in LANGUAGES, in this case: English. name_i18n_es will contain the name in Spanish language. When the object is accessed: name = Book.objects.get( id=1 ) book.name = 'Name of the book' book.name gets the value of the default language, the first one defined in LANGUAGES, and: book.name_i18n_es = 'Nombre del libro' is stored the string in a different language. book.name should be a function instead of an attribute where you pass the language and get the string. If none is passed you get the string of the first LANGUAGE. Some extra arrays should be added to the _meta options class named i18n_fields and i18n_languages. Using this approach ordering and even full-text with multiple languages is possible. For creating an object: book = Book( name='Name of the book') or: book = Book( name='Name of the book', name_i18n_es='Nombre del libro') With this it would be easier to implement different languages in the newforms.FormForModel and nfa-branch. Filtering could be done in the first approach: field_name = 'name_i18n_%s__contains' % ( language_id ) kwargs={ field_name:'text to search'} I'm not convinced of this but something else could be done inside the django.db I think I can make this work in three weeks, If I do, could it be considered for Django 1.0? Let's be honest, English is not the only language in the world and I have known some companies that didn't switch to django because of this. Any suggestions are welcome. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: OneToOneField
second is true, you need to use OnetOneField(Model,primary=True) to make field primary_key Juanjo Conti pisze: > Here > http://www.djangoproject.com/documentation/db-api/#one-to-one-relationships > says: > > ''' > The semantics of one-to-one relationships will be changing soon, so we > don't recommend you use them. > ''' > > But in > http://www.djangoproject.com/documentation/model-api/#one-to-one-relationships > says: > > ''' > New in Django development version: OneToOneField classes used to > automatically become the primary key on a model. This is no longer > true, although you can manually pass in the primary_key attribute if > you like. Thus, it's now possible to have multiple fields of type > OneToOneField on a single model. > ''' > > Is that last note the change mentioned in the first note? Is the first > note out of date? > > I'd like to use OneToOneField, but I'am note sure because of the first note. > > Thanks > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
OneToOneField
Here http://www.djangoproject.com/documentation/db-api/#one-to-one-relationships says: ''' The semantics of one-to-one relationships will be changing soon, so we don't recommend you use them. ''' But in http://www.djangoproject.com/documentation/model-api/#one-to-one-relationships says: ''' New in Django development version: OneToOneField classes used to automatically become the primary key on a model. This is no longer true, although you can manually pass in the primary_key attribute if you like. Thus, it's now possible to have multiple fields of type OneToOneField on a single model. ''' Is that last note the change mentioned in the first note? Is the first note out of date? I'd like to use OneToOneField, but I'am note sure because of the first note. Thanks -- Juanjo Conti --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Pb with dumpdata/loaddata and unicode
Thanks a lot, that was it. Upgrading to an SVN version of django solved the case. -- LB --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Modeling complex ER-diagrams with Django. How to get started?
Hello: I am new to Django. I am intrigued by the possibility of providing a web front-end to complex databases. Let's say I have a database with more than 10 or 20 related tables, with a complex ER-diagram, such as, for example, the picture here: http://blog.hundhausen.com/files/AdventureWorksLT.jpg. There are many tables with multiple one-to-many and many-to-one relationships. How easy it is to quickly develop a web front-end for database searches and updates (add,delete,edit records) using Django or some other web application framework? And how would I get started? I only have the ER-diagram and the actual database tables and relationships between the various keys to get started. GIovanni --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Timezone conversion
Django initializes the time module with the timezone specified in your settings module. So if you use datetime.datetime.now() you get a datetime instance from the specified timezone (but still a naive datetime object). If you build your own datetime instances, I think they will get stored as is into the database. So the timezone setting should only be relevant for now() calls IMO. -- Horst On Fri, Jun 13, 2008 at 8:31 PM, Darthmahon <[EMAIL PROTECTED]> wrote: > Hi Horst, > > Thanks to your earlier post I now have time zones working! :) > > To be honest I didn't like the sound of using the mysql way, sounded a > bit too much like a hack to me. > > One final question though - when you use the datetime field and insert > into the database, is that date UTC or based on my TIME_ZONE setting > in Django? > > On Jun 13, 4:59 pm, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: >> Well, to what user's timezone? SET (IIRC) changes the setting for the >> whole database connection (at least) so if you have multiple inserts >> for multiple users while using the same connection, the same setting >> their applies. Meaning it would affect not only one user put >> potentially multiple users that you actually don't want to use this >> timezone. >> >> IMO stuff like that should be left to the application esp. if you want >> users to have different timezones. In such a case you'd have to store >> the user's timezone somewhere. Here it would probably be best to store >> the "name" of the timezone (like for instance Europe/Vienna). I'm not >> 100% sure, but IMO this would give you the benefit of leaving the >> whole DST stuff to the underlying system instead of having to fight >> with questions like "Does the user live in a country with n hours of >> offset where there is DST?", "When does DST apply in this user's >> timezone?", etc. >> >> If I'm not mistaken dateutil.tz.tzfile (which you get when using >> dateutil.tz.gettz) handles all this. >> >> -- Horst >> >> On Fri, Jun 13, 2008 at 3:01 PM, Darthmahon <[EMAIL PROTECTED]> wrote: >> > Hi, >> >> > Just been having a chat with someone at work and was offered an >> > alternative. >> >> > First of he said I should use a timestamp field instead of a datetime >> > field, and then I can use " SET time_zone " in MySQL and that way all >> > dates will be automatically converted to the users timezone. >> >> >http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html >> >> > Any ideas if this is a good way of doing this? >> >> > On Jun 13, 9:37 am, Darthmahon <[EMAIL PROTECTED]> wrote: >> >> Yea that's the one - so hopefully, once I assign it a timezone >> >> with .replace it will recognise it properly :) >> >> >> Excellent, I'll try it tonight. Thanks for all your help Horst :) >> >> >> On Jun 13, 9:27 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: >> >> >> > Do you mean something like this? >> >> >> > ValueError: astimezone() cannot be applied to a naive datetime >> >> >> > This just means that the datetime instance you're working with, has no >> >> > timezone associated with it :-) >> >> >> > -- Horst >> >> >> > On Fri, Jun 13, 2008 at 10:22 AM, Darthmahon <[EMAIL PROTECTED]> wrote: >> >> > > Right, so it doesn't automatically assign timezone information to it? >> >> > > I've seen some other examples where people have two/three fields just >> >> > > to store the timezone and date but I'd rather not have to go through >> >> > > all of that. >> >> >> > > At work at the moment, but will try this when I get home :) >> >> >> > > Any idea what is means by "naive datetime"? >> >> >> > > On Jun 13, 9:16 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: >> >> > >> From what I can see in the database, DateTime stores its content in >> >> > >> the timezone specified in the settings.py by default. So when you >> >> > >> fetch a datetime from the database you have to associated the >> >> > >> respective timezone with that datetime instance: >> >> >> > >> tzedate = edate.replace(tzinfo=gettz(settings.TIMEZONE)) >> >> > >> tz = gettz('America/New_York') >> >> > >> edatetz = tzedate.astimezone(tz) >> >> >> > >> Just a wild guess, though. >> >> >> > >> -- Horst >> >> >> > >> On Fri, Jun 13, 2008 at 10:07 AM, Darthmahon <[EMAIL PROTECTED]> >> >> > >> wrote: >> >> > >> > Hi Guys, >> >> >> > >> > I want to convert a datetime field for an entry in my database to a >> >> > >> > specified timezone. Here is the code I have so far: >> >> >> > >> > from dateutil.parser import * >> >> > >> > from dateutil.tz import * >> >> > >> > from datetime import * >> >> >> > >> > event = get_object_or_404(Event, id__exact=eventid) >> >> > >> > edate = event.date >> >> > >> > tz = gettz('America/New_York') >> >> > >> > edatetz = edate.astimezone(tz) >> >> >> > >> > Now, when I do this, I get something along the lines of "naive >> >> > >> > datetime" for the edate variable. However, if I change the edate >> >> > >> > variable to the following line of code, it works: >> >> >> > >> > edate = datetime.now(tz=gettz('UTC')) >> >
VM mentioned in Where2.0 GeoDjango talk
Hello, I was reading the presentation "Rapid Geographic Web Application Development with GeoDjango" ( http://en.oreilly.com/where2008/public/schedule/detail/1666 ). In it there is mention to a Virtual Machine with everything pre-installed. Does anyone know if it's available for download somewhere? It would be great to be able to reproduce that environment without the hassle of installing and configuring everything. Thanks, Pedro Valente --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Timezone conversion
Hi Horst, Thanks to your earlier post I now have time zones working! :) To be honest I didn't like the sound of using the mysql way, sounded a bit too much like a hack to me. One final question though - when you use the datetime field and insert into the database, is that date UTC or based on my TIME_ZONE setting in Django? On Jun 13, 4:59 pm, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > Well, to what user's timezone? SET (IIRC) changes the setting for the > whole database connection (at least) so if you have multiple inserts > for multiple users while using the same connection, the same setting > their applies. Meaning it would affect not only one user put > potentially multiple users that you actually don't want to use this > timezone. > > IMO stuff like that should be left to the application esp. if you want > users to have different timezones. In such a case you'd have to store > the user's timezone somewhere. Here it would probably be best to store > the "name" of the timezone (like for instance Europe/Vienna). I'm not > 100% sure, but IMO this would give you the benefit of leaving the > whole DST stuff to the underlying system instead of having to fight > with questions like "Does the user live in a country with n hours of > offset where there is DST?", "When does DST apply in this user's > timezone?", etc. > > If I'm not mistaken dateutil.tz.tzfile (which you get when using > dateutil.tz.gettz) handles all this. > > -- Horst > > On Fri, Jun 13, 2008 at 3:01 PM, Darthmahon <[EMAIL PROTECTED]> wrote: > > Hi, > > > Just been having a chat with someone at work and was offered an > > alternative. > > > First of he said I should use a timestamp field instead of a datetime > > field, and then I can use " SET time_zone " in MySQL and that way all > > dates will be automatically converted to the users timezone. > > >http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html > > > Any ideas if this is a good way of doing this? > > > On Jun 13, 9:37 am, Darthmahon <[EMAIL PROTECTED]> wrote: > >> Yea that's the one - so hopefully, once I assign it a timezone > >> with .replace it will recognise it properly :) > > >> Excellent, I'll try it tonight. Thanks for all your help Horst :) > > >> On Jun 13, 9:27 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > > >> > Do you mean something like this? > > >> > ValueError: astimezone() cannot be applied to a naive datetime > > >> > This just means that the datetime instance you're working with, has no > >> > timezone associated with it :-) > > >> > -- Horst > > >> > On Fri, Jun 13, 2008 at 10:22 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > >> > > Right, so it doesn't automatically assign timezone information to it? > >> > > I've seen some other examples where people have two/three fields just > >> > > to store the timezone and date but I'd rather not have to go through > >> > > all of that. > > >> > > At work at the moment, but will try this when I get home :) > > >> > > Any idea what is means by "naive datetime"? > > >> > > On Jun 13, 9:16 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > >> > >> From what I can see in the database, DateTime stores its content in > >> > >> the timezone specified in the settings.py by default. So when you > >> > >> fetch a datetime from the database you have to associated the > >> > >> respective timezone with that datetime instance: > > >> > >> tzedate = edate.replace(tzinfo=gettz(settings.TIMEZONE)) > >> > >> tz = gettz('America/New_York') > >> > >> edatetz = tzedate.astimezone(tz) > > >> > >> Just a wild guess, though. > > >> > >> -- Horst > > >> > >> On Fri, Jun 13, 2008 at 10:07 AM, Darthmahon <[EMAIL PROTECTED]> > >> > >> wrote: > >> > >> > Hi Guys, > > >> > >> > I want to convert a datetime field for an entry in my database to a > >> > >> > specified timezone. Here is the code I have so far: > > >> > >> > from dateutil.parser import * > >> > >> > from dateutil.tz import * > >> > >> > from datetime import * > > >> > >> > event = get_object_or_404(Event, id__exact=eventid) > >> > >> > edate = event.date > >> > >> > tz = gettz('America/New_York') > >> > >> > edatetz = edate.astimezone(tz) > > >> > >> > Now, when I do this, I get something along the lines of "naive > >> > >> > datetime" for the edate variable. However, if I change the edate > >> > >> > variable to the following line of code, it works: > > >> > >> > edate = datetime.now(tz=gettz('UTC')) > > >> > >> > Any ideas why this is happening? Is it the way I am storing the > >> > >> > datetime in my MySQL database? I'm using a standard datetime field - > >> > >> > is it missing something? > > >> > >> > Cheers, > >> > >> > Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/
Re: DjangoAMF vs. pyAMF - any opinions?
Hi J Peyret... I'm in the same trouble that you... Do you have an advice for me, based in you researchs and in your knowledges after this message (May 2)? Thanks a lot On 5/2/08, J Peyret <[EMAIL PROTECTED]> wrote: > > > I am just starting out with Flex 3 and I'd like to know if anybody's > got any strong opinions on which AMF<=>Python bridge is best for using > AMF to talk to Django. > > I do know Python and am somewhat familiar with Django. > > Things that make a difference to me, roughly in order of decreasing > importance: > > - code maturity > - how much activity there is on the project, by how many developers > - absolute drop-dead bugs that prohibit using either under specific > circumstances > - documentation > - ease of use and clean design > - performance > > Far as I can tell from surfing around, DjangoAMF is more mature and > perhaps easier to set up, but it is hosted in Japan and last time I > checked I didn't speak Japanese so I am worried about missing out on > the latest project "gossip". > > Neither seem to have much documentation going for them. That's OK to > an extent, I'll probably try both, but I'd welcome some insight from > people who have used them in anger. > > What I would like to do is to move data back and forth from a Django- > based postgreSQL database backend to a GUI application with complex > behavior requirements, using Apache to serve the SWFs. Not all of the > relational data will be housed in Django models either, as I will use > some raw SQL to manipulate it as needed. > > Any opinions? > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template engine
Would it be possible to borrow from the embedded ruby syntax and define something like this: {{ variable.name -}} {% tag param1,param2 -%} If the '-' was present as part of the tag closure token, the template processor would eat the next 1-2 characters only if they were a CR or CR/LF. Although I suppose this might cause problems for some tags that had begin/end pairs, -- Scott On Fri, Jun 13, 2008 at 1:43 PM, Norman Harman <[EMAIL PROTECTED]> wrote: > > Russell Keith-Magee wrote: > > If there is a particular whitespace-eating behaviour that you would > > like, you could always implement it yourself in a template tag. If you > > think the template tag could be useful for others, you can share it on > > djangosnippets.org, or open a ticket to have the tag considered for > > inclusion in Django itself. > > > > If what you're proposing can't be done in a template tag, we're always > > open to suggestions on how to make Django better. Put down your ideas > > in a ticket, and we'll consider it. > > What I'm use to is less of particular tag and more of a change to how > all tags/templates work. In short, lines in templates that have only > tags should be "invisible" i.e. they should not be in the output of that > template. > > If after doing tag processing a line(that had 1+ tags to begin with) > consists of nothing but whitespace then eliminate that line, including > it's new line. > > line numbers for ref: > 1: {% if bar %}bar{% endif %} > 2: {% for i in list %} > 3: i > 4: {% if False %}{% endif %} > 5: {% endfor %} > 6: > > which now creates something like this when bar=False, list=[1,2] > 1: > 2: > 3: 1 > 4: > 3: 2 > 4: > 5: > 6: > > instead outputs this > 1: > 3: 1 > 3: 2 > 6: > > > But this is a backwards incompatible change, a minor issue, and with > effort it's possible to work around this issue just not beautifully > (which contrasts with the rest of Django). > > Other stuff is higher priority and the real problem with Django is > http://superjared.com/entry/real-problem-django/. I didn't mean to > sound complainy in previous post, if anyone took it that way. > > -- > Norman J. Harman Jr. > Senior Web Specialist, Austin American-Statesman > ___ > You've got fun! Check out Austin360.com for all the entertainment > info you need to live it up in the big city! > > > > -- http://scott.andstuff.org/ | http://truthadorned.org/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template engine
Russell Keith-Magee wrote: > If there is a particular whitespace-eating behaviour that you would > like, you could always implement it yourself in a template tag. If you > think the template tag could be useful for others, you can share it on > djangosnippets.org, or open a ticket to have the tag considered for > inclusion in Django itself. > > If what you're proposing can't be done in a template tag, we're always > open to suggestions on how to make Django better. Put down your ideas > in a ticket, and we'll consider it. What I'm use to is less of particular tag and more of a change to how all tags/templates work. In short, lines in templates that have only tags should be "invisible" i.e. they should not be in the output of that template. If after doing tag processing a line(that had 1+ tags to begin with) consists of nothing but whitespace then eliminate that line, including it's new line. line numbers for ref: 1: {% if bar %}bar{% endif %} 2: {% for i in list %} 3: i 4: {% if False %}{% endif %} 5: {% endfor %} 6: which now creates something like this when bar=False, list=[1,2] 1: 2: 3: 1 4: 3: 2 4: 5: 6: instead outputs this 1: 3: 1 3: 2 6: But this is a backwards incompatible change, a minor issue, and with effort it's possible to work around this issue just not beautifully (which contrasts with the rest of Django). Other stuff is higher priority and the real problem with Django is http://superjared.com/entry/real-problem-django/. I didn't mean to sound complainy in previous post, if anyone took it that way. -- Norman J. Harman Jr. Senior Web Specialist, Austin American-Statesman ___ You've got fun! Check out Austin360.com for all the entertainment info you need to live it up in the big city! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template engine
Is this white-space behavior the case with all template tags? Is it desirable for all template tags? Maybe only tags that are common to be at the top of a template file could have this enhancement to erase whitespace between them and the next real tag in the template? It seems to me that if certain template tags are going to be present at the top of a template file, and it would help their ease of use to have trailing whitespace removed then those tags should be treated a little differently than other tags. Just my $.02 On Jun 13, 11:45 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On Fri, Jun 13, 2008 at 11:58 PM, Arien <[EMAIL PROTECTED]> wrote: > > > On Fri, Jun 13, 2008 at 9:48 AM, Norman Harman <[EMAIL PROTECTED]> wrote: > >> Template's white space handling is one of the few things that irks me > >> about Django. I hate having to make confusing formating, jamming stuff > >> all on the same line just to get white space correct. > > >> I really wish it had some whitespace handling tools like Cheetah > >>http://www.cheetahtemplate.org/docs/users_guide_html/users_guide.html... > > > Or Template Toolkit's: > > >http://template-toolkit.org/docs/manual/Syntax.html#section_Chomping_... > > If there is a particular whitespace-eating behaviour that you would > like, you could always implement it yourself in a template tag. If you > think the template tag could be useful for others, you can share it on > djangosnippets.org, or open a ticket to have the tag considered for > inclusion in Django itself. > > If what you're proposing can't be done in a template tag, we're always > open to suggestions on how to make Django better. Put down your ideas > in a ticket, and we'll consider it. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: auto generate models
On 2008-06-12 15:13:23 -0600, Justin Kennedy <[EMAIL PROTECTED]> said: > With Django, as I understand it, the class models have to be developer > first, and it takes care of setting up the db tables. I really prefer > this method, however, I would still like to create my Class Diagrams or > DB Model first so I can visualize the relations between the models as a > whole. It would be nice if I could generate the basic Django models from > a DB Schema/model or Class Diagram or similar tools. It is common to just start designing your models using Python. Models in Django are written declaratively which enable a very nice syntax for creating database tables and keep it mapped properly in the ORM. > > I tried using manage.py inspectdb but it didn't auto detect the > relations. The basic db is like: > > table: milestone > columns: id, title, due_date > > table: task > columns: id, milestone_id, title, due_date inspectdb is meant to help you get to the finish line and not cross it for you. It does as much as it can, but as you have discovered it has some problems with certain database backends due to their nature. There is no reason to still not use insepctdb. Just convert the foreign keys it missed. For example if it resulted in:: milestone_id = models.PositiveIntegerField() Simply change it to:: milestone = models.ForeignKey(Milestone) The underlying datatype won't need to be changed. This will make sure that the ORM generates the SQL you would expect from a foreign key. -- Brian Rosner http://oebfare.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template engine
On Fri, Jun 13, 2008 at 11:58 PM, Arien <[EMAIL PROTECTED]> wrote: > > On Fri, Jun 13, 2008 at 9:48 AM, Norman Harman <[EMAIL PROTECTED]> wrote: >> Template's white space handling is one of the few things that irks me >> about Django. I hate having to make confusing formating, jamming stuff >> all on the same line just to get white space correct. >> >> I really wish it had some whitespace handling tools like Cheetah >> http://www.cheetahtemplate.org/docs/users_guide_html/users_guide.html#SECTION00068 > > Or Template Toolkit's: > > http://template-toolkit.org/docs/manual/Syntax.html#section_Chomping_Whitespace If there is a particular whitespace-eating behaviour that you would like, you could always implement it yourself in a template tag. If you think the template tag could be useful for others, you can share it on djangosnippets.org, or open a ticket to have the tag considered for inclusion in Django itself. If what you're proposing can't be done in a template tag, we're always open to suggestions on how to make Django better. Put down your ideas in a ticket, and we'll consider it. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
registration with mandatory profile
Hi all! I need an app, which registers users but also forces user to fill out a profile. I found the link below, but it seems to me, that django-profile will not send email, and with django-registration I cannot force users to fill out a profile (I would like to use ModelForm for this) So what is the easiest mode to register a user with email validation and force them fill out a profile? thanks http://groups.google.com/group/django-users/browse_thread/thread/81712c8e4291213c/e39542cf906ead43?lnk=gst&q=registration#e39542cf906ead43 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Timezone conversion
Well, to what user's timezone? SET (IIRC) changes the setting for the whole database connection (at least) so if you have multiple inserts for multiple users while using the same connection, the same setting their applies. Meaning it would affect not only one user put potentially multiple users that you actually don't want to use this timezone. IMO stuff like that should be left to the application esp. if you want users to have different timezones. In such a case you'd have to store the user's timezone somewhere. Here it would probably be best to store the "name" of the timezone (like for instance Europe/Vienna). I'm not 100% sure, but IMO this would give you the benefit of leaving the whole DST stuff to the underlying system instead of having to fight with questions like "Does the user live in a country with n hours of offset where there is DST?", "When does DST apply in this user's timezone?", etc. If I'm not mistaken dateutil.tz.tzfile (which you get when using dateutil.tz.gettz) handles all this. -- Horst On Fri, Jun 13, 2008 at 3:01 PM, Darthmahon <[EMAIL PROTECTED]> wrote: > Hi, > > Just been having a chat with someone at work and was offered an > alternative. > > First of he said I should use a timestamp field instead of a datetime > field, and then I can use " SET time_zone " in MySQL and that way all > dates will be automatically converted to the users timezone. > > http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html > > Any ideas if this is a good way of doing this? > > On Jun 13, 9:37 am, Darthmahon <[EMAIL PROTECTED]> wrote: >> Yea that's the one - so hopefully, once I assign it a timezone >> with .replace it will recognise it properly :) >> >> Excellent, I'll try it tonight. Thanks for all your help Horst :) >> >> On Jun 13, 9:27 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: >> >> > Do you mean something like this? >> >> > ValueError: astimezone() cannot be applied to a naive datetime >> >> > This just means that the datetime instance you're working with, has no >> > timezone associated with it :-) >> >> > -- Horst >> >> > On Fri, Jun 13, 2008 at 10:22 AM, Darthmahon <[EMAIL PROTECTED]> wrote: >> > > Right, so it doesn't automatically assign timezone information to it? >> > > I've seen some other examples where people have two/three fields just >> > > to store the timezone and date but I'd rather not have to go through >> > > all of that. >> >> > > At work at the moment, but will try this when I get home :) >> >> > > Any idea what is means by "naive datetime"? >> >> > > On Jun 13, 9:16 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: >> > >> From what I can see in the database, DateTime stores its content in >> > >> the timezone specified in the settings.py by default. So when you >> > >> fetch a datetime from the database you have to associated the >> > >> respective timezone with that datetime instance: >> >> > >> tzedate = edate.replace(tzinfo=gettz(settings.TIMEZONE)) >> > >> tz = gettz('America/New_York') >> > >> edatetz = tzedate.astimezone(tz) >> >> > >> Just a wild guess, though. >> >> > >> -- Horst >> >> > >> On Fri, Jun 13, 2008 at 10:07 AM, Darthmahon <[EMAIL PROTECTED]> wrote: >> > >> > Hi Guys, >> >> > >> > I want to convert a datetime field for an entry in my database to a >> > >> > specified timezone. Here is the code I have so far: >> >> > >> > from dateutil.parser import * >> > >> > from dateutil.tz import * >> > >> > from datetime import * >> >> > >> > event = get_object_or_404(Event, id__exact=eventid) >> > >> > edate = event.date >> > >> > tz = gettz('America/New_York') >> > >> > edatetz = edate.astimezone(tz) >> >> > >> > Now, when I do this, I get something along the lines of "naive >> > >> > datetime" for the edate variable. However, if I change the edate >> > >> > variable to the following line of code, it works: >> >> > >> > edate = datetime.now(tz=gettz('UTC')) >> >> > >> > Any ideas why this is happening? Is it the way I am storing the >> > >> > datetime in my MySQL database? I'm using a standard datetime field - >> > >> > is it missing something? >> >> > >> > Cheers, >> > >> > Chris > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template engine
On Fri, Jun 13, 2008 at 9:48 AM, Norman Harman <[EMAIL PROTECTED]> wrote: > Template's white space handling is one of the few things that irks me > about Django. I hate having to make confusing formating, jamming stuff > all on the same line just to get white space correct. > > I really wish it had some whitespace handling tools like Cheetah > http://www.cheetahtemplate.org/docs/users_guide_html/users_guide.html#SECTION00068 Or Template Toolkit's: http://template-toolkit.org/docs/manual/Syntax.html#section_Chomping_Whitespace Arien --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Handling unknown data
Hi, > I've got an "events" model. One of the things many (but not all) of > the events will have is results. Problem is, I don't know what the > results will look like in terms of rows or columns. > > Event 1 may have three classes, two groups and 40 winners, with 5 > fields for each winner (home state, beer preference, etc) > > Event 2 may have 1 class with 5 groups, 20 winners, and 10 fields for > each winner > > And so forth. I'd like to store the results for the event, but can't > figure out how. The event object is generic, but the results > structures are specific to that event. > > Suggestions? >From your two examples above, it looks like an Event result's "root" is a result "class". Are the structures for classes and groups also dependent on the event or is it just that a winner's "profile" fields need to be flexible? If classes and groups have a fixed model then, you could model that: ResultClass eEvent (FK) other fields ... Group result_class (FK) other fields ... Winner user (FK) group (FK) other fields ... Possibly: Meta constraint -> unique_together (user, group) WinnerProperty winner (FK) field_name - char field field_value - char field - RD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django test Client problems
Hi, If you want to add functionalities to test client, you may need to modify (or subclass, if posible ) the client code (django.test.client.Client). I used to add ability to set, get "HTTP_HOST" environment, For example, > self.client.http_host = "google.com" So, when my I run unit test, my code still work. For your situation, you propbably add 'REMOTE_ADDR' in request environment, def request(self, **request): """ The master request method. Composes the environment dictionary and passes to the handler, returning the result of the handler. Assumes defaults for the query environment, which can be overridden using the arguments to the request. """ environ = { 'HTTP_COOKIE': self.cookies, 'PATH_INFO': '/', 'QUERY_STRING': '', 'REQUEST_METHOD':'GET', 'SCRIPT_NAME': None, 'SERVER_NAME': 'testserver', 'SERVER_PORT': 80, 'SERVER_PROTOCOL': 'HTTP/1.1', 'REMOTE_ADDR':'127.0.0.1', } For the session, I guess you may need to do the same thing. Hope this help. Chatchai 2008/6/13 shabda <[EMAIL PROTECTED]>: > > I have some code like this, > > c = Client() > client.get('/myurl/') > > where '//myurl' calls view function, > > def foo(request): > ip_addrs = request.META['REMOTE_ADDR'] > > This view function works when I use a browser, as > request.META['REMOTE_ADDR'] is populated. But when I use test Client, > I get a keyerror, as resquests generated by Clinet() do not have > request.META['REMOTE_ADDR'] populated. > > Related question, how do I set a value on requests.sessions before > making a call to Client().get() > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms-admin permissions
emont88 wrote: > I just switched over to the newforms-admin branch because I need to > add specific permissions to my admin site. > I have been looking over the newforms-admin howto and the ModelAdmin > class, but I haven't been able to figure very much out. > > My app is a blogging app that needs to support multiple blogs, each > with multiple authors. Each author will only have access to edit a > single blog. Basically, I think I just need to figure out row-level > permissions, but I'm not sure where to start. Study the class ModelAdmin in the file django/contrib/admin/ options.py. There are has_*_permission() methods there that you can override in your own Admin class. There's an example of an overridden has_change_permission method in the docs: http://code.djangoproject.com/wiki/NewformsAdminBranch > > Also, since an author can only post to a single blog, I need to be > able to set the Entry.author and Entry.blog fields automatically when > they are writing a new post, based on the currently signed-in User. > I'm not sure how to add that either since you can't just access > request.user within Entry's save() method. Your Admin class could override the ModelAdmin.save_add() and .change_add() methods. In these methods, you will have access to the request object from which you can do your request.user magic. -RD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom filters tied to form fields
Hi Roodie, > Anyway, currently I see 2 solutions: > > 1. The longer way is to use the filter in the clean_ functions - > tedious job... > 2. Create a custom TextArea widget and implement the cleaning feature > there > > I think I wills tick with option #2 but maybe I missed some > undocumented attribute / function somewhere. You should consider creating a custom field rather than a custom widget. Something like: class TinyMCEField(forms.CharField): def __init__(self, *args, **kwargs): kwargs['widget'] = kwargs.get('widget', Textarea()) super(TinyMCEField, self).__init__(*args, **kwargs) def clean(self, value): # do your clean up of value here return value -RD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: remove references
Hello, > how can I achieve that a custom function (maybe in my model class) gets > called if a model becomes deleted? > > What I want to do is to ensure that all references to a model are > removed when it woun't exist any longer in the database. > > Is that possible? Yes, in a couple of ways: 1. You can override the delete() method on your model and do cleanup before calling super(YourModel, self).delete() 2. You can hook in a custom function to a pre_delete or post_delete signal. See:http://code.djangoproject.com/wiki/Signals -Rajesh D --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Session lost between two requests from the test client
ksachdeva wrote: > Hi, > > From a testcase I first issue a 'get' request to a view (say view1) > where I set a request.session['m_key'] = 'myval'. Now I issue a 'post' > request to a view (say view2). In view2, I tried to obtain > request.session['m_key'] but I get an error that session does not have > 'm_key' key. I've spent a lot of time debugging session problems only to discover I had made the bone headed mistake of having this settings combo CACHE_BACKEND="dummy://" SESSION_ENGINE="django.contrib.sessions.backends.cache" ... -- Norman J. Harman Jr. Senior Web Specialist, Austin American-Statesman ___ You've got fun! Check out Austin360.com for all the entertainment info you need to live it up in the big city! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Add filters to the Users List/Page in the admin app
Hi Rishabh, > This is what I was thinking, but I thought there was a glimmer of hope of > achieving this without moving over to newforms-admin. Is there absolutely no > way to do this using trunk?? There is: 1. You can tweak the django.contrib.auth models.py file in your local installation i.e. tweak list_filters to your needs in User.Admin inner class there. 2. You can disable the auth application, make a copy of it in your own Python path, say /my/pythonapps/auth and tweak it there. 3. You can "monkey patch" the list_filters option on the Admin inner class This is highly ugly but won't require you to change the Django Admin class. Basically, in one of your root level Python modules' __init__.py insert this: from django.contrib.auth.models import User User._meta.admin.list_filter = None # <--- or replace with whatever filter you want > > I'll give newforms-admin a shot on my dev box over the weekend and see what > comes out of it. I will research this too, but are there any backwards > incompatible changes between the current trunk and the newforms-admin > branch?? I'm thinking the qs-rf merge maybe introduced some issues... Apart from the admin classes being specified in a different way and the URLs.py syntax for including admin being different, there should be no backward incompatible changes. The newforms-admin (nfa) branch fairly frequently imports latest trunk changes. Here's the last merge from trunk to nfa: (http://code.djangoproject.com/changeset/7604) In particular, all qs-rf changes from trunk are already in nfa. Hope this helps you decide. -Rajesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template engine
Juanjo Conti wrote: > Hi, I am using Django's template engine to produce rtf files and I > have noticed something: if the first line of my template is a {%load > ... %} tag then the result has a withe like at the to of it. This is > not a problem in html, the common use of the tempalte engine, but is > fatal in a rtf file. > > I write this because I think that this behaibour should bi fixed, am I right? > > Anyway I have putted the load tag in the second line of my tempalte :) > > Juanjo Template's white space handling is one of the few things that irks me about Django. I hate having to make confusing formating, jamming stuff all on the same line just to get white space correct. I really wish it had some whitespace handling tools like Cheetah http://www.cheetahtemplate.org/docs/users_guide_html/users_guide.html#SECTION00068 The spaceless tag helps sometimes, but not for your situation. -- Norman J. Harman Jr. Senior Web Specialist, Austin American-Statesman ___ You've got fun! Check out Austin360.com for all the entertainment info you need to live it up in the big city! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Does django-driven Blog popular?
<3 byteflow i dont use the blog itsself, but i have stolen a ton of ideas from it. On Jun 13, 12:11 am, Eugene Lazutkin <[EMAIL PROTECTED]> wrote: > It is stupidly easy to write a blog using Django, and many people do so. > You can find many examples out there. One complete example is the > Byteflow:http://byteflow.su/ > > Thanks, > > Eugene > > kylin wrote: > > Thanks > > I am looking forward to finding some samples to study.Could you give > > me any advices? > > > On 6月13日, 上午11时39分, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > >> On 13-Jun-08, at 8:51 AM, kylin wrote: > > >>> I am a newbie of django.Dose django-driven blog software pop? > >>> Actually,I have not seen any blog software as good as wordpress ever. > >>> Thus, why this fantastic framework have not driven a good enough blog > >>> system? > >> django is not a cms, it is a web framework which helps developers to > >> build web applications - which would include blogs. There are a few > >> blogs written in django (more than a few, I think everyone who uses > >> django has written a piece of blog software at some time) > > >> -- > > >> regards > >> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django test Client problems
I have some code like this, c = Client() client.get('/myurl/') where '//myurl' calls view function, def foo(request): ip_addrs = request.META['REMOTE_ADDR'] This view function works when I use a browser, as request.META['REMOTE_ADDR'] is populated. But when I use test Client, I get a keyerror, as resquests generated by Clinet() do not have request.META['REMOTE_ADDR'] populated. Related question, how do I set a value on requests.sessions before making a call to Client().get() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Tutorial Clarification
> I have never used generic views, so share your confusion Well you really should. :) Well I have seen your name many times on the list so know that you are a longtime Django user. If you are not using generic views, you are missing something. On Jun 13, 12:41 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 13-Jun-08, at 12:54 PM, wave connexion(BQ) wrote: > > > 1. in reading overview, "you've got a free, and rich, Python API to > > access your data. The API is created on the fly, no code generation > > necessary?" > > > Does this mean Django generated API code for you? > > django does not generate a single line of code - unlike some other > frameworks which need to generate all sorts of files with all sorts > of rules about filenames and position of the file. > > > > > 2. in tutorial part 1, "What's the difference between a project and > > an app? An app is a Web application that does something — e.g., a > > weblog system, a database of public records or a simple poll app. A > > project is a collection of configuration and apps for a particular > > Web site. A project can contain multiple apps. An app can be in > > multiple projects." > > > Here, that an app can be in multiple projects means the app code > > can be copied/imported into different projects rather than shared > > between different projects? > > app code can be imported into different projects. apps need not be > under the project directory, they can be anywhere in the file system > as long as django can find them (installed apps). > > > > > 3. in tutorial part 4 - > > "Use generic views: Less code is better... > > url(r'^(?P\d+)/results/$', > > 'django.views.generic.list_detail.object_detail', dict(info_dict, > > template_name='polls/results.html'), 'poll_results'), " > > > not very clear on this. more explanation is appreciated. > > I have never used generic views, so share your confusion > > -- > > regards > kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Timezone conversion
Hi, Just been having a chat with someone at work and was offered an alternative. First of he said I should use a timestamp field instead of a datetime field, and then I can use " SET time_zone " in MySQL and that way all dates will be automatically converted to the users timezone. http://dev.mysql.com/doc/refman/5.0/en/time-zone-support.html Any ideas if this is a good way of doing this? On Jun 13, 9:37 am, Darthmahon <[EMAIL PROTECTED]> wrote: > Yea that's the one - so hopefully, once I assign it a timezone > with .replace it will recognise it properly :) > > Excellent, I'll try it tonight. Thanks for all your help Horst :) > > On Jun 13, 9:27 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > > > Do you mean something like this? > > > ValueError: astimezone() cannot be applied to a naive datetime > > > This just means that the datetime instance you're working with, has no > > timezone associated with it :-) > > > -- Horst > > > On Fri, Jun 13, 2008 at 10:22 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Right, so it doesn't automatically assign timezone information to it? > > > I've seen some other examples where people have two/three fields just > > > to store the timezone and date but I'd rather not have to go through > > > all of that. > > > > At work at the moment, but will try this when I get home :) > > > > Any idea what is means by "naive datetime"? > > > > On Jun 13, 9:16 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > > >> From what I can see in the database, DateTime stores its content in > > >> the timezone specified in the settings.py by default. So when you > > >> fetch a datetime from the database you have to associated the > > >> respective timezone with that datetime instance: > > > >> tzedate = edate.replace(tzinfo=gettz(settings.TIMEZONE)) > > >> tz = gettz('America/New_York') > > >> edatetz = tzedate.astimezone(tz) > > > >> Just a wild guess, though. > > > >> -- Horst > > > >> On Fri, Jun 13, 2008 at 10:07 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > > >> > Hi Guys, > > > >> > I want to convert a datetime field for an entry in my database to a > > >> > specified timezone. Here is the code I have so far: > > > >> > from dateutil.parser import * > > >> > from dateutil.tz import * > > >> > from datetime import * > > > >> > event = get_object_or_404(Event, id__exact=eventid) > > >> > edate = event.date > > >> > tz = gettz('America/New_York') > > >> > edatetz = edate.astimezone(tz) > > > >> > Now, when I do this, I get something along the lines of "naive > > >> > datetime" for the edate variable. However, if I change the edate > > >> > variable to the following line of code, it works: > > > >> > edate = datetime.now(tz=gettz('UTC')) > > > >> > Any ideas why this is happening? Is it the way I am storing the > > >> > datetime in my MySQL database? I'm using a standard datetime field - > > >> > is it missing something? > > > >> > Cheers, > > >> > Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
remove references
Hello, how can I achieve that a custom function (maybe in my model class) gets called if a model becomes deleted? What I want to do is to ensure that all references to a model are removed when it woun't exist any longer in the database. Is that possible? Regards, Constantin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Add filters to the Users List/Page in the admin app
This is what I was thinking, but I thought there was a glimmer of hope of achieving this without moving over to newforms-admin. Is there absolutely no way to do this using trunk?? I'll give newforms-admin a shot on my dev box over the weekend and see what comes out of it. I will research this too, but are there any backwards incompatible changes between the current trunk and the newforms-admin branch?? I'm thinking the qs-rf merge maybe introduced some issues... Thanks anyways, R On 6/12/08, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > > > Hi Rishabh, > > > > > Now, the django admin app provides (by default) a page where user details > > are listed. I do not want to change that list. However, I would like to > add > > filters on that page (remove the superuser status and staff status > filters > > and add others like TechSkillsList etc.). I was wondering if this were > > possible, and if so, how. I am using a (somewhat out of date) trunk > checkout > > of the djago code. If this is not possible in the current admin, is it > > possible using newforms-admin?? > > Yes, newsforms-admin will let you create an admin area for the > auth.User model using your own admin options (list filters, search, > etc.) It's worth switching to that branch and trying this out. > > http://code.djangoproject.com/wiki/NewformsAdminBranch > http://code.djangoproject.com/wiki/NewformsHOWTO > > -Rajesh D > > > > > -- Best, Rishabh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-registration with my custom user profile
Hi thanks for your replay, It is the second situation, I re-write the form.py like this class RegistrationForm(forms.Form): (other stuff ) def save(self, profile_callback=None): new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], password=self.cleaned_data['password1'], email=self.cleaned_data['email'], nickname = self.cleaned_data['nickname'], country = self.cleaned_data['country'], province = self.cleaned_data['province'], city = self.cleaned_data['city'], gender = self.cleaned_data['gender'], phone = self.cleaned_data['phone'], bio = self.cleaned_data['bio'], profile_callback=profile_callback) return new_user and then I changed the models.py in this way. def create_inactive_user(self, username, password, email,dob,nickname,country,province, city,gender,phone,bio,send_email=True, profile_callback=None): new_user = User.objects.create_user(username,last_name,first_name, email, password) new_user.is_active = False new_user.save() registration_profile = self.create_profile(new_user) userdetail = UserDetail(new_user,nickname,dob,country,province,city,gender,phone,bio) userdetail.save() if profile_callback is not None: profile_callback(user=new_user) but the browser throw the error like this TypeError at /veryuser/register/ create_inactive_user() takes at least 12 non-keyword arguments (4 given) thanks On Jun 13, 5:17 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > 2008/6/13 Chr1s <[EMAIL PROTECTED]>: > > > But still I don't know how to implement this, anyone could give me a > > simple example? thanks very much > > This feature is intended for a situation where each of the following is true: > > 1. You have a custom user-profile model. > 2. The user-profile model has been written in such a way that an > instance can be created using nothing but default values (e.g., with > no input whatsoever from the user). > > If that is the case, simply write a function which can create an > instance using nothing but default values, and pass that as the > argument. > > If that is not the case, you will either need to write a more complex > custom form (to handle any additional information you want to collect) > or create the profile in a separate step (e.g., using > django-profiles). > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django-registration with my custom user profile
Hi guys I am newbie for django, today I tried django-registration, in the source code it said that --- To enable creation of a custom user profile along with the ``User`` (e.g., the model specified in the ``AUTH_PROFILE_MODULE`` setting), define a function which knows how to create and save an instance of that model with appropriate default values, and pass it as the keyword argument ``profile_callback``. This function should accept one keyword argument: ``user`` The ``User`` to relate the profile to. I have a custom specific user profile like this class Userdetail(models.Model): user = models.ForeignKey(User, primary_key = True) # nickname = models.CharField(max_length=30) DOB = models.DateField() country = models.CharField(max_length=30, default = "CN") # province = models.CharField(max_length=30) # city = models.CharField(max_length=15) # gender = models.BooleanField() # phone = models.PhoneNumberField() # ip = models.IPAddressField() # bio = models.CharField(max_length=200) # def_club = models.ForeignKey(ClubMember) I don't know how to implement this, anyone could give me a simple example? thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Custom filters tied to form fields
Hello, Is there an easy way to add a filter function to specific fields defined in a newforms Form? I have some large forms with lots of textareas. I am using tinymce to add some basic formatting capabilities to the textareas, and I need to use a filter function to "sanitize" the value of the textarea in case the users just copy-paste some content there from a website / Word doc ( they always do that for some reason... ) Anyway, currently I see 2 solutions: 1. The longer way is to use the filter in the clean_ functions - tedious job... 2. Create a custom TextArea widget and implement the cleaning feature there I think I wills tick with option #2 but maybe I missed some undocumented attribute / function somewhere. Thanks, Roodie --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-registration with my custom user profile
2008/6/13 Chr1s <[EMAIL PROTECTED]>: > But still I don't know how to implement this, anyone could give me a > simple example? thanks very much This feature is intended for a situation where each of the following is true: 1. You have a custom user-profile model. 2. The user-profile model has been written in such a way that an instance can be created using nothing but default values (e.g., with no input whatsoever from the user). If that is the case, simply write a function which can create an instance using nothing but default values, and pass that as the argument. If that is not the case, you will either need to write a more complex custom form (to handle any additional information you want to collect) or create the profile in a separate step (e.g., using django-profiles). -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django-registration with my custom user profile
Hi guys, I tried django-registration 0.5 today, it is powerful indeed, but I have a site-specific user profile just like this writen in my model.py class Userdetail(models.Model): user = models.ForeignKey(User, primary_key = True) # nickname = models.CharField(max_length=30) DOB = models.DateField() country = models.CharField(max_length=30, default = "CN") # province = models.CharField(max_length=30) #省份 city = models.CharField(max_length=15) #城市 gender = models.BooleanField() # male true, female false phone = models.PhoneNumberField() # phone ip = models.IPAddressField() # last login IP bio = models.CharField(max_length=200) # bio for user def_club = models.ForeignKey(ClubMember) In the source code of django-registration, it said that #To enable creation of a custom user profile along with the # ``User`` (e.g., the model specified in the # ``AUTH_PROFILE_MODULE`` setting), define a function which # knows how to create and save an instance of that model with # appropriate default values, and pass it as the keyword # argument ``profile_callback``. This function should accept one #keyword argument: # ``user`` # The ``User`` to relate the profile to. But still I don't know how to implement this, anyone could give me a simple example? thanks very much --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Does django-driven Blog popular?
If you don't want to start from scratch take a look at this links from "this week in django" http://blog.michaeltrier.com/2008/5/14/this-week-in-django-22-2008-05-11 byteflow http://blog.michaeltrier.com/2007/12/30/django-blogging-apps http://blog.michaeltrier.com/2007/12/6/blogmaker-for-django yves On Jun 13, 5:21 am, kylin <[EMAIL PROTECTED]> wrote: > Hi guys > I am a newbie of django.Dose django-driven blog software pop? > Actually,I have not seen any blog software as good as wordpress ever. > Thus, why this fantastic framework have not driven a good enough blog > system? > > Kind regards --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Timezone conversion
Yea that's the one - so hopefully, once I assign it a timezone with .replace it will recognise it properly :) Excellent, I'll try it tonight. Thanks for all your help Horst :) On Jun 13, 9:27 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > Do you mean something like this? > > ValueError: astimezone() cannot be applied to a naive datetime > > This just means that the datetime instance you're working with, has no > timezone associated with it :-) > > -- Horst > > On Fri, Jun 13, 2008 at 10:22 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > > Right, so it doesn't automatically assign timezone information to it? > > I've seen some other examples where people have two/three fields just > > to store the timezone and date but I'd rather not have to go through > > all of that. > > > At work at the moment, but will try this when I get home :) > > > Any idea what is means by "naive datetime"? > > > On Jun 13, 9:16 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > >> From what I can see in the database, DateTime stores its content in > >> the timezone specified in the settings.py by default. So when you > >> fetch a datetime from the database you have to associated the > >> respective timezone with that datetime instance: > > >> tzedate = edate.replace(tzinfo=gettz(settings.TIMEZONE)) > >> tz = gettz('America/New_York') > >> edatetz = tzedate.astimezone(tz) > > >> Just a wild guess, though. > > >> -- Horst > > >> On Fri, Jun 13, 2008 at 10:07 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > >> > Hi Guys, > > >> > I want to convert a datetime field for an entry in my database to a > >> > specified timezone. Here is the code I have so far: > > >> > from dateutil.parser import * > >> > from dateutil.tz import * > >> > from datetime import * > > >> > event = get_object_or_404(Event, id__exact=eventid) > >> > edate = event.date > >> > tz = gettz('America/New_York') > >> > edatetz = edate.astimezone(tz) > > >> > Now, when I do this, I get something along the lines of "naive > >> > datetime" for the edate variable. However, if I change the edate > >> > variable to the following line of code, it works: > > >> > edate = datetime.now(tz=gettz('UTC')) > > >> > Any ideas why this is happening? Is it the way I am storing the > >> > datetime in my MySQL database? I'm using a standard datetime field - > >> > is it missing something? > > >> > Cheers, > >> > Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Timezone conversion
Do you mean something like this? ValueError: astimezone() cannot be applied to a naive datetime This just means that the datetime instance you're working with, has no timezone associated with it :-) -- Horst On Fri, Jun 13, 2008 at 10:22 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > Right, so it doesn't automatically assign timezone information to it? > I've seen some other examples where people have two/three fields just > to store the timezone and date but I'd rather not have to go through > all of that. > > At work at the moment, but will try this when I get home :) > > Any idea what is means by "naive datetime"? > > On Jun 13, 9:16 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: >> From what I can see in the database, DateTime stores its content in >> the timezone specified in the settings.py by default. So when you >> fetch a datetime from the database you have to associated the >> respective timezone with that datetime instance: >> >> tzedate = edate.replace(tzinfo=gettz(settings.TIMEZONE)) >> tz = gettz('America/New_York') >> edatetz = tzedate.astimezone(tz) >> >> Just a wild guess, though. >> >> -- Horst >> >> On Fri, Jun 13, 2008 at 10:07 AM, Darthmahon <[EMAIL PROTECTED]> wrote: >> > Hi Guys, >> >> > I want to convert a datetime field for an entry in my database to a >> > specified timezone. Here is the code I have so far: >> >> > from dateutil.parser import * >> > from dateutil.tz import * >> > from datetime import * >> >> > event = get_object_or_404(Event, id__exact=eventid) >> > edate = event.date >> > tz = gettz('America/New_York') >> > edatetz = edate.astimezone(tz) >> >> > Now, when I do this, I get something along the lines of "naive >> > datetime" for the edate variable. However, if I change the edate >> > variable to the following line of code, it works: >> >> > edate = datetime.now(tz=gettz('UTC')) >> >> > Any ideas why this is happening? Is it the way I am storing the >> > datetime in my MySQL database? I'm using a standard datetime field - >> > is it missing something? >> >> > Cheers, >> > Chris > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Timezone conversion
Right, so it doesn't automatically assign timezone information to it? I've seen some other examples where people have two/three fields just to store the timezone and date but I'd rather not have to go through all of that. At work at the moment, but will try this when I get home :) Any idea what is means by "naive datetime"? On Jun 13, 9:16 am, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > From what I can see in the database, DateTime stores its content in > the timezone specified in the settings.py by default. So when you > fetch a datetime from the database you have to associated the > respective timezone with that datetime instance: > > tzedate = edate.replace(tzinfo=gettz(settings.TIMEZONE)) > tz = gettz('America/New_York') > edatetz = tzedate.astimezone(tz) > > Just a wild guess, though. > > -- Horst > > On Fri, Jun 13, 2008 at 10:07 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > > Hi Guys, > > > I want to convert a datetime field for an entry in my database to a > > specified timezone. Here is the code I have so far: > > > from dateutil.parser import * > > from dateutil.tz import * > > from datetime import * > > > event = get_object_or_404(Event, id__exact=eventid) > > edate = event.date > > tz = gettz('America/New_York') > > edatetz = edate.astimezone(tz) > > > Now, when I do this, I get something along the lines of "naive > > datetime" for the edate variable. However, if I change the edate > > variable to the following line of code, it works: > > > edate = datetime.now(tz=gettz('UTC')) > > > Any ideas why this is happening? Is it the way I am storing the > > datetime in my MySQL database? I'm using a standard datetime field - > > is it missing something? > > > Cheers, > > Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Timezone conversion
>From what I can see in the database, DateTime stores its content in the timezone specified in the settings.py by default. So when you fetch a datetime from the database you have to associated the respective timezone with that datetime instance: tzedate = edate.replace(tzinfo=gettz(settings.TIMEZONE)) tz = gettz('America/New_York') edatetz = tzedate.astimezone(tz) Just a wild guess, though. -- Horst On Fri, Jun 13, 2008 at 10:07 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > Hi Guys, > > I want to convert a datetime field for an entry in my database to a > specified timezone. Here is the code I have so far: > > from dateutil.parser import * > from dateutil.tz import * > from datetime import * > > event = get_object_or_404(Event, id__exact=eventid) > edate = event.date > tz = gettz('America/New_York') > edatetz = edate.astimezone(tz) > > Now, when I do this, I get something along the lines of "naive > datetime" for the edate variable. However, if I change the edate > variable to the following line of code, it works: > > edate = datetime.now(tz=gettz('UTC')) > > Any ideas why this is happening? Is it the way I am storing the > datetime in my MySQL database? I'm using a standard datetime field - > is it missing something? > > Cheers, > Chris > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Timezone conversion
Hi Guys, I want to convert a datetime field for an entry in my database to a specified timezone. Here is the code I have so far: from dateutil.parser import * from dateutil.tz import * from datetime import * event = get_object_or_404(Event, id__exact=eventid) edate = event.date tz = gettz('America/New_York') edatetz = edate.astimezone(tz) Now, when I do this, I get something along the lines of "naive datetime" for the edate variable. However, if I change the edate variable to the following line of code, it works: edate = datetime.now(tz=gettz('UTC')) Any ideas why this is happening? Is it the way I am storing the datetime in my MySQL database? I'm using a standard datetime field - is it missing something? Cheers, Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: DB Models best practice
On Jun 12, 11:44 pm, "Bartek Gniado" <[EMAIL PROTECTED]> wrote: > Instead of over complicating it like this. Why not just use memcached or > django's own cache? He's referring to: http://www.djangoproject.com/documentation/cache/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Tutorial Clarification
On Fri, Jun 13, 2008 at 2:24 AM, wave connexion(BQ) <[EMAIL PROTECTED]> wrote: > Does this mean Django generated API code for you? No. The phrase "no code generation necessary" means precisely what it says: that, unlike some frameworks which require you to run a script which generates files of code for you, Django's database API is generated dynamically at runtime. > Here, that an app can be in multiple projects means the app code can be > copied/imported into different projects rather than shared between different > projects? In the largest sense, it means that an application is simply a Python module, and thus the standard Python "import" statement can be used to access it the same as any other Python code; this means that a single application module can be re-used by multiple Django projects without needing to make multiple copies of the application module (just as any other Python library can be imported by multiple pieces of code without needing its files to be copied into new locations by each of them). > not very clear on this. more explanation is appreciated. An explanation of that code is provided in the section immediately following it. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Tutorial Clarification
On 13-Jun-08, at 12:54 PM, wave connexion(BQ) wrote: > 1. in reading overview, "you've got a free, and rich, Python API to > access your data. The API is created on the fly, no code generation > necessary?" > > Does this mean Django generated API code for you? django does not generate a single line of code - unlike some other frameworks which need to generate all sorts of files with all sorts of rules about filenames and position of the file. > > > 2. in tutorial part 1, "What's the difference between a project and > an app? An app is a Web application that does something — e.g., a > weblog system, a database of public records or a simple poll app. A > project is a collection of configuration and apps for a particular > Web site. A project can contain multiple apps. An app can be in > multiple projects." > > Here, that an app can be in multiple projects means the app code > can be copied/imported into different projects rather than shared > between different projects? app code can be imported into different projects. apps need not be under the project directory, they can be anywhere in the file system as long as django can find them (installed apps). > > > 3. in tutorial part 4 - > "Use generic views: Less code is better... > url(r'^(?P\d+)/results/$', > 'django.views.generic.list_detail.object_detail', dict(info_dict, > template_name='polls/results.html'), 'poll_results'), " > > not very clear on this. more explanation is appreciated. I have never used generic views, so share your confusion -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/code/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django Tutorial Clarification
I am new to Django, can someone make following clarification on Django tutorial: 1. in reading overview, "you've got a free, and rich, Python API to access your data. The API is created on the fly, no code generation necessary?" Does this mean Django generated API code for you? 2. in tutorial part 1, "What's the difference between a project and an app? An app is a Web application that does something — e.g., a weblog system, a database of public records or a simple poll app. A project is a collection of configuration and apps for a particular Web site. A project can contain multiple apps. An app can be in multiple projects." Here, that an app can be in multiple projects means the app code can be copied/imported into different projects rather than shared between different projects? 3. in tutorial part 4 - "Use generic views: Less code is better... url(r'^(?P\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results.html'), 'poll_results'), " not very clear on this. more explanation is appreciated. Thanks, -- BQ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: more info when serializing
Hi, With a bit of prompting from another Djangoista I've posted the python and json "full" serializer implementations to http://code.djangoproject.com/ticket/4656 . Please have a try and let me know if you find and bugs or have any other feedback. cheers Matthew On Dec 14 2007, 5:02 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 18 Nov, 11:25, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > > > > On Sat, 2007-11-17 at 16:21 -0500, Bryan L. Fordham wrote: > > > So, say I have a model something like this: > > > > class Bar(models.Model): > > > user = models.ForeignKey(User) > > > name = models.CharField(maxlength=50) > > > description = models.TextField() > > > > where user is tied to a django.contrib.auth.models.User entity. When I > > > serialize this to json, I get: > > > [{"pk": "1", "model": "foo.bar", "fields": {"description": "", "user": > > > 1, "name": "Phone"}}] > > > > Which is fine, but I need both the username and user id on the front > > > end. Is there a simple way to get this info all in one shot that I'm > > > just missing? > > > > Ideally, it would return something like: ..."user": > > > {"username":"bfordham", "pk":1}... > > Hi, > > I've come up with a solution to this that is very similar to the way > Rails does it [1]. I'm also CC-ing to django-developers as it covers > ticket #4656 and feel it is wandering more into the developer realm > where a design decision is needed. > > I've written a new python & json serializer for Django. An example > invocation and output for the Bar model above would look like: > > >>> from django.core import serializers > >>> serializers.serialize('json', Bar.objects.all(), > >>> relations={'user':{'fields':('username',)}}) > > [{ > "pk": "1", > "model": "foo.bar", > "fields": { > "description": "", > "user": {"pk":"1", "model":"auth.user", "fields": > {"username":"bfordham"}}, > "name": "Phone" > } > > }] > > The new serializer takes the following keyword arguments: > > fields - list of fields to be serialized only. > excludes - list of fields to be excluded. > relations - list of related fields to be serialized or a > dictionary with the keys being the fields to serialize and the values > being a dictionary of arguments to pass to sub-serializer. ie. fields, > excludes, relations, methods. > methods - list of methods to include. Methods cannot take > arguments. Not yet implemented. > attributes - list of other class attributes to serialize that > aren't model fields. Not yet implemented. > > At the moment with no arguments it only serializes regular model > fields that aren't ForeignKeys or ManyToManys. You have to explicitly > include related fields using the 'relations' argument. I could make > this backwards-compatible with the way the serializers work now if > needed. > > > > > The serializer doesn't support this. It would take a bit of design work > > to figure out how to specify such an extension easily. You might like > > put some thought into that, though. > > > Things that immediately spring to mind as requiring addressing: > > - what should the format look like for many-to-many objects (and > > making sure we can deserialise as well) > > Here is how I do it with User model as an example: > > >>> serializers.serialize('python', User.objects.filter(username='jdoe'), > >>> relations=('groups',)) > > [{ > 'fields': {'date_joined': datetime.datetime(2006, 8, 14, 10, 34, > 56), > 'email': u'[EMAIL PROTECTED]', > 'first_name': u'', > 'groups': [{'fields': {'name': u'group1'}, > 'model': u'auth.group', > 'pk': 2}, > {'fields': {'name': u'group2'}, > 'model': u'auth.group', > 'pk': 1}], > 'is_active': True, > 'is_staff': True, > 'is_superuser': False, > 'last_login': datetime.datetime(2007, 9, 19, 12, 29, 2, > 649167), > 'last_name': u'', > 'password': u'sha1$x', > 'username': u'jdoe'}, > 'model': u'auth.user', > 'pk': 2}] > > > - once you add one level of indirection, it will take > > approximately 8 seconds for somebody to want to go two levels > > and more. So it should be extensible beyond just "the immediate > > foreign key relative". > > My serialiser allows for as many levels of indirection as you want as > well as specifying which fields you want included, excluded etc at > each level. > > > - reverse relations > > Not yet implemented. > > > - deserialisation, if possible. > > Not yet implemented. > > > - is it easy to say "all the normal fields plus these extra > > ones". > > The attributes and methods arguments are for this, though I haven't > implemented that part either and I'm thinking of merging