Re: Check if user is in a list

2009-01-18 Thread Darthmahon
Hey DR, that works perfectly! Cheers, Chris On Jan 18, 1:44 pm, Daniel Roseman wrote: > On Jan 18, 12:43 pm, Darthmahon wrote: > > > > > Hey Guys, > > > I've got a model like this: > > > event   = models.ForeignKey(Event) > > user        

Check if user is in a list

2009-01-18 Thread Darthmahon
Hey Guys, I've got a model like this: event = models.ForeignKey(Event) user= models.ForeignKey(UserProfile) user_2 = models.ForeignKey(UserProfile, related_name='user_2') I then get a list of all the invites: people_invited = EventInvitation.objects.filter (event=event).select_r

Re: auth: get_profile(): create if it does not exist.

2008-12-17 Thread Darthmahon
Why not create your own function then and just put the try or except code in that? That way it'll only be one line. On Dec 17, 3:19 pm, nbv4 wrote: > On Dec 17, 5:00 am, Thomas Guettler wrote: > > > > > Hi, > > > The method user.get_profile() fails, if the user has no profile. During > > my cus

Re: auth: get_profile(): create if it does not exist.

2008-12-17 Thread Darthmahon
Can you not do this: if request.user.is_authenticated(): # Get profile user.get_profile() else: # Create profile On Dec 17, 10:00 am, Thomas Guettler wrote: > Hi, > > The method user.get_profile() fails, if the user has no profile. During > my custom login I > check if the user has

Re: Count is different when using custom SQL?

2008-12-11 Thread Darthmahon
Hi Malcolm, Weird. I managed to fix this problem by using the distinct filter which I didn't know existed but does what I actually wanted anyway :) // get results friends_albums = Albums.objects.filter(users__in=friend_list, date__gte=today).distinct().select_related() /

Re: custom variables in settings.py

2008-12-10 Thread Darthmahon
Actually just realised you want to do this in the template file. How about this: http://www.djangosnippets.org/snippets/67/ On Dec 10, 10:50 am, Darthmahon <[EMAIL PROTECTED]> wrote: > First thing you need to do is import your settings file at the top of > your .py fil

Re: custom variables in settings.py

2008-12-10 Thread Darthmahon
First thing you need to do is import your settings file at the top of your .py file import mysite.settings Then just reference it like so: {{ settings.MAP_MEDIA }} Cheers, Chris On Dec 10, 10:28 am, Leppy <[EMAIL PROTECTED]> wrote: > Hi everyone, > I am facing some issues in creating custom v

Count is different when using custom SQL?

2008-12-10 Thread Darthmahon
Hi Guys, Ok got a bit of a tricky one here for some reason. Basically I am doing a query which returns a list of albums your friends own. The problem is that I need to group the results by the album id so that I only get a unique list of albums. Now what I've noticed is that the number of resul

Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon
I'll give it a go :) Thanks for your help Ben. On Dec 9, 9:50 am, Ben Eliott <[EMAIL PROTECTED]> wrote: > hmm, don't know. that's the documented approach. you might want to   > investigate intermediary tables/models etc. > > On 9 Dec 2008, at 09:24, Darthmahon

Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon
Ahh yes possibly. Any downsides to using this? On Dec 9, 9:19 am, Ben Eliott <[EMAIL PROTECTED]> wrote: > Do you want something like this? > friends_new = models.ManyToManyField("self",symmetrical=False) > > On 9 Dec 2008, at 09:06, Darthmahon wrote: > > > &g

Re: Many to Many entries being duplicated, any ideas?

2008-12-09 Thread Darthmahon
Hi Guys, Just bumping this up as I still can't figure out why this is happening :/ On Dec 8, 9:27 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > Hi Guys, > > I've got a model that has a Many to Many relationship on one of the > fields. This relationship is basicall

Many to Many entries being duplicated, any ideas?

2008-12-08 Thread Darthmahon
Hi Guys, I've got a model that has a Many to Many relationship on one of the fields. This relationship is basically on itself though like this: # class UserProfile(models.Model): user= models.ForeignKey(User, unique=True) friends_new

Re: Is it possible to output JSON like this?

2008-11-06 Thread Darthmahon
Events' : > >    ...:     [ { 'title' : 'Event 1', 'location' : '1', 'id' : '1' }, { > > 'title' : > >    ...:         'Event 2', 'location' : '1', 'id' : '2

Re: Is it possible to output JSON like this?

2008-11-06 Thread Darthmahon
: > With simplejson module (that is part of django distribution) you can covert > to JSON any python objects. So create data structure you need and pass it to > simplejson dump/dumps functions. > > On Thu, Nov 6, 2008 at 01:17, Darthmahon <[EMAIL PROTECTED]> wrote: > > &g

Is it possible to output JSON like this?

2008-11-05 Thread Darthmahon
Hi, Ok I'm using the following code to turn my model into JSON: from django.core import serializers json = serializers.serialize("json", Event.objects.all()[:5], fields=('title','date','location')) Now, this returns JSON like this: [ { "pk": 1, "model": "events.event", "fields": {

RSS feed only returning one result, but table has 10 results.

2008-10-25 Thread Darthmahon
Hey Guys, Got a very strange thing going on with the RSS feed framework in Django. Here is the code for one feed: * class LatestNotes(Feed): title = "Title" link = "Link" description = "Description" def items(self): return Note.objects.or

Re: Checking image isn't too big on upload

2008-07-25 Thread Darthmahon
Hi Marty, So currently there is no way of getting the dimensions for an image? On Jul 25, 6:09 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Fri, Jul 25, 2008 at 12:31 PM, Darthmahon <[EMAIL PROTECTED]> wrote: > > I've just upgraded my Django to th

Checking image isn't too big on upload

2008-07-25 Thread Darthmahon
Hey, I've just upgraded my Django to the trunk and noticed some code I need to change. I've got a form that uploads images, looks like Django throws up an error if the file is not an image, which is nice but I also need to check if the image is too big/small. Here is the code: class SettingsImag

ForeignKey ordering on Models

2008-07-14 Thread Darthmahon
Hey, I want to have a field on one model link to another model as a ForeignKey. Problem is, this field needs to be declared before the second model has been defined. Example below - latest refers to Album, but Album is below Musician so it won't let me do this? Is there a way of getting around t

Re: Many to many array accessible from template?

2008-07-13 Thread Darthmahon
l 13, 1:16 pm, "Alex Koshelev" <[EMAIL PROTECTED]> wrote: > But in this case `message` must be a `UserProfile` instance if it has > `users` attribute > > On Sun, Jul 13, 2008 at 4:09 PM, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Alex, > > > I

Re: Many to many array accessible from template?

2008-07-13 Thread Darthmahon
I`UserMessage` model has `users_read` field why do you write in > template `message.users`? > > On Jul 13, 2:56 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Hey, > > > I'm writing a messaging module at the moment. I'm printing out the > > list of messa

Many to many array accessible from template?

2008-07-13 Thread Darthmahon
Hey, I'm writing a messaging module at the moment. I'm printing out the list of messages fine, but when I loop through each message I want to check if the current user is in an array. This array has all of the people who have read the message so far. Model looks like this: sender

Re: Having problems with regroup on datetime

2008-06-22 Thread Darthmahon
Not sure what happened, but I fixed this by doing this: {% regroup event_list by date.date as events %} {% for event in grouped %} {{ event.grouper|date:"l jS F" }} {% for event in events.list %} {{ event.title }} {% endfor %} {% endfor %} On Jun 22, 1:01 pm, Darthmahon <[EM

Having problems with regroup on datetime

2008-06-22 Thread Darthmahon
Hi, I am trying to group a list of events using the regroup template tag as such: {% regroup event_list by date as events %} {% for event in events %} {{ event.grouper.day }} {% for event in events.list %} {{ event.title }} {% endfor %} {% endfor %} Now, in my model for Events, I am using a da

How to check if something in one array is in another

2008-06-15 Thread Darthmahon
Hi Guys, I'm trying to do a hash lookup with two arrays. Basically, I have a friends list and another list that has user id's. I want to check if any of the user id's I have are also in the friends list. The two arrays are just normal dictionaries that look something like this: friends = [id=1,

Re: Timezone conversion

2008-06-13 Thread Darthmahon
istaken 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 > >

Re: Timezone conversion

2008-06-13 Thread Darthmahon
one. 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 :)

Re: Timezone conversion

2008-06-13 Thread Darthmahon
ing 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

Re: Timezone conversion

2008-06-13 Thread Darthmahon
etime 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. > &

Timezone conversion

2008-06-13 Thread Darthmahon
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('Amer

Re: Can't convert UTC time :(

2008-06-12 Thread Darthmahon
like this: 2008-06-12 20:57:04 It's missing all of the extra stuff the first date prints out. I'm guessing this is why the time is not converting, because there is no tzinfo data? Any ideas? On Jun 11, 5:50 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > Tried out both pytz an

Re: Can't convert UTC time :(

2008-06-11 Thread Darthmahon
u, no idea. This is the first time I've heard of pytz, to be honest > :-) But I'd assume that whenever you create a new datetime object with > a given timezone, it should consider the DST setting. Haven't tried it > though on any library. > > -- Horst > > On Wed,

Re: Can't convert UTC time :(

2008-06-11 Thread Darthmahon
ssociated with it. If you know what timezone it's supposed > to have (yet is lacking the timezone attribute itself), you can easily > attach a timezone like this: > > mydatetime.replace(tzinfo=gettz('CEST')) # associated mydatetime with > the CEST timezone > > I ho

Re: Can't convert UTC time :(

2008-06-11 Thread Darthmahon
n seconds between 2 timezones? Then > perhaps the tzinfo class itself might be of some help here. It has a > utcoffset(self, datetime) method that returns a datetime.timedelta > instance:http://docs.python.org/lib/datetime-tzinfo.html > > - Horst > > On Tue, Jun 10, 2008 at 10:1

Can't convert UTC time :(

2008-06-10 Thread Darthmahon
Hi Guys, I want to convert a UTC timestamp so I can use it to figure out what offset a certain user has based on their selected timezone. I'm using the Python pytz module by the way. Here is the code so far: == # get users time timezone = timezone('America/New_York') # get UTC time no

Re: Queryset returning unexpected results

2008-03-05 Thread Darthmahon
Ahh ok. Something like this then? qset = (Q(tags__title__icontains=query) | Q(title__icontains=query)) results = Blog.objects.filter(qset).extra(LEFT OUTER JOIN tag ON blog.tag = tag.id) On Mar 5, 10:49 pm, Pigletto <[EMAIL PROTECTED]> wrote: > > Basically, the queryset in views.py will ONLY ret

Re: Queryset returning unexpected results

2008-03-05 Thread Darthmahon
Ahh ok, can I simply specify just the 'left outer join' part of the query or do I need need to write it myself I.E. SELECT from TABLE where XXX LEFT OUTER JOIN... On Mar 5, 10:49 pm, Pigletto <[EMAIL PROTECTED]> wrote: > > Basically, the queryset in views.py will ONLY return results if that > > p

Queryset returning unexpected results

2008-03-05 Thread Darthmahon
Hey, Ok I have a queryset that basically searches a model for both the title, and the title of related tags. File: views.py query = request.POST.get('blog', '') if query: qset = ( Q(tags__title__icontains=query) |

Re: Need some help with a query if you can :)

2008-02-24 Thread Darthmahon
Hi Guys, Just wondered if anyone else could help out on this one? To me it doesn't seem like it's a difficult thing to do, I just can't get it to work :( Cheers, Chris On Feb 23, 11:48 am, Darthmahon <[EMAIL PROTECTED]> wrote: > Hmmm ok, can't get this to print a

Re: Need some help with a query if you can :)

2008-02-23 Thread Darthmahon
threads.html', { "friends" : > friends}, context_instance=RequestContext(request)) > > Your template should then be: > {% for friend in friends %} >     {{ friend }} >     {{ friend.thread_set|join:", " }} > {% endfor %} > > All that is if you want

Re: Need some help with a query if you can :)

2008-02-22 Thread Darthmahon
render_to_response('people/threads.html', { "thread_list" : threads }, context_instance=RequestContext(request)) - - Template: - {% for thread in thread_list %} {{ thread.title }} {{ thread.friends|join:", " }} {% endfor %} - On Feb 22, 10:44 pm, Darthmahon &

Re: Need some help with a query if you can :)

2008-02-22 Thread Darthmahon
t; friends = profile.friends.all() > > # get threads for friends > threads = [] > for friend in friends: > thread.append([friend, friend.threads.all()]) > > > On Feb 23, 8:34 am, Darthmahon <[EMAIL PROTECTED]> wrote: > > Hey, > > > > I have three mo

Need some help with a query if you can :)

2008-02-22 Thread Darthmahon
Hey, I have three models but I can only handle the relationship between two at any one time. Basically I have a page that needs to show a threads the current user's friends are currently participating in. I.E. something like this: Thread: ABC Participating: Friend 1 Thread: XYZ Participating:

Re: Deploying Django - can't get past the welcome screen

2008-02-18 Thread Darthmahon
alled "thumbslap": > > >If you plan to use a database, edit the DATABASE_* settings in > >thumbslap/settings.py. > >Start your first app by running python thumbslap/manage.py startapp > >[appname]. > > But your settings file is ROOT_URL_CONF set to "mysite.u

Re: Deploying Django - can't get past the welcome screen

2008-02-17 Thread Darthmahon
== File: urls.py == from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), (r'^$', 'mysite.views.index'), (r'^settings/', 'mysite.people.v

Re: Deploying Django - can't get past the welcome screen

2008-02-17 Thread Darthmahon
== File: urls.py == from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), (r'^$', 'thumbslap.views.index'), (r'^settings/', 'thumbslap.

Re: Deploying Django - can't get past the welcome screen

2008-02-16 Thread Darthmahon
Yea I've restarted it and "touched" the fcgi file so it's rather odd - do you know of any good tutorials that are not written by the Django team (read them, not too helpful and assume too much)? On Feb 16, 9:05 pm, Bret W <[EMAIL PROTECTED]> wrote: > Have you restarted the Web server?  Perhaps ca

Re: Deploying Django - can't get past the welcome screen

2008-02-16 Thread Darthmahon
Hi Bret, Yea I've done both of those things, ran syncdb as well. It's very odd. For example I have a /static/ folder that just has all of my css files, but even when I try to access that folder it shows the Django Welcome screen. I wouldn't expect that to happen... On Feb 16, 7:57 pm, Bret W <[

Deploying Django - can't get past the welcome screen

2008-02-16 Thread Darthmahon
Hi Guys, In the final steps of my app and looking to deploy (yay!). I'm using a dedicated server which has Apache 2 and is using FastCGI with Lighttpd. Django installed, the models are in, the mysql database is working but I can't get past this welcome screen: --

Re: 'unicode' object has no attribute 'strftime'

2008-02-16 Thread Darthmahon
e probably is a cleaner way of doing it, but it seems to work :) On Feb 16, 10:49 am, Darthmahon <[EMAIL PROTECTED]> wrote: > Hi Alex, > > Tried this and it gave me the following error: > > TypeError at /register/ > an integer is required > > Any ideas? > > On Fe

Re: 'unicode' object has no attribute 'strftime'

2008-02-16 Thread Darthmahon
om datetime import date > _dob = date( year = form.clean_data['dob_year'], >                    month = form.clean_data['dob_month'], >                    day = form.clean_data['dob_day'] >                       ) > > On 14 фев, 01:48,Darthmahon<[

Re: 'unicode' object has no attribute 'strftime'

2008-02-13 Thread Darthmahon
that. By the way, I am using Django 0.96 and MySQL. On Feb 13, 10:38 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > If birthday UserProfile field in DataField you must set date object to > it. Not string. > > On 14 фев, 00:50, Darthmahon <[EMAIL PROTECTED]> wrote: &g

'unicode' object has no attribute 'strftime'

2008-02-13 Thread Darthmahon
Hmm I seem to have hit another problem just after another! I've got a form that lets user's select the birthday via three dropdowns (day, month and year). This is all using newforms. Basically, within my views.py file I have a function that creates new users - one part of this process is to make

Re: Using newforms and a select - how do I stop a user from selecting a value?

2008-02-13 Thread Darthmahon
'Month': > > MONTH_CHOICES=( >                 (None,'Month',), >                 (1,'January'), >                 > > On Feb 14, 7:24 am, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Hey, > > > I'm usi

Using newforms and a select - how do I stop a user from selecting a value?

2008-02-13 Thread Darthmahon
Hey, I'm using the newforms functionality to create my forms - so the structure is something like this: / FORMS.PY / class RegisterForm(forms.Form): MONTH_CHOICES=( (0,'Month',), (1,'January'), (2,'February

Re: Simple filter query throwing up an error

2008-02-10 Thread Darthmahon
Thanks for all your help guys - python docs make sense :) On Feb 10, 12:17 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Feb 10, 2008 5:59 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Event.objects.filter(date__exact=datetime.now()) > > >

Simple filter query throwing up an error

2008-02-10 Thread Darthmahon
Hey, I want to get a list of events that are happening today and I'm using this query: Event.objects.filter(date__exact=datetime.now()) Simple enough, but it throws up this error: AttributeError at /events/today/ 'module' object has no attribute 'now' My model looks like this: title

Re: Strange Many-to-Many relationship question

2008-01-19 Thread Darthmahon
d.get_profile.avatar}} > Of course if you set proper AUTH_PROFILE_MODULE setting. > > On 19 янв, 22:24, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I'm using the built in authentication of Django, so new users who > > register go through the U

Strange Many-to-Many relationship question

2008-01-19 Thread Darthmahon
Hi, I'm using the built in authentication of Django, so new users who register go through the User model. I also have a custom UserProfile model that links directly to the User model via a ForeignKey. This is my completed UserProfile model: # File: people/models.py

ImageField Example

2008-01-19 Thread Darthmahon
Hey, Does anyone have a working example of uploading images using Django? I've looked extensively and haven't found anything - any idea how I save images using Django? I've put an ImageField in my model with the path to where it should save, but how do I tell Django to save it when a form is subm

Re: How to see if current item is in a list

2008-01-12 Thread Darthmahon
Doh! Yup I forgot that...cheers! :) On Jan 12, 4:17 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Jan 12, 2008 10:59 AM, Darthmahon <[EMAIL PROTECTED]> wrote: > > > > > > > Hey, > > > I want to check if the current item I am pri

How to see if current item is in a list

2008-01-12 Thread Darthmahon
Hey, I want to check if the current item I am printing in one list is also available in another list. Basically I have a list of books and I want to check if the user already has a particular book in their profile so that instead of it saying "Add Book", it says "Remove Book". At the moment I am

Re: Inserting a date into DateField

2008-01-12 Thread Darthmahon
to change your code to, > _dob = form_name.cleaned_data['date_attribute_name'] > form.cleaned_data, gets you the canonical representation for the data > type depending on the field type declared in the Form class. > (All this assuming you are using newforms) > > On Jan 1

Inserting a date into DateField

2008-01-12 Thread Darthmahon
Hi, I'm trying to insert a simple date (2002-01-12) from a form I have created into a DateField but I keep getting this error: 'str' object has no attribute 'strftime' This is how the DateField is setup in my models.py file: birthday = models.DateField(blank=True) This is how I am trying to w

Re: When to use templatetags and how to use views.py

2008-01-11 Thread Darthmahon
Hi Malcolm, Thanks for the great writeup, it has certainly made things clearer. Like you say, don't sweat the small stuff - I'll try not to :) Thanks, Chris On Jan 11, 8:53 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-01-10 at 23:18 -0800, Darthmahon wr

Re: When to use templatetags and how to use views.py

2008-01-10 Thread Darthmahon
Jan 11, 2:03 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On 10-Jan-08, at 8:54 PM, Darthmahon wrote: > > > Is there any real difference between passing the data from a views.py > > file into a template compared with asking for the data using a > > templatetag?

When to use templatetags and how to use views.py

2008-01-10 Thread Darthmahon
Hey, I've recently stumbled on templatetags as a great way of pulling in data you need within a specific template file. Previously I would have done all of the logic to pull in data from within a views.py file and then just pass that data into a specified template. Is there any real difference b

Re: How is this page being loaded?

2008-01-09 Thread Darthmahon
es so wondered if anyone had any thoughts... Cheers, Chris On Jan 9, 7:17 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Darthmahon wrote: > > I've been looking through the source code for djangoproject.com which > > is really useful and has helped me a lot, but I have a

How is this page being loaded?

2008-01-09 Thread Darthmahon
I've been looking through the source code for djangoproject.com which is really useful and has helped me a lot, but I have a question regarding the code. Does anyone know how the url www.djangoproject.com/community know which template it needs to load? I've been looking to see how they have stru

Re: Many to Many

2008-01-08 Thread Darthmahon
Hi Alex, I am using 0.96 - __str__ did the trick :) Thanks so much for your help! On Jan 8, 11:01 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > What version of django do you use? May be you need __str__ method for > models > > On 9 янв, 01:52, Darthmahon <[EMAIL PROTEC

Re: Many to Many

2008-01-08 Thread Darthmahon
Hi Alex, Thanks - no error now, but it prints this: Platform object How can I get it to print the title for this platform? On Jan 8, 10:01 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > My mistake, colon needed after "join" > > {{game.platforms.all|join:", "

Re: Many to Many

2008-01-08 Thread Darthmahon
rms, so > >  def games(request): >         games = Game.objects.all() >         return render_to_response('games/games.html', > { 'games':games }, context_instance=RequestContext(request)) > > {% for game in games %} > Title: {{ game.title }} > Platform: {

Many to Many

2008-01-08 Thread Darthmahon
Hey, Can't get my head around this. Basically I have a model that includes a manytomany field like this: ## File: /games/models.py ## class Platform(models.Model): title = models.CharField(maxlength=30) def __unicode__(self):

Re: Passing data when using render_to_response

2008-01-08 Thread Darthmahon
Thanks Maarten, so can I still then iterate through the songs in my template file? On Jan 8, 10:00 am, Maarten <[EMAIL PROTECTED]> wrote: > Hello > > """ > def songs(request): > songs_listing = [] > for songs_list in Song.objects.all(): > songs_dict = {} >

Re: Query How To

2008-01-08 Thread Darthmahon
Ahh ok I saw that and thought it might be useful. Can I have more than one ManyToMany field in my custom user profile model? I.E. if a user has a list of songs and groups, for example? Just reading about ManyToMany - it seems to create an intermediary join table - is this exactly what I am trying

Re: Query How To

2008-01-08 Thread Darthmahon
r( user=U ) > > Then you can iterate over it or pass that list to a template that > iterates over it > > >>> for song in list: > >>>doSomething > > Look here for morehttp://www.djangoproject.com/documentation/db-api/ > > On Jan 7, 3:01 pm, Darthmah

Query How To

2008-01-07 Thread Darthmahon
Hey, My ongoing quest to get a basic app working will hopefully be answered by this question :) I have the following model.py file: File: model.py == from django.db import models from django.contrib.auth.models import User class Song(models.Model): titl

Re: Passing data when using render_to_response

2008-01-07 Thread Darthmahon
Hi Doug, Returning the songs function results worked a treat. I'm looking into the generic views part of Django at the moment as it seems to be what I want or is it ok for me to do as you suggested above? Cheers, Chris On Jan 7, 8:48 pm, Doug B <[EMAIL PROTECTED]> wrote: > Couldn't you get what

Passing data when using render_to_response

2008-01-07 Thread Darthmahon
Hi All, Got a quick question for you. I have a page that lists songs. Each song has a link that allows a user to add it to their songs list. Here is the views.py file: def songs(request): songs_listing = [] for songs_list in Song.objects.all(): songs_dict = {}

Re: Should logic appear in views.py

2008-01-07 Thread Darthmahon
e handling and most of > business logic have to be in views.py or similar but not in models.py. > > On 7 янв, 12:38, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Hey, > > > I've just started working on my project but before getting too far > > down the line I

Should logic appear in views.py

2008-01-07 Thread Darthmahon
Hey, I've just started working on my project but before getting too far down the line I wanted to ask the opinion of people on here. I've seen some code examples that show functions within the models.py file like so: from django.db import models class SaveArticle(model

Re: Getting current user id

2008-01-06 Thread Darthmahon
of django.contrib.auth.models.User, which maps to the django users > table. request.user would be such an instance :) > > On Jan 6, 10:08 pm, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Thanks, should have guessed that! > > > For some reason though it is returning

Re: Getting current user id

2008-01-06 Thread Darthmahon
pping the L off the end? On Jan 6, 9:00 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote: > User id - request.user.id > > On 6 янв, 23:43, Darthmahon <[EMAIL PROTECTED]> wrote: > > > Hi Guys, > > > Been looking to get the current id of the user logged i

Getting current user id

2008-01-06 Thread Darthmahon
Hi Guys, Been looking to get the current id of the user logged in everywhere but can't seem to find how to do this. Basically in my views.py file I want to insert an entry into a table. Part of this insert requires the current logged in users id. The only bit of information I seem to be able to