Stuck re:Practical Django Projects 2nd E...
Bit stumped on chapter 4. Every thing is working except I'm getting a 'Page not found (404)' when I try to view any entries. View: def entry_detail(request, year, month, day, slug): import datetime, time date_stamp = time.strptime(year+month+day, "%Y%b%d") pub_date = datetime.date(*date_stamp[:3]) return render_to_response('coltrane/entry_detail.html', { 'entry': Entry.objects.get (pub_date__year=pub_date.year, pub_date__month=pub_date.month, pub_date__day=pub_date.day, slug=slug) }) Url: (r'^weblog/(?P\d{4})/(?P\w{3})/(?P\d{2})/(P?[- \w]+)/$', 'coltrane.views.entry_detail'), Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
urls.py error: unbalanced parenthesis
Getting a unblanced parenthesis error with this urls setup. Not sure why. urls.py: from django.conf.urls.defaults import * from coltrane.models import Entry entry_info_dict = { 'queryset': Entry.objects.all(), 'date_field': 'pub_date', } urlpatterns = patterns('django.views.generic.date_based', (r'^$', 'archive_index', entry_info_dict, 'coltrane_entry_archive_index'), (r'^(?P\d{4}/$', 'archive_year', entry_info_dict, 'coltrane_entry_archive_year'), (r'^(?P\d{4}/(?P\w{3})/$', 'archive_month', entry_info_dict, 'coltrane_entry_archive_month'), (r'^(?P\d{4}/(?P\w{3})/(?P\d{2}/)$', 'archive_day', entry_info_dict, 'coltrane_entry_archive_day'), (r'^(?P\d{4}/(?P\w{3})/(?P\d{2})/(?P[- \w]+)/$', 'object_detail', entry_info_dict, 'coltrane_entry_detail'), ) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
URL & DB question
Using the url to look up a user profile just not sure what to put in the view. Any suggestions welcome. Model: class Profile(models.Model): title = models.ForeignKey(User, unique=True) name = models.CharField(max_length=50, null=False, blank=False) def __unicode__(self): return self.name URL: (r'^(?P[\w\._-]+)/$', 'mysite.profiles.views.profile_detail'), View: def profile_detail(request, name): name = get_list_or_404(Profile, name=name) return render_to_response('profile_detail.html', now what? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: URL & DB question
Solved it by doing this: def profile_detail(request, name): p = get_object_or_404(Profile, name=name) return render_to_response('profile_detail.html', {'name': p}) On 1 Aug, 12:22, "Rob B (uk)" wrote: > Using the url to look up a user profile just not sure what to put in > the view. Any suggestions welcome. > > Model: > class Profile(models.Model): > title = models.ForeignKey(User, unique=True) > name = models.CharField(max_length=50, null=False, blank=False) > > def __unicode__(self): > return self.name > > URL: > (r'^(?P[\w\._-]+)/$', 'mysite.profiles.views.profile_detail'), > > View: > def profile_detail(request, name): > name = get_list_or_404(Profile, name=name) > return render_to_response('profile_detail.html', now what? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
user online
Im using this middleware to try and display a list of online user on my site. http://dpaste.com/77464/ Im just not sure how to pass it to my view and template. Any ideas? Middleware found @ http://groups.google.com/group/django-users/browse_thread/thread/6f5f759d3fd4318a/ Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django-cms-2.0 problem
Trying to get a default install of : http://github.com/digi604/django-cms-2.0/ up and running on my dev but I'm getting this error when trying to log into admin http://dpaste.com/77696/ Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: user online
Thanks Daniel. Im still quite new to python / django and not sure how to pass OnlineUsers.get_online_user_ids() into the context. My view to list all profiles looks like this: def profile_list(request): return render_to_response('profile_list.html', { 'profile_list': Profile.objects.all () }, context_instance=RequestContext(request)) On 9 Aug, 22:16, Daniel Roseman wrote: > On Aug 9, 10:07 pm, "Rob B (uk)" wrote: > > > Im using this middleware to try and display a list ofonlineuser on > > my site.http://dpaste.com/77464/ > > > Im just not sure how to pass it to my view and template. Any ideas? > > > Middleware found > > @http://groups.google.com/group/django-users/browse_thread/thread/6f5f... > > > Thanks > > Jeremy explains how to do it in the message you link to: > "You'll want to use OnlineUsers.get_online_user_ids() wherever you > need > the list of IDs. " > > ie import the OnlineUsers module in your view and pass > OnlineUsers.get_online_user_ids() into the context. > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: user online
Im reading through loads of python / django tutorials atm, hopefully some of it will stick! I added what you suggested and now I'm getting the error "type object 'OnlineUsers' has no attribute 'get_online_user_ids'" view - http://dpaste.com/77965/ middleware (name OnlineUsers) - http://dpaste.com/77967/ What am I doing wrong now? Thanks R On Aug 10, 8:32 pm, Daniel Roseman wrote: > On Aug 10, 7:10 pm, "Rob B (uk)" wrote: > > > Thanks Daniel. > > Im still quite new to python / django and not sure how to pass > > OnlineUsers.get_online_user_ids() into the context. My view to list > > all profiles looks like this: > > def profile_list(request): > > > return render_to_response('profile_list.html', > > > { 'profile_list': Profile.objects.all > > () }, context_instance=RequestContext(request)) > > You pass it exactly as you are passing the list of profile objects: > { 'profile_list': Profile.objects.all(), > 'online_users': OnlineUsers.get_online_user_ids() } > > You really need to read an introductory Python tutorial - you must at > least know how to define variables like dictionaries, and how to call > functions. > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: user online
Brill thanks. Its actaully working! Getting a the IDs with the template: {% for user_set in online_users %} {{ user_set }} {% empty %} To list the usernames instead of the ID will I need to update the view or is there a clever trick with the template? On Aug 10, 11:02 pm, Daniel Roseman wrote: > On Aug 10, 10:45 pm, "Rob B (uk)" wrote: > > > Im reading through loads of python / django tutorials atm, hopefully > > some of it will stick! > > > I added what you suggested and now I'm getting the error "type object > > 'OnlineUsers' has no attribute 'get_online_user_ids'" > > view -http://dpaste.com/77965/ > > middleware (name OnlineUsers) -http://dpaste.com/77967/ > > What am I doing wrong now? > > > Thanks R > > You've imported get_online_user_ids directly, so you don't in fact > need to use OnlineUsers again to call it - in this case Python think > you're talking about a class method of the OnlineUsers middleware > class which you also import (really it's best to keep class names > different from the modules they live in). > > So you just need to do: > { 'profile_list': Profile.objects.all(), 'online_users': > get_online_user_ids() } > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Need help getting the company I work for to go with django
I work as a web developer at a reasonably large company in London. We are just about to completely re brand and rebuild the companies website (s) and implement a CMS. I'm having a meeting tomorrow to discuss different avenues we can go down in regards to what technologies we can use. I'm hoping to steer them towards Django! If you were me how would you sell Django to fellow developers and business (non-techies) people?? The CMS will need to cope with million+ hits a month & have multilingual support. P.S. I know django isn't a CMS. I want to build a custom one using it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
question about admin.py list_display
http://dpaste.com/89435/ I'm trying to show game.status in GameListAdmin's list_display but not sure how to do a backwards lookup using the ForeignKey in Admin.py See link for details. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: question about admin.py list_display
Solved over at http://stackoverflow.com/questions/1378447/question-about-admin-py-listdisplay On Sep 4, 11:28 am, "Rob B (uk)" wrote: > http://dpaste.com/89435/ > > I'm trying to show game.status in GameListAdmin's list_display but not > sure how to do a backwards lookup using the ForeignKey in Admin.py > > See link for details. > > Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
date range headache
http://dpaste.com/90621/ (The code in above obviously isn't going to work I'm just using it to help illustrate my problem.) I want to show all active promotions between the start date and end date. So if a promotion starts on 01/01/09 and ends 30/01/09 and a person searches from 01/12/08 to 01/02/09 it will still return a result. Also if they search from inside the date range e.g. 02/01/09 - 03/01/09 they would get the same result. Is there some magical django way of achieving this without looping over each day? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: date range headache
Oh that just makes my brain hurt lol Works though! thanks On Sep 7, 3:13 pm, Masklinn wrote: > On 7 Sep 2009, at 15:50 , Rob B (uk) wrote:http://dpaste.com/90621/ > > > (The code in above obviously isn't going to work I'm just using it to > > help illustrate my problem.) > > > I want to show all active promotions between the start date and end > > date. > > So if a promotion starts on 01/01/09 and ends 30/01/09 and a person > > searches from 01/12/08 to 01/02/09 it will still return a result. Also > > if they search from inside the date range e.g. 02/01/09 - 03/01/09 > > they would get the same result. > > > Is there some magical django way of achieving this without looping > > over each day? > > Something along the lines of: > > Promotion.objects.filter(start_date__lt=end_date, > end_date__gt=start_date) > > I'd think. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
models.Manager error
Model: http://dpaste.com/96349/ View: def game_list(request): return render_to_response('games/game_list.html', { 'object_list': GameList.objects.published.all().order_by('position')}) Template error: AttributeError at /games/ 'Manager' object has no attribute 'published' Would seem my view doesn't like my new manager 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Best intranet solution for a small digital agency?
I work for a small digital agency (10-15 employees). We design and build websites (using php and Django). Are we better off building our own intranet using django or going for a pre built (free or paid for) solution? Key features needed: - Project management (basecamp clone) - Time reporting - Local and external file sharing (dropbox clone) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
form model def save question
Been struggling over at http://stackoverflow.com/questions/3652585/simple-django-form-model-save-question to get a solution. I want the inuse field to update to to True when LocationForm is saved. For example there would be a list of locations added by the admin (London, New York and Paris) all with inuse of False. The user would select London and submit the form and the inuse field for London would become True. Models and forms: class Location(models.Model): place = models.CharField(max_length=100) inuse = models.BooleanField() class Meta: ordering = ('place', 'id') def __unicode__(self): return self.place class LocationForm(ModelForm): class Meta: model = Location class Booking(models.Model): name = models.CharField(max_length=100, verbose_name="Your name*:") place = models.ManyToManyField(Location, blank=True, null=True) def __unicode__(self): return self.name class BookingForm(ModelForm): class Meta: model = Booking def save(self, commit=True): booking = super(BookingForm, self).save(commit=False) if commit: booking.save() for location in booking.place.all(): location.inuse = True location.save() Code saves fine but the location.inuse field is not saved to True. Any ideas where I'm going wrong? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django or CMS.
The design agency I work for are looking into CMS options. Being a Django man myself I'm hoping to convince them to build one using Django. Requirements are roughly: Page control (creation/drafts/published/withdrawn/deletion) Page revisions View draft pages on site for testing In-place editing for simple text updates Categories Editable Navigation Wysiwyg editors Image upload (mass select) Tagging (pages, images, clients) Smart site search Limiting user publishing rights I can't seem to find a decent CMS that would fit the criteria. What are people's opinions / experiences with CMS'? What would you recommend? 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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.