Static file problem using the development server
I tried using a style sheet served as a static file with the tutorial project. In settings.py, I defined STATIC_URL = /static/ and STATICFILES_DIRS = ('/path/to/project/static/',). Then I defined a base_html template with a line in the HEAD of the form and put style.css in directory /static/. Finally, I defined index.html, detail.html, etc., as given in the tutorial to each extend base.html. Everything works perfectly, except that only one template (detail.html) correctly processes the {{ STATIC_URL }} value to find / static/style.css. In every other template, {{ STATIC_URL }} evaluates to the empty string, giving just style.css, which does not exist of course. Every template extends the single base template in the same way. So why does {{ STATIC_URL }} work for some templates and not others? Rodney -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How can I use {{variable}} in custom templatetag?
{% get_related_entries weblog.entry 5 from object.categories as related_entries %} {% for entry in related_entries %} {{ entry.title }} {% endfor %} class RelatedEntryNode(template.Node): def __init__(self, model, number, categories, varname): self.model = model self.number = int(number) self.categories = template.Variable(categories) self.varname = varname >Ok, so this means that: >self.model is a string; literally, in your example, "weblog.entry" No, self.model shouldn't be a string. It should be the model for Entry in app weblog (and I use it like that in other custom template tags that work) The templatetag is used when on a blog entry detail page and should give a list of related entries (with corresponding categories) . It comes from django.db.models.get_model() (p117 of Practical Django Projects) >But that's fine, because your render() method is going to compute some >value, probably a list of Entry instances in this case, and then it will >create a new context variable, with the statement; >context[self.related_entries] = This is where the problem is. I don't get a computed list. It returns nothing instead of 1 other related blogentry (in this case) I'm really stuck now in solving this quite common query: * a blog entry is shown in a detail page * this blog entry has categories (m2m relation) Let's assume categories C1 and C2 * other blog entries have the same categories (also C1 and C2, I'll skip the OR relation for now) * through a custom template tag I want to get the list of Entry instances that have categories C1 AND/OR C2 and display them on the detailpage. * Three database tables are involved in this query ** weblog_entry (which contains the entries) ** category_entry (which contains the categories) ** weblog_entry_categories (which joins the entry with the category) When displaying the blog entry, Django also references these 3 tables (otherwise I wouldn't get the category name in the template.) I'm going around in circles and am afraid I don't see where the problem could be. I reread the books, went through the documentation and searched the internet, but am getting nowhere. I'm sure I'm overcomplicating things as this should be a quite easy common query to perform. Maybe you could give a hint or a pointer how you would achieve this thorugh a template tag? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/VSgdCU_fo5cJ. 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: Static file problem using the development server
On Tuesday, 9 August 2011 08:24:20 UTC+1, Rodney Topor wrote: > > I tried using a style sheet served as a static file with the tutorial > project. In settings.py, I defined STATIC_URL = /static/ and > STATICFILES_DIRS = ('/path/to/project/static/',). Then I defined a > base_html template with a line in the HEAD of the form > > > > and put style.css in directory /static/. Finally, I defined > index.html, detail.html, etc., as given in the tutorial to each extend > base.html. > > Everything works perfectly, except that only one template > (detail.html) correctly processes the {{ STATIC_URL }} value to find / > static/style.css. In every other template, {{ STATIC_URL }} evaluates > to the empty string, giving just style.css, which does not exist of > course. > > Every template extends the single base template in the same way. So > why does {{ STATIC_URL }} work for some templates and not others? > > Rodney Because you need to use a RequestContext to render the template. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/H_SiI4YEu1YJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to get request object out of views
On Tuesday, 9 August 2011 02:33:47 UTC+1, oops wrote: > > Hi, > > May be you miss understanted my meaning. > > I just want to get the current user object in a normal .py file out of > views. > > And this file just offer some data according to different user. > > Do you have any methods to get the goal? > > thank you > > regards, > kejun > No, Tom understood you fine, and his answer was quite clear. Get the user from the template context into your tag, and pass it from there into the list function. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/LwpPt4GXW8sJ. 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: Static file problem using the development server
Great. Thank you. I missed one, and this somehow affected others. (Must try to understand what RequestContext really does one day.) RT -- 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: Static file problem using the development server
On Tuesday, 9 August 2011 09:48:22 UTC+1, Rodney Topor wrote: > > Great. Thank you. I missed one, and this somehow affected others. > (Must try to understand what RequestContext really does one day.) > > RT It just runs the context processors, which add various things to the context - including STATIC_URL. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/I039Wz2IzRcJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to get request object out of views
hi, Ok, It is a good method to get the current user. I am sorry for that. But i just do maintain a django project, and i do not want to change the template structure. And now, I have found a new method to resolve the problem. through a variable CURRENT_USER defined in settings.py to save the current user in a view. and get the current_user from settings.CURRENT_USER. thanks for your reply. And i found a strange appearance. PART_ONE: I defined a variable named CURRENT_USER and import the settings in a view like below: from gmadmin import settings ## the gmadmin is the name of the topo directory then assign request.user to settings.CURRENT_USER PART_TWO: Get the settings.CURRENT_USER in a .py file the code: import settings user = settings.CURRENT_USER But it reported a problem: the settings.CURRENT_USER is None . and the problem disappeared when i use "import settings" instead of "from gmadmin import settings" on PART_ONE。 Could you talk about it? regards, kejun On Tue, Aug 9, 2011 at 4:23 PM, Daniel Roseman wrote: > > On Tuesday, 9 August 2011 02:33:47 UTC+1, oops wrote: >> >> Hi, >> >> May be you miss understanted my meaning. >> >> I just want to get the current user object in a normal .py file out of >> views. >> >> And this file just offer some data according to different user. >> >> Do you have any methods to get the goal? >> >> thank you >> >> regards, >> kejun >> > > No, Tom understood you fine, and his answer was quite clear. Get the user > from the template context into your tag, and pass it from there into the > list function. > -- > DR. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/LwpPt4GXW8sJ. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Passing data between the view and the form
Hello there I've got an event model, which has an association with multiple workshops models.py class Event(models.Model): workshops = models.ManyToManyField(Workshop, related_name='evt_workshop', limit_choices_to = {'lang_code__in': ('B', 'E')}, blank=True, null=True) I've got a form that I then use to create the email, with the view forms.py class EventBookForm(ModelForm): workshops = MultipleChoiceField() views.py def event_book(request,edate, slug): I run through some logic here based on request type, and put together the email that sends off the selected items I also throw data back to the form, like this eventdetail = Event.objects.filter(slug=ventslug,start_date=ventdate) for d in eventdetail: workshopid = d.id workshop = Workshop.objects.filter(evt_workshop=workshopid) cats = formextra.objects.all() context = Context({'form': form, 'cats': cats, 'eventdetail': eventdetail, 'workshop': workshop }) return render_to_response('forms/eventbookform.html', context, context_instance=RequestContext(request)) My problem is this I can't find a way to list the workshops that are associated with the event AND send which ones are selected in the tick boxes in the email. I can list the workshops that are associated with the event in the view workshops = Workshop.objects.filter(evt_workshop=d.id) workshoptitlearray = '' for w in workshops: workshoptitle = w.title workshoptitlearray = workshoptitlearray + ', ' + w.title I think I need to do something like this in the form though, in order to send the items that have been selected class EventBookForm(ModelForm): workshops = MultipleChoiceField() requirements = CharField(widget=Textarea(attrs={'rows': 5, 'cols': 80})) class Meta: model = Event def __init__(self, *args, **kwargs): self.request = kwargs.pop('request', None) super(EventBookForm, self).__init__(*args, **kwargs) workshop_choices = [] data = Workshop.objects.all() print data for d in data: workshop_choices.append((d.title,d.title)) self.fields['workshops']=MultipleChoiceField(widget=CheckboxSelectMultiple, choices=workshop_choices, required=False) As you can see, I'm getting myself into a bit of a mess here, if anyone can shed any light on how I access the information passed from the view context = Context({'form': form, 'cats': cats, 'eventdetail': eventdetail, 'workshop': workshop }) return render_to_response('forms/eventbookform.html', context, context_instance=RequestContext(request)) Any help, greatly appreciated, as always -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to get request object out of views
On Aug 9, 11:22 am, Kejun He wrote: > hi, > Ok, It is a good method to get the current user. It's actually THE good method. > > But i just do maintain a django project, and i do not want to change the > template structure. > > And now, I have found a new method to resolve the problem. > > through a variable CURRENT_USER defined in settings.py to save the current > user in a view. > and get the current_user from settings.CURRENT_USER. How ? And does it really works ?-) (hint: whatever you might think, it's totally broken) > And i found a strange appearance. > > PART_ONE: > I defined a variable named CURRENT_USER > > and import the settings in a view like below: > > from gmadmin import settings ## the gmadmin is the name > of the topo directory DONT import settings that way. ALWAYS use "from django.conf import settings" > > then assign request.user to settings.CURRENT_USER Question: what do you think will happen in a multithreaded environment ? > PART_TWO: > Get the settings.CURRENT_USER in a .py file > > the code: > import settings > user = settings.CURRENT_USER > > But it reported a problem: the settings.CURRENT_USER is None . > and the problem disappeared when i use "import settings" instead of "from > gmadmin import settings" on PART_ONE。 > > Could you talk about it? It would be better if you learned enough about Django and Python to find out by yourself - and why this approach will never work. In the meantime, save yourself some pain and do things the right way (IOW: do has Tom said). -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to get request object out of views
On Tue, Aug 9, 2011 at 10:22 AM, Kejun He wrote: > hi, > Ok, It is a good method to get the current user. I am sorry for that. > > But i just do maintain a django project, and i do not want to change the > template structure. > > And now, I have found a new method to resolve the problem. > > through a variable CURRENT_USER defined in settings.py to save the current > user in a view. > and get the current_user from settings.CURRENT_USER. > > thanks for your reply. > > > And i found a strange appearance. > > PART_ONE: > I defined a variable named CURRENT_USER > > and import the settings in a view like below: > > from gmadmin import settings ## the gmadmin is the name > of the topo directory > > then assign request.user to settings.CURRENT_USER > > PART_TWO: > Get the settings.CURRENT_USER in a .py file > > the code: > import settings > user = settings.CURRENT_USER > > > But it reported a problem: the settings.CURRENT_USER is None . > and the problem disappeared when i use "import settings" instead of "from > gmadmin import settings" on PART_ONE。 > > > Could you talk about it? > > regards, > kejun > You should not do this. https://docs.djangoproject.com/en/1.3/topics/settings/#altering-settings-at-runtime If a function needs a user object, pass it a user object as an argument. Using globals is a clear sign that you haven't understood the problem. Don't do it. I gave you a precise way of achieving this without futzing around with anti-patterns. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to get request object out of views
On Tue, Aug 9, 2011 at 5:54 PM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > On Aug 9, 11:22 am, Kejun He wrote: > > hi, > > Ok, It is a good method to get the current user. > > It's actually THE good method. > > > > > But i just do maintain a django project, and i do not want to change the > > template structure. > > > > And now, I have found a new method to resolve the problem. > > > > through a variable CURRENT_USER defined in settings.py to save the > current > > user in a view. > > and get the current_user from settings.CURRENT_USER. > > How ? And does it really works ?-) > (hint: whatever you might think, it's totally broken) > > > And i found a strange appearance. > > > > PART_ONE: > > I defined a variable named CURRENT_USER > > > > and import the settings in a view like below: > > > > from gmadmin import settings ## the gmadmin is the > name > > of the topo directory > > DONT import settings that way. ALWAYS use "from django.conf import > settings" > I test in my development server, and found that from django.conf import settings is to all client but import settings is to a singal one > > > > > then assign request.user to settings.CURRENT_USER > > Question: what do you think will happen in a multithreaded > environment ? > I just test it on my development server, and it could work normally when there are several users. And have not test it in a multithreaded environment. > > PART_TWO: > > Get the settings.CURRENT_USER in a .py file > > > > the code: > > import settings > > user = settings.CURRENT_USER > > > > But it reported a problem: the settings.CURRENT_USER is None . > > and the problem disappeared when i use "import settings" instead of "from > > gmadmin import settings" on PART_ONE。 > > > > Could you talk about it? > > It would be better if you learned enough about Django and Python to > find out by yourself - and why this approach will never work. > > In the meantime, save yourself some pain and do things the right way > (IOW: do has Tom said). > my method is not a normal way on django thanks for your suggestion, I will spend enough time to learned django, i am so new > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to get request object out of views
hi, I will do as your method thanks for your reply regards, kejun On Tue, Aug 9, 2011 at 5:56 PM, Tom Evans wrote: > On Tue, Aug 9, 2011 at 10:22 AM, Kejun He wrote: > > hi, > > Ok, It is a good method to get the current user. I am sorry for that. > > > > But i just do maintain a django project, and i do not want to change the > > template structure. > > > > And now, I have found a new method to resolve the problem. > > > > through a variable CURRENT_USER defined in settings.py to save the > current > > user in a view. > > and get the current_user from settings.CURRENT_USER. > > > > thanks for your reply. > > > > > > And i found a strange appearance. > > > > PART_ONE: > > I defined a variable named CURRENT_USER > > > > and import the settings in a view like below: > > > > from gmadmin import settings ## the gmadmin is the > name > > of the topo directory > > > > then assign request.user to settings.CURRENT_USER > > > > PART_TWO: > > Get the settings.CURRENT_USER in a .py file > > > > the code: > > import settings > > user = settings.CURRENT_USER > > > > > > But it reported a problem: the settings.CURRENT_USER is None . > > and the problem disappeared when i use "import settings" instead of "from > > gmadmin import settings" on PART_ONE。 > > > > > > Could you talk about it? > > > > regards, > > kejun > > > > You should not do this. > > > https://docs.djangoproject.com/en/1.3/topics/settings/#altering-settings-at-runtime > > If a function needs a user object, pass it a user object as an > argument. Using globals is a clear sign that you haven't understood > the problem. Don't do it. I gave you a precise way of achieving this > without futzing around with anti-patterns. > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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: Using Form Elements Widgets direclty in HTML
Since you don't want to use forms class, you can write elements in your templates directly. 2011/8/9 Hayyan Rafiq > Hi I wanted to know if there was a way in which we could use widget > directly in an HTML file > By widget i mean elements of a form such as input boxes,calendars,Buttons > etc without using the forms class. > > For example A default normal html input box is : > > I wanted to replace it with a fancier (more interesting and professional) > input box.. > any suggestions on how i could do that would be appreciated.. > > I also wanted to use a table in my HTML to display contents from my DB. Do > you guys have anything in mind which might be useful for me... > I currently am generating the table dynamically using tag > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to get request object out of views
On Aug 9, 12:13 pm, Kejun He wrote: > On Tue, Aug 9, 2011 at 5:54 PM, bruno desthuilliers < > > > > DONT import settings that way. ALWAYS use "from django.conf import > > settings" > > I test in my development server, and found that > > from django.conf import settings is to all client > > but > > import settings is to a singal one I don't understand what you mean here. But anyway: the only correct way to import your project's settings module is to use the first form. It #1 respects the --settings option of ./manage.py (or the $DJANGO_SETTINGS_MODULE environment variable - cf deploying on mod_wsgi), and #2 makes sure you have the default values for what you didn't set in you settings file. > > > > then assign request.user to settings.CURRENT_USER > > > Question: what do you think will happen in a multithreaded > > environment ? > > I just test it on my development server, and it could work normally when > there are several users. I'm talking about multithreaded environment here. > And have not test it in a multithreaded environment. Please do. -- 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.
Trying to simplify the last post
Hello there I'm trying to make this as easy as possible, but it's pretty complicated. Here's my form class EventBookForm(ModelForm): """A form for governors to email to govwales with details of which events they wish to attend""" title = CharField() firstname = CharField() surname = CharField() address = CharField(widget=Textarea(attrs={'rows': 5, 'cols': 80})) postcode = CharField() telephone = CharField() email = EmailField() govtype = Field(widget=Select(choices=GOVTYPELIST)) schoolname = CharField(widget=Textarea(attrs={'rows': 2, 'cols': 60})) authority = CharField() workshops = MultipleChoiceField() requirements = CharField(widget=Textarea(attrs={'rows': 5, 'cols': 80})) class Meta: model = Event def __init__(self, *args, **kwargs): super(EventBookForm, self).__init__(*args, **kwargs) workshop_choices = [] data = Workshop.objects.filter(evt_workshop='80') print data for d in data: workshop_choices.append((d.title,d.title)) self.fields['workshops']=MultipleChoiceField(widget=CheckboxSelectMultiple, choices=workshop_choices, required=False) As you can see I've hard coded the id of the event into this section data = Workshop.objects.filter(evt_workshop='80') If I could pass the request object into the form, or the event ID itself,I could get at the right data for the workshop_choices list. Here's the view Note that I still haven't worked out how I send only the selected/ ticked multiple items yet def event_book(request,edate, eslug): if request.method == 'POST': form = EventBookForm(request.POST) if form.is_valid(): the_rufurl = request.META['HTTP_REFERER'] the_url = request.META['HTTP_REFERER'].split('/') eventdate = "%s-%s-%s" % (the_url[5], the_url[6], the_url[7]) eventslug = the_url[8] eventdetails = Event.objects.filter(start_date=eventdate) for d in eventdetails: eventid = d.id eventtitle = d.title print "event title" + eventtitle eventdate = d.start_date eventstarttime = d.start_time eventendtime = d.end_time eventvenue = d.venue workshops = Workshop.objects.filter(evt_workshop=d.id) workshoptitlearray = '' for w in workshops: workshoptitle = w.title workshoptitlearray = workshoptitlearray + ', ' + w.title to = ['tonm...@gmail.com','cont...@governorswales.org.uk'] subject = 'Event Booking Form' from_email = 'cont...@governorswales.org.uk' cleaned_data = form.cleaned_data print cleaned_data['workshop'] htmllinksuggestion = 'Title: ' + cleaned_data['title'] + '' htmllinksuggestion += 'First Name: ' + cleaned_data['firstname'] + '' htmllinksuggestion += 'Surname: ' + cleaned_data['surname'] + '' htmllinksuggestion += 'Address: ' + cleaned_data['address'] + '' htmllinksuggestion += 'Post Code: ' + cleaned_data['postcode'] + '' htmllinksuggestion += 'Telephone Number: ' + cleaned_data['telephone'] + '' htmllinksuggestion += 'Email Address: ' + cleaned_data['email'] + '' htmllinksuggestion += 'Type of Governor: ' + cleaned_data['govtype'] + '' htmllinksuggestion += 'Name of School: ' + cleaned_data['schoolname'] + '' htmllinksuggestion += 'Authority: ' + cleaned_data['authority'] + '' htmllinksuggestion += 'Event Title: ' + str(eventtitle) + '' htmllinksuggestion += 'Event Date: ' + str(eventdate) + '' htmllinksuggestion += 'Workshops Selected: ' + str(workshoptitlearray) + '' htmllinksuggestion += 'Requirements: ' + cleaned_data['requirements'] + '' html_content = htmllinksuggestion text_content = '' msg = EmailMultiAlternatives(subject, text_content, from_email, to, headers = {'Reply-To': 'mjdav...@creativebeans.co.uk'}) msg.attach_alternative(html_content, "text/html") msg.send() return HttpResponseRedirect
Re: Tutorial Part 2, django 1.3, installed via bitnami
That did help, thanks a lot :) On 9 Sie, 03:21, Mike Dewhirst wrote: > On 9/08/2011 9:49am, eggxtreme wrote: > > > Hi, i've had some strange errors when trying to install django > > standalone, so i have used the whole bundle option, linked from > > documentation. Bitnami. It installed python, django, apache, > > sqlite I use Windows XP btw. > > I'm not sure whether Bitnami will let you choose the locations for your > stack components but if not I would suggest you uninstall everything and > start again installing into your own locations. > > IMHO you need short directory names without spaces so you can easily > adjust settings and config files and actually use less brain-space to > make things happen. > > If it was me I'd create C:\lamp as a root directory for python and > apache. I'd create C:\users\Luka\dprojects as root for Django projects > and their source including (eventually) your own css and images etc. > C:\users\Luka by the way is where Windows 7 will put your "My Documents" > etc and profile. > > Then install ... > > - Apache into C:\lamp\apache > - Python into C:\lamp\python > - Sqlite into C:\lamp\sqlite (not that I use Sqlite - I prefer PostgreSQL) > > Provided Python installs successfully it will establish all the > necessary environment vars so that Django will automatically install > into C:\lamp\python\Lib\site-packages\django > > After that, in C:\users\Luka\dprojects\first I'd try again according to > the tutorial > > On my own XP machine, I adjusted "My Documents" to point to > C:\users\miked which makes life less complex. > > Other people might have other ideas and I'm not insisting you give up > spaces in filenames. This is just my take on your problems. > > Good luck > > Mike > > > > > > > > > > > And i've went first run on python and django by the tutorial. > > Unfortunatly i have stopped at part 2 when i should login to admin > > panel, and can't solve problem with css and js files. They just don't > > load, do a 404 and i see admin panel in a pure html layout (scary). > > > So how could i fix this? > > My settings.py and urls.py are all default, except i turned on all > > those apps that tutorial said to and admin url. > > > I see that the css and js files lies in their folders under this path: > > C:\Program Files\BitNami DjangoStack\apps\django\django\contrib\admin > > \media > > > While my app(models, views,tests) is here: > > C:\Documents and Settings\Luka\BitNami DjangoStack projects\djangoTut > > \polls > > > and settings.py is one folder up > > > How should i configure and what to make those damn css load? -- 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: Trying to simplify the last post
On Tuesday, 9 August 2011 12:09:08 UTC+1, vanderkerkoff wrote: > > Hello there > > I'm trying to make this as easy as possible, but it's pretty > complicated. > > Here's my form > > > > As you can see I've hard coded the id of the event into this section > > data = Workshop.objects.filter(evt_workshop='80') > > If I could pass the request object into the form, or the event ID > itself,I could get at the right data for the workshop_choices list. > > So why not do this? What's stopping you? I can't read the rest of the code, because of the lack of indentation. I would say, though, that you're doing a lot of HTML manipulation in the view - that sort of thing is best done in a template. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/jsHHjFj7DtsJ. 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.
Time duration in django models
Hey guys, I am just wondering if there is a time duration field in django models. what I want to do is a field that takes a time duration in days, hours, mins, seconds and store it into the database. -- Mohamed Sayed Ghoneim -- 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: Time duration in django models
Nothing native. I'd store it in seconds, as an int, and let the model convert to and from a timedelta. Looks like there's a snippet all ready to go: http://djangosnippets.org/snippets/1060/ On Aug 9, 6:32 am, Mohamed Ghoneim wrote: > Hey guys, > > I am just wondering if there is a time duration field in django models. > > what I want to do is a field that takes a time duration in days, hours, > mins, seconds and store it into the database. > > -- > Mohamed Sayed Ghoneim -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Need help writing join Django query for this simple model..
On Mon, Aug 8, 2011 at 11:49 PM, Hayyan Rafiq wrote: > so i tried this now > > > class Student_Info(models.Model): > Roll_No = models.IntegerField(primary_key=True) > Cell_No = models.IntegerField() > > E_mail = models.EmailField(max_length=30) > > class Academics(models.Model): > * #Roll_No = models.ForeignKey('Student_Info',to_field='Roll_No')* > * Roll_No = models.OneToOneField('Student_Info',to_field='Roll_No')* > GPA = models.IntegerField() > > You would really be better off naming Roll_No in Academics something like "student_info". (And in general changing your naming conventions to match Python, but this one field in particular is going to be very confusing if you name it as you have). In the Django ORM, the field will be an object that contains the associated Student_Info instance, it will not be a simple Integer containing the Roll_No of that student. The fact that you have specified Roll_No as the field to link on (which is unnecessary by the way, the primary key field will be used by default) is irrelevant. > Then i tried this : > > >>> from DbDemo.models import Student_Info > > >>> list=Student_Info.objects.all() > >>> obj=list[0] > >>> obj > > >>> obj.GPA > >>> obj.GPA > * > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'Student_Info' object has no attribute 'GPA' > * > GPA isn't an attribute of a Student_Info, it's an Attribute of Academics. Student_Info has an associated academics object due to the OneToOne field in Academics, to access it's fields you need to specify that is where the field is: obj.academics.GPA The naming of the field used to access the "backwards" relationship is noted here: https://docs.djangoproject.com/en/dev/topics/db/queries/#one-to-one-relationships > > Then i tried > >>> from DbDemo.models import Academics > >>> list= Academics.objects.all() > >>> obj=list[0] > >>> obj > > > >>> obj.E_mail > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'Academics' object has no attribute 'E_mail' > E_mail is in the linked Student_Info object: obj.Roll_No.E_mail (this is why I mentioned Roll_No is probably not really what you want to name that field) > >>> obj.Student_Info.GPA > > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'Academics' object has no attribute 'Student_Info' > GPA is directly in the Academics object: obj.GPA Linking two models via a ForeignKey or OneToOne field doesn't make all the attributes of one directly accessible in the other: you need to specify the relationship you want to follow in order to get at whatever attribute you are looking for. Karen -- http://tracey.org/kmt/ -- 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.
Tutorial: New class based generic views
Hey guys, This is the first part of a series of blog posts I'm writing about class based generic views: http://pseudocorta.blogspot.com/2011/08/django-generic-views.html Cheers! Juan Pablo -- 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: problem with django admin
Hi all, Anybody know a good documentation or book that can help me with integrating google maps with my app? -- 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: Using Form Elements Widgets direclty in HTML
Could you please give an example.. say of a simple input box in html its done like How would i replace the default input box with the one from Django widgets?? Date: Tue, 9 Aug 2011 18:34:56 +0800 Subject: Re: Using Form Elements Widgets direclty in HTML From: changjia...@gmail.com To: django-users@googlegroups.com Since you don't want to use forms class, you can write elements in your templates directly. 2011/8/9 Hayyan Rafiq Hi I wanted to know if there was a way in which we could use widget directly in an HTML file By widget i mean elements of a form such as input boxes,calendars,Buttons etc without using the forms class. For example A default normal html input box is : I wanted to replace it with a fancier (more interesting and professional) input box.. any suggestions on how i could do that would be appreciated.. I also wanted to use a table in my HTML to display contents from my DB. Do you guys have anything in mind which might be useful for me... I currently am generating the table dynamically using tag -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Admin model listing custom ordering
Thanks, Christian. After trying your attempts, I solved the problem by creating an additional "order" field in the ForeignKey. So in the referenced model I had to do: class Meta: ordering = ['fkfield__order'] That's not so elegant as I wished it to be, but it's not that ugly too, IMO. Vinicius 2011/7/28 christian.posta : > Is this something that can work for you? > > https://docs.djangoproject.com/en/1.3/ref/models/options/#order-with-respect-to > > If not, then the only thing i can do is recommend you review the > source code for how the ordering happens in the admin module for a > model. > > The main spots to look at would be the get_ordering() method of the > ChangeList class (django/contrib/admin/views/main.py) and the > get_query_set() method of the same class. The ordering will definitely > change, regardless of the queryset you override in the ModelAdmin > class, but those two methods should give some clue as to what ordering > options are available to you (default is descending by ID). you may > wish to look closer than i did at the first line in the get_ordering() > method which goes like this: > lookup_opts, params = self.lookup_opts, self.params > there might be some additional ordering that can be accomplished with > those variables. > > good luck, let me know if you figure it out > > On Jul 28, 6:07 am, Vinicius Massuchetto > wrote: >> I got a model with a ForeignKey field, and I want the default listing >> of this model to be ordered by this field. >> >> I get the correct `qs.query` SQL statement, but for some reason the >> admin listing is not following it. This is what I've done so far: >> >> class SomeAdminModel(admin.ModelAdmin): >> # ... fields >> >> def queryset(self, request): >> qs = super(SomeAdminModel, self).queryset(request) >> fk_list = [1,2,7,3,5,6,4] >> ordering = 'FIELD(`fk_field_id`, %s)' % ','.join(str(id) >> for id in fk_list) >> qs = qs.filter(fk_field__in = fk_list).extra( >> select = {'ordering': ordering}, >> order_by = ('ordering',) >> ) >> return qs >> >> What can be preventing this from behave as desired? Do I need to >> override anything else? >> >> Thanks in advance. >> -- >> Vinicius Massuchettohttp://vinicius.soylocoporti.org.br > > -- > 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. > > -- Vinicius Massuchetto http://vinicius.soylocoporti.org.br -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
RE: Need help writing join Django query for this simple model..
Thanks for the suggestions.. okay suppose i change my models to something like this class Student_Info(models.Model): Roll_No = models.IntegerField(primary_key=True) Cell_No = models.IntegerField() E_mail = models.EmailField(max_length=30) class Academics(models.Model): #Roll_No = models.ForeignKey('Student_Info',to_field='Roll_No') roll = models.OneToOneField('Student_Info',to_field='Roll_No') GPA = models.IntegerField() Now how can i access the academic fields through the student object >>> from DbDemo.models import Student_Info >>> list=Student_Info.objects.all() >>> obj=list[0] >>> obj Now i got the Student_info object. and i know Student_Info is linked to Academics via Roll_No.. so now how could i read the GPA in Academics any suggestions?? Date: Tue, 9 Aug 2011 08:50:48 -0400 Subject: Re: Need help writing join Django query for this simple model.. From: kmtra...@gmail.com To: django-users@googlegroups.com On Mon, Aug 8, 2011 at 11:49 PM, Hayyan Rafiq wrote: so i tried this now class Student_Info(models.Model): Roll_No = models.IntegerField(primary_key=True) Cell_No = models.IntegerField() E_mail = models.EmailField(max_length=30) class Academics(models.Model): #Roll_No = models.ForeignKey('Student_Info',to_field='Roll_No') Roll_No = models.OneToOneField('Student_Info',to_field='Roll_No') GPA = models.IntegerField() You would really be better off naming Roll_No in Academics something like "student_info". (And in general changing your naming conventions to match Python, but this one field in particular is going to be very confusing if you name it as you have). In the Django ORM, the field will be an object that contains the associated Student_Info instance, it will not be a simple Integer containing the Roll_No of that student. The fact that you have specified Roll_No as the field to link on (which is unnecessary by the way, the primary key field will be used by default) is irrelevant. Then i tried this : >>> from DbDemo.models import Student_Info >>> list=Student_Info.objects.all() >>> obj=list[0] >>> obj >>> obj.GPA >>> obj.GPA Traceback (most recent call last): File "", line 1, in AttributeError: 'Student_Info' object has no attribute 'GPA' GPA isn't an attribute of a Student_Info, it's an Attribute of Academics. Student_Info has an associated academics object due to the OneToOne field in Academics, to access it's fields you need to specify that is where the field is: obj.academics.GPA The naming of the field used to access the "backwards" relationship is noted here: https://docs.djangoproject.com/en/dev/topics/db/queries/#one-to-one-relationships Then i tried >>> from DbDemo.models import Academics >>> list= Academics.objects.all() >>> obj=list[0] >>> obj >>> obj.E_mail Traceback (most recent call last): File "", line 1, in AttributeError: 'Academics' object has no attribute 'E_mail' E_mail is in the linked Student_Info object: obj.Roll_No.E_mail (this is why I mentioned Roll_No is probably not really what you want to name that field) >>> obj.Student_Info.GPA Traceback (most recent call last): File "", line 1, in AttributeError: 'Academics' object has no attribute 'Student_Info' GPA is directly in the Academics object: obj.GPA Linking two models via a ForeignKey or OneToOne field doesn't make all the attributes of one directly accessible in the other: you need to specify the relationship you want to follow in order to get at whatever attribute you are looking for. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Google AppEngine vs. dedicated hosting (Pros/cons)
Hi, If I wouldn't have a dedicated server, I would choose a hosting service, where I can deploy the (mostly) exact project as I do on my own server. This for the reason of portability and because of avoiding the learning curve.. You could have a look at [1]. These days there are lots of provider like Dotcloud. Ken inspired me with his blog [2] and in fact I am deploying a new small project to Dotcloud. [1] https://www.dotcloud.com/ [2] http://kencochrane.net/blog/2011/04/deploying-my-django-application-to-dotcloud/ Regards, Philip On Aug 8, 7:23 pm, francescortiz wrote: > Hi, > > I have dedicated server sites and django hosting sites. Personally, I > prefer that someone else takes care of the server and focus myself on > development. So, unless you need to use a lot of resources for some > reason, dedicated django hostings are ok to me. > > About google apps, I never used it. > > Regards, > > Francesc > > On Aug 5, 1:48 pm, Herman Schistad wrote: > > > > > > > > > Hello. > > > I'm developing a site with approx. 500 visits per day, mainly from > > Norway (Europe). > > > Now I'm trying to find the best possible way to host this site. > > Earlier I've used dedicated hosts like WebFaction and Djangoeurope, > > and this has worked pretty well. > > However Google AppEnginge is free and provides a really reliable > > server (as far as I can tell). But I'm no expert on this matter and > > therefore come to you guys. > > > What is the tradeoff between using Google AppEngine (with > > django-nonrel [1]), learning this, and writing my application for the > > Google datastore versus using a traditional host. > > Are there any big challanges by using AppEngine? > > > A third alternative would to maybe invest in e.g. dedicated virtual > > machine at MediaTemple[2] or something. > > > So what it all boils down to: which is your preffered hosting method, > > and why/why not? > > - Google AppEngine > > - Dedicated django hosting (e.g. WebFaction[3]) > > - Virtual server/dedicated server (e.g. MediaTemple) > > > tl;dr: pros/cons with Google AppEngine, and which hosting method is > > your preferred method? > > > [1]:http://code.google.com/appengine/articles/django.html > > [2]:http://mediatemple.net/webhosting/dv/ > > [3]:http://www.webfaction.com/ > > > -- > > With regards, Herman Schistad -- 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: Passing tuple values to a model choices field
The label_from_instance should simply return the obj. I don't think any fuzzy codes is needed as described in the Django docs [1] The method label_from_instance already converts the objects to string. So a simple override like this: class MyModelChoiceField(ModelChoiceField): def label_from_instance(self, obj): return obj I made changes like this to my code: """ Introduced a new model to store the form field select values """ class Branch(models.Model): """Branch""" name = models.CharField(max_length=50) name_branch = models.CharField(max_length=50) address_1 = models.CharField(max_length=100) class Meta: db_table = 'branch' def __unicode__(self): return u"%s | %s | %s" % ( unicode(self.name_branch), unicode(self.address_1)) """ subclass of ModelChoiceField class BranchModelChoiceField(ModelChoiceField): def label_from_instance(self, obj): return obj # Just return the obj class TransactionUpdateForm(forms.ModelForm): branchqs =Branch.objects.values_list('name_branch', flat=True) branches_field = BranchModelChoiceField(branchqs) #ModelChoiceField instance class Meta: model = Transaction fields = ('branch_name') In template file I do this: {{form.branches_field}} Thanks everyone [1] https://docs.djangoproject.com/en/1.3/ref/forms/fields/#modelchoicefield On Mon, Aug 8, 2011 at 8:54 PM, Kayode Odeyemi wrote: > I have made changes like this: > > """ Introduced a new model to store the form field select values """ > class Branch(models.Model): > """Branch""" > name = models.CharField(max_length=50) > name_branch = models.CharField(max_length=50) > address_1 = models.CharField(max_length=100) > > class Meta: > db_table = 'branch' > > def __unicode__(self): > return u"%s | %s | %s" % ( > unicode(self.name_branch), > unicode(self.address_1)) > > class TransactionUpdateForm(forms.ModelForm): > branchqs = Branch.objects.get(name_branch) > branches_field = forms.BranchModelChoiceField(branchqs) > #ModelChoiceField instance > branch_name_new = forms.models.CharField(required=True, > widget=forms.Select(choices={'BR_CODE1': 'HQ': 'Branch 2'})) > class Meta: > model = Transaction > fields = ('branch_name') > widgets = { > 'branch_name_new': Select(choices={'BR_CODE1': 'HQ': 'Branch > 2'}), > } > > """ subclass of ModelChoiceField > class BranchModelChoiceField(ModelChoiceField): > def label_from_instance(self, obj): > return "My Object #%i" % obj.id > > In template file I do this: > > {{form.branches_field}} > > Unfortunately, no luck yet. > > I'm still trying other options though. > > Thanks > > On Mon, Aug 8, 2011 at 3:20 PM, Tom Evans wrote: > >> On Mon, Aug 8, 2011 at 2:56 PM, Daniel Roseman >> wrote: >> > >> > I'm afraid it's really not clear what you're trying to do, or what the >> > problem is. >> > If the issue is that you have a field referring to a foreign key, and >> you >> > want to change what the values displayed in the dropdown for that field, >> > then you simply need to redefine the `__unicode__` method for the >> related >> > model, as documented >> > here: >> https://docs.djangoproject.com/en/1.3/ref/forms/fields/#modelchoicefield >> > An alternative, also documented at that link, is to subclass >> > ModelChoiceField and override label_from_instance. >> >> This exact question gets asked about 3 times a week (well, once you >> have normalized out the different ways in which it is asked..). >> Personally, I'm fed up of answering it. >> >> I think that adjusting the labels needs to become a bit more flexible >> - perhaps allow a "label_from_instance=callable" argument on >> ModelChoiceField, or have ModelChoiceField look for a >> MyForm.label_from_instance_ method. >> >> The current options are >> >> a) change how the related field's model is displayed throughout Django >> (which may be impossible to do for a cross app links/3rd party apps) >> b) provide your own Field class which labels things appropriately >> >> Both these options are more cumbersome than needs be, as evidenced by >> the number of users who don't understand how to do this. >> >> Cheers >> >> Tom >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > > > -- > Odeyemi 'Kayode O. > http://www.sinati.com. t: @charyorde > > -- Odeyemi 'Kayode O. http://www.sinati.com. t: @charyorde -- 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.c
'str' object has no attribute 'resolve' when access admin site
I keep getting this error: 'str' object has no attribute 'resolve' when trying to accessing the django admin site and I can't figure out why. I have apps within my project that have their own admin.py files. Could this cause it? here is my urls.py: from django.conf.urls.defaults import * import settings from django.contrib.auth.views import login, logout from views import index, simple, complex from django.views.generic.simple import direct_to_template # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^django_jchat/', include('django_jchat.foo.urls')), # Uncomment the admin/doc line below and add 'django.contrib.admindocs' # to INSTALLED_APPS to enable admin documentation: (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/', include(admin.site.urls)), ... and my admin site has been installed correctly in my settings.py file. Help please. thank you. -- 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.
same form model with separate admins and data
I've created a form with Model->ModelForm flow. Django is running on a sub-domain and I'm putting separate instances of the form on multiple php websites via iframe. How can I use the same form model but have independent forms? For example I want: form1 to be at: example.com/form1 form2 to be at: example.com/form2 form1 admin to be at: example.com/form1Admin form2 admin to be at: example.com/form2Admin I want form1 and form2 to use the same model but act independent of each other. For example I want form1 data to only be present in form1Admin. I believe I can add options in the url.py file for the different forms but I'm not sure how specify keeping the data separate in the database and setup the admin page. -- 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: same form model with separate admins and data
On Tue, Aug 09, 2011 at 08:53:07AM -0700, brian wrote: > I've created a form with Model->ModelForm flow. Django is running on > a sub-domain and I'm putting separate instances of the form on > multiple php websites via iframe. > > How can I use the same form model but have independent forms? > > For example I want: > form1 to be at: example.com/form1 > form2 to be at: example.com/form2 > > form1 admin to be at: example.com/form1Admin > form2 admin to be at: example.com/form2Admin > > I want form1 and form2 to use the same model but act independent of > each other. For example I want form1 data to only be present in > form1Admin. I believe I can add options in the url.py file for the > different forms but I'm not sure how specify keeping the data separate > in the database and setup the admin page. I'd probably add an extra field, maybe IntegerField or something to the model, exclude it in both ModelForms and ModelAdmins and define two distinct constants. Then provide the default predefined value in both ModelForms and ModelAdmins and specify corresponding QuerySets as needed. If you need any more details, just ask. Michal signature.asc Description: Digital signature
RE: Need help writing join Django query for this simple model..
okay so i got it working (Thanks to you guys) but i do have a question.. First my dbmodel is class Student_Info(models.Model): roll_no = models.IntegerField(primary_key=True) cell_no = models.IntegerField() e_mail = models.EmailField(max_length=30) class Academics(models.Model): roll = models.ForeignKey('Student_Info',to_field='roll_no') gpa = models.IntegerField() subject_code= models.IntegerField(primary_key=True) supervisor=models.CharField(max_length=30) So From Academics -> Student_info it works >>> list=Academics.objects.all() >>> obj=list[0] >>> obj >>> obj.roll.e_mail u'syvlisa...@hotmail.com' but from Student_info->Academics it doesnt work?? >>> list=Student_Info.objects.all() >>> obj=list[0] >>> obj >>> obj.roll_no.gpa Traceback (most recent call last): File "", line 1, in AttributeError: 'int' object has no attribute 'gpa' My question is how can i make it work both ways ?? Is that even possible??? Date: Tue, 9 Aug 2011 08:50:48 -0400 Subject: Re: Need help writing join Django query for this simple model.. From: kmtra...@gmail.com To: django-users@googlegroups.com On Mon, Aug 8, 2011 at 11:49 PM, Hayyan Rafiq wrote: so i tried this now class Student_Info(models.Model): Roll_No = models.IntegerField(primary_key=True) Cell_No = models.IntegerField() E_mail = models.EmailField(max_length=30) class Academics(models.Model): #Roll_No = models.ForeignKey('Student_Info',to_field='Roll_No') Roll_No = models.OneToOneField('Student_Info',to_field='Roll_No') GPA = models.IntegerField() You would really be better off naming Roll_No in Academics something like "student_info". (And in general changing your naming conventions to match Python, but this one field in particular is going to be very confusing if you name it as you have). In the Django ORM, the field will be an object that contains the associated Student_Info instance, it will not be a simple Integer containing the Roll_No of that student. The fact that you have specified Roll_No as the field to link on (which is unnecessary by the way, the primary key field will be used by default) is irrelevant. Then i tried this : >>> from DbDemo.models import Student_Info >>> list=Student_Info.objects.all() >>> obj=list[0] >>> obj >>> obj.GPA >>> obj.GPA Traceback (most recent call last): File "", line 1, in AttributeError: 'Student_Info' object has no attribute 'GPA' GPA isn't an attribute of a Student_Info, it's an Attribute of Academics. Student_Info has an associated academics object due to the OneToOne field in Academics, to access it's fields you need to specify that is where the field is: obj.academics.GPA The naming of the field used to access the "backwards" relationship is noted here: https://docs.djangoproject.com/en/dev/topics/db/queries/#one-to-one-relationships Then i tried >>> from DbDemo.models import Academics >>> list= Academics.objects.all() >>> obj=list[0] >>> obj >>> obj.E_mail Traceback (most recent call last): File "", line 1, in AttributeError: 'Academics' object has no attribute 'E_mail' E_mail is in the linked Student_Info object: obj.Roll_No.E_mail (this is why I mentioned Roll_No is probably not really what you want to name that field) >>> obj.Student_Info.GPA Traceback (most recent call last): File "", line 1, in AttributeError: 'Academics' object has no attribute 'Student_Info' GPA is directly in the Academics object: obj.GPA Linking two models via a ForeignKey or OneToOne field doesn't make all the attributes of one directly accessible in the other: you need to specify the relationship you want to follow in order to get at whatever attribute you are looking for. Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Need help writing join Django query for this simple model..
This is where using the related_name kwarg comes in. You can also use the default value, which in this case is academics_set. I see you made most of the recommended changes to your model definitions. I'd just like to reiterate two: Remove the underscore in your model name. Remove the 's' from Academics (it shouldn't be plural). -- 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.
dull look after install on ubuntu
django 1.3 on python 2.7.1 ubuntu 11.04 looking through firefox 4 Dull look, like all javascript has been removed On windows looks nice, but here all works, but no colors, no styles, nothing... What could it be? 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: dull look after install on ubuntu
Please read: https://code.djangoproject.com/wiki/UsingTheMailingList Especially this section: Prepare the question -- 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.
How to concatenate two variables in a template for evaluation..
hi I have been playing around with a certain scenario Consider the following {% for title in field %} {{obj}}{{.title}} {% endfor %} Here obj is an object and title are the various fields of that object. How can i evaluate the entire thing in a template Example I want it to end up like this {{obj.title}} How can i do that from my previous code.. Any suggestions would be appreciated... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Tutorial: New class based generic views
On 08/09/2011 03:33 PM, Juan Pablo Romero Méndez wrote: > Hey guys, > > This is the first part of a series of blog posts I'm writing about > class based generic views: > > http://pseudocorta.blogspot.com/2011/08/django-generic-views.html > > Cheers! > > Juan Pablo > Hi Juan, This blog looks interesting. I am curious about the next ones :-) . For people with little experience it might help a lot if you also add the import statements. I personally don't know for example by heart, where generic.CreateView is coming from. With many tutorials, blogs, code snippets I spent more time searching for the correct import than understanding the rest of the code. Experienced programmes wil know of course the which import to use, but the few addtional lines shouldn't really hurt them. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to concatenate two variables in a template for evaluation..
You have to write it as {{ obj.title }} in your template. Django templates are designed to allow very little in the way of logic; that should take place in your views. -- 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: dull look after install on ubuntu
On 08/09/2011 09:58 PM, Peter Kovgan wrote: > django 1.3 > on python 2.7.1 > ubuntu 11.04 > looking through firefox 4 > > Dull look, like all javascript has been removed > On windows looks nice, but here all works, but no colors, no styles, > nothing... > > What could it be? Well you don't really give a lot of info, so my guess might be completely wrong. Do you use the django development server ( manage.py runserver) or do you run with apache / some existing server? Did you run the command "manage.py collectstatic"? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
RE: How to concatenate two variables in a template for evaluation..
Okay then which way do u recommend that i should follow in case i need to displays objects with different no of properties Example obj has propA and PropB {{obj.propA}} {{obj.propB}} would work but i want it to be dynamic since the no and name of properties may vary.. I tried writing all the properties of an object in a list and passing that list obj to template but it seems this is not just possible.. since {% for prop in properties %} {{obj}}+{{.prop}} {% endfor %} or other things similar to above do not work Any suggestions.. > Date: Tue, 9 Aug 2011 17:25:42 -0400 > Subject: Re: How to concatenate two variables in a template for evaluation.. > From: sh...@milochik.com > To: django-users@googlegroups.com > > You have to write it as {{ obj.title }} in your template. Django > templates are designed to allow very little in the way of logic; that > should take place in your views. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Tutorial: New class based generic views
Thanks for the feedback Gelonida! 2011/8/9 Gelonida N : > On 08/09/2011 03:33 PM, Juan Pablo Romero Méndez wrote: >> Hey guys, >> >> This is the first part of a series of blog posts I'm writing about >> class based generic views: >> >> http://pseudocorta.blogspot.com/2011/08/django-generic-views.html >> >> Cheers! >> >> Juan Pablo >> > Hi Juan, > > This blog looks interesting. I am curious about the next ones :-) . > > For people with little experience it might help a lot if you also add > the import statements. > > I personally don't know for example by heart, where generic.CreateView > is coming from. > > With many tutorials, blogs, code snippets I spent more time searching > for the correct import than understanding the rest of the code. > Experienced programmes wil know of course the which import to use, but > the few addtional lines shouldn't really hurt them. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to order "links" in the Admin?
Hi, I'm testing Django for my first project using it. I have a model like this: from django.db import models import datetime class Directory(models.Model): website_name = models.CharField(max_length=200) website_url = models.CharField(max_length=200) website_position = models.IntegerField() pub_date = models.DateTimeField('date published') Basicaly this model is for storing URL's, but I need to order them, and for that I use "website_position" to control if the link will be at the top or at the end or in the middles... My question is, there is a better way to control the positions of the links? Django Admin have any feature that could help to deal with this specific case? Please let me know. Best 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to concatenate two variables in a template for evaluation..
On 9 août, 23:37, Hayyan Rafiq wrote: > Okay then which way do u recommend that i should follow in case > i need to displays objects with different no of properties > Example obj has propA and PropB > {{obj.propA}} > {{obj.propB}} > would work but i want it to be dynamic since the no and name of properties > may vary.. Then you need a custom template filter. Something like this should do the trick: # in your templatetags module: @register.filter def get_attribute(obj, name): return getattr(obj, name, u"") # in your template {% load youtemplatetags %} {% for attrname in attributes %} {{ obj|get_attribute:attrname }} {% endor %} -- 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.
Newbie: Help with validation
Hi all, I have a model snippet that I wanna use to store phonenumbers: e_mail = models.EmailField() phone = models.CharField(max_length=15) Mobile numbers in my country are 11digit numbers e.g 080, Fixed Lines: (2 digit),7 digit e.g (01)755 I wanna try and validate this field on a form, ensuring that info supplied is commensurate with above mentioned parameters: def clean_phone(self): if self.cleaned_data['phone'] : raise forms.ValidationError('Phone Number wrong.') return self.cleaned_data['phone'] Can anyone suggest a validation or regex pattern I can use? If there are other field types I wouldn't mind too; PhoneNumberField(django.contrib.localflavor) doesnt quite cut it for me. Regards Damola From: damola oyeniyi To: "django-users@googlegroups.com" Sent: Tuesday, August 9, 2011 2:57:36 PM Subject: Re: problem with django admin Hi all, Anybody know a good documentation or book that can help me with integrating google maps with my app? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to order "links" in the Admin?
you should figure out what it is based on to order these urls. i use time stamp to order them. 2011/8/10 Andre Lopes > Hi, > > I'm testing Django for my first project using it. > > I have a model like this: > > from django.db import models > import datetime > > class Directory(models.Model): > website_name = models.CharField(max_length=200) > website_url = models.CharField(max_length=200) > website_position = models.IntegerField() > pub_date = models.DateTimeField('date published') > > > Basicaly this model is for storing URL's, but I need to order them, > and for that I use "website_position" to control if the link will be > at the top or at the end or in the middles... > > My question is, there is a better way to control the positions of the > links? Django Admin have any feature that could help to deal with this > specific case? > > Please let me know. > > Best 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 > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: dull look after install on ubuntu
Thank you guys. I use development server of django(manage.py runserver). I created an app. from the official site of the django, this one of the first tutorial. I did it on windows installation. Then I came home, installed the same app on ubuntu. Now my conf is: > django 1.3 > on python 2.7.1 > ubuntu 11.04 > looking through firefox 4 and it stopped show "stattic content" HERE IS COLLECTSTATIC:: peter@peter-big:~/work/django/projects/src/mysite$ python manage.py collectstatic Traceback (most recent call last): File "manage.py", line 14, in execute_manager(settings) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 68, in load_command_class return module.Command() File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 41, in __init__ self.storage = get_storage_class(settings.STATICFILES_STORAGE)() File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/storage.py", line 23, in __init__ raise ImproperlyConfigured("You're using the staticfiles app " django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting. I tried to resolve it myself, but nothing has worked. I used answers to another threads, but probably my installation is somehow different. What exactly I specify in MEDIA_ROOT = ''" ? Thank you. On 10 August 2011 00:29, Gelonida N wrote: > On 08/09/2011 09:58 PM, Peter Kovgan wrote: > > django 1.3 > > on python 2.7.1 > > ubuntu 11.04 > > looking through firefox 4 > > > > Dull look, like all javascript has been removed > > On windows looks nice, but here all works, but no colors, no styles, > > nothing... > > > > What could it be? > > > Well you don't really give a lot of info, so my guess might be > completely wrong. > > > Do you use the django development server ( manage.py runserver) or do > you run with apache / some existing server? > > Did you run the command "manage.py collectstatic"? > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to prevent model formset from saving the empty forms?
I have a model formset that's displaying an extra form, but when I save I always get that form saved as an empty entry. How do I tell it not to save the model forms that I don't edit? It doesn't happen this way in the admin, does it? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ECwTMJjallYJ. 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: 'str' object has no attribute 'resolve' when access admin site
*bump* really need an answer for this. On Aug 9, 11:41 am, raj wrote: > I keep getting this error: > 'str' object has no attribute 'resolve' > > when trying to accessing the django admin site and I can't figure out > why. > I have apps within my project that have their own admin.py files. > Could this cause it? > here is my urls.py: > > from django.conf.urls.defaults import * > > import settings > > from django.contrib.auth.views import login, logout > > from views import index, simple, complex > > from django.views.generic.simple import direct_to_template > > # Uncomment the next two lines to enable the admin: > > from django.contrib import admin > > admin.autodiscover() > > urlpatterns = patterns('', > > # Example: > > # (r'^django_jchat/', include('django_jchat.foo.urls')), > > # Uncomment the admin/doc line below and add > 'django.contrib.admindocs' > > # to INSTALLED_APPS to enable admin documentation: > > (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > # Uncomment the next line to enable the admin: > (r'^admin/', include(admin.site.urls)), > ... > > and my admin site has been installed correctly in my settings.py file. > Help please. thank you. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to prevent model formset from saving the empty forms?
Ok, I figured out why, but I still don't know how to fix it. I set a dropdown to empty_label = None, which automatically selects the first element. I want that, but the form then thinks it has changed because the value in the list of initial values is empty for that field, and I can't see how to set the initial value for the forms in a model formset. Any suggestions? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/MEV63pXOvaIJ. 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: 'str' object has no attribute 'resolve' when access admin site
Hi, I have never met the same problem. And it would be better if you paste the traceback On Wed, Aug 10, 2011 at 11:56 AM, raj wrote: > *bump* really need an answer for this. > > On Aug 9, 11:41 am, raj wrote: > > I keep getting this error: > > 'str' object has no attribute 'resolve' > > > > when trying to accessing the django admin site and I can't figure out > > why. > > I have apps within my project that have their own admin.py files. > > Could this cause it? > > here is my urls.py: > > > > from django.conf.urls.defaults import * > > > > import settings > > > > from django.contrib.auth.views import login, logout > > > > from views import index, simple, complex > > > > from django.views.generic.simple import direct_to_template > > > > # Uncomment the next two lines to enable the admin: > > > > from django.contrib import admin > > > > admin.autodiscover() > > > > urlpatterns = patterns('', > > > > # Example: > > > > # (r'^django_jchat/', include('django_jchat.foo.urls')), > > > > # Uncomment the admin/doc line below and add > > 'django.contrib.admindocs' > > > > # to INSTALLED_APPS to enable admin documentation: > > > > (r'^admin/doc/', include('django.contrib.admindocs.urls')), > > > > # Uncomment the next line to enable the admin: > > (r'^admin/', include(admin.site.urls)), > > ... > > > > and my admin site has been installed correctly in my settings.py file. > > Help please. thank you. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to prevent model formset from saving the empty forms?
Nm, I got it -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/lYt3r0vdv4cJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to prevent model formset from saving the empty forms?
I just needed to retrieve the first pk value from the field's queryset in the init of the form and set the initial value there. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Nguop_mDqMgJ. 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: Using Form Elements Widgets direclty in HTML
You can have a look to the as_p method of django Form class and create your own renderer based on that. On Aug 9, 4:09 pm, Hayyan Rafiq wrote: > Could you please give an example.. say of a simple input box > in html its done like > > > How would i replace the default input box with the one from Django widgets?? > > Date: Tue, 9 Aug 2011 18:34:56 +0800 > Subject: Re: Using Form Elements Widgets direclty in HTML > From: changjia...@gmail.com > To: django-users@googlegroups.com > > Since you don't want to use forms class, you can write elements in your > templates directly. > > 2011/8/9 Hayyan Rafiq > > Hi I wanted to know if there was a way in which we could use widget directly > in an HTML file > By widget i mean elements of a form such as input boxes,calendars,Buttons etc > without using the forms class. > > For example A default normal html input box is : > > > I wanted to replace it with a fancier (more interesting and professional) > input box.. > any suggestions on how i could do that would be appreciated.. > > I also wanted to use a table in my HTML to display contents from my DB. Do > you guys have anything in mind which might be useful for me... > I currently am generating the table dynamically using tag > > -- > > 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 > athttp://groups.google.com/group/django-users?hl=en. > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is there a way to use a tree control in my template
What part are you missing? How to write the django template, how to access the data or the what is the related HTML? On Aug 8, 9:43 pm, Hayyan Rafiq wrote: > Hi i wanted to know is there a way through which i could use a tree control > in my template > I wanted to add something like > > Student > |_Name > |_Address > |_Contact No > > I think you guys get the picture...How can i add something like that in my > template...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: how to save inlines?
The django documentation about ModelAdmin.save_model seems to be what you look for. The example they give does almost what you want: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model On Aug 8, 11:32 pm, galgal wrote: > I need to override save method of inlines in admin. While saving photos, I > need to add user id to DB column. I cant make it in model because there is > no request data there. How can I do it in admin, to somehow get nad set user > id? -- 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: dull look after install on ubuntu
*please dump your *settings.py ?! On Wed, Aug 10, 2011 at 5:53 AM, Peter Kovgan wrote: > Thank you guys. > > I use development server of django(manage.py runserver). > > I created an app. from the official site of the django, this one of the > first tutorial. > > I did it on windows installation. > > Then I came home, installed the same app on ubuntu. > > Now my conf is: > > > django 1.3 > > on python 2.7.1 > > ubuntu 11.04 > > looking through firefox 4 > > and it stopped show "stattic content" > > HERE IS COLLECTSTATIC:: > > peter@peter-big:~/work/django/projects/src/mysite$ python manage.py > collectstatic > Traceback (most recent call last): > File "manage.py", line 14, in > execute_manager(settings) > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", > line 438, in execute_manager > utility.execute() > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", > line 379, in execute > self.fetch_command(subcommand).run_from_argv(self.argv) > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", > line 261, in fetch_command > klass = load_command_class(app_name, subcommand) > File > "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", > line 68, in load_command_class > return module.Command() > File > "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", > line 41, in __init__ > self.storage = get_storage_class(settings.STATICFILES_STORAGE)() > File > "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/storage.py", > line 23, in __init__ > raise ImproperlyConfigured("You're using the staticfiles app " > django.core.exceptions.ImproperlyConfigured: You're using the staticfiles > app without having set the STATIC_ROOT setting. > > I tried to resolve it myself, but nothing has worked. > > I used answers to another threads, but probably my installation is somehow > different. > > What exactly I specify in MEDIA_ROOT = ''" ? > > Thank you. > > > > > > > > > On 10 August 2011 00:29, Gelonida N wrote: > >> On 08/09/2011 09:58 PM, Peter Kovgan wrote: >> > django 1.3 >> > on python 2.7.1 >> > ubuntu 11.04 >> > looking through firefox 4 >> > >> > Dull look, like all javascript has been removed >> > On windows looks nice, but here all works, but no colors, no styles, >> > nothing... >> > >> > What could it be? >> >> >> Well you don't really give a lot of info, so my guess might be >> completely wrong. >> >> >> Do you use the django development server ( manage.py runserver) or do >> you run with apache / some existing server? >> >> Did you run the command "manage.py collectstatic"? >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Thanks and Regards, *Praveen Krishna R* -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.