Accessing related fields.
The more time I spend with django, the more problems pop up :) I dont fully understand how to access related fields between models. (FK or ManyToMany) Code: http://pastebin.com/qbciYqYw In code pasted below - {{p.souce.all}} returns source name but in that form: [], instead of "Google". Also I dont know how to access source.url. 1. {% for p in publisher.object_list %} 2. {{ p.date_added|date:"d-m-Y" }} r. 3. {{ p.source.all }} 4. 5. {{ p.type|title }} 6. {% endfor %} 7. Could you explain me how does that work? I couldn't figure it out only by documentation, I need some examples :) -- 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/-/PdHY4ccIaxcJ. 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: Accessing related fields.
On Sunday, 11 September 2011 08:23:16 UTC+1, Petey wrote: > > The more time I spend with django, the more problems pop up :) > > I dont fully understand how to access related fields between models. (FK or > ManyToMany) > Code: > http://pastebin.com/qbciYqYw > > In code pasted below - {{p.souce.all}} returns source name but in that > form: [], instead of "Google". > Also I dont know how to access source.url. > >1. {% for p in publisher.object_list %} >2. {{ p.date_added|date:"d-m-Y" }} r. >3. {{ p.source.all }} >4. >5. {{ p.type|title }} >6. {% endfor %} >7. > > Could you explain me how does that work? I couldn't figure it out only by > documentation, I need some examples :) > > It should be obvious that `p.source.all` returns *all* the related `source` objects - so it returns a Queryset, which is iterable. If you want to access the first item in the list, then you can slice it, like any other list. Because of the special syntax restrictions in templates, you can do `p.source.all.0` (rather than `p.source.all()[0]` which is what you would do in Python code). -- 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/-/YHk8pLktsO0J. 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: Implementing a List of Foreign Keys in a Model
On Sunday, 11 September 2011 00:18:28 UTC+1, Kurtis wrote: > > Hey Guys, > > I have a very simple stub of a project. I'm trying to do something > that should be very simple but isn't as easy as I hoped. > > I have a UserProfile class. This object is basically just an extension > of the standard User Class. Within my UserProfile class, I want to > have a list of PublicProfile foreign keys. PublicProfile itself is an > abstract class with multiple classes extending it. For example, a User > can create an ArtistProfile, a BandProfile, etc... > > To give you a sense of what I'm trying to accomplish from a user's > perspective: A user can sign up and create multiple Pages (represented > as PublicProfile) for bands, artists, etc... > > Sounds like you want [generic relations](https://docs.djangoproject.com/en/1.3/ref/contrib/contenttypes/#generic-relations). -- 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/-/MbkMEt65QFcJ. 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: Accessing related fields.
That worked but how do I acces other field called "url" which is in Category model? -- 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/-/1VxdFnovRNEJ. 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: Accessing related fields.
Why would it be any different? You have the same relationship between Publisher and Category as you do between Publisher and Source, so just do the same thing again. -- 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/-/M7xvU-4SbIUJ. 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: Accessing related fields.
And also how do I display more objets from that list? ;) Sorry for double post -- 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/-/FAgvFRzJpdIJ. 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: Accessing related fields.
Hi, as Daniel wrote, the {{ p.source.all }} is a queryset you can access the same way as in {% for p in publisher.object_list %}. So you create a nested for loop. Martin On Sun, 11 Sep 2011 10:38:39 +0200, Petey wrote: And also how do I display more objets from that list? ;) Sorry for double post -- 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: Accessing related fields.
Ooops I meant source ;) Firstly: {{ p.source.all.0 }} - < gets source name, only first element (as proper slice should work) but I still dont understand how to get all avaliable elements for each source in publisher Secondly: {{ p.source.url.all.0 }} < does not get URL from Source.url, I really need an example on accessing other fields -- 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/-/Jrmz-NhmBikJ. 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: Accessing related fields.
{{ p.source.all }} - is a list of source objects {{ p.source.all.0 }} - is the first item in the list of source objects (the same as p.source.all[0] in python) {{ p.source.all.0.some_attribute }} - you access some_attribute of the object source which is the first item in the list od source objects Martin On Sun, 11 Sep 2011 10:45:53 +0200, Petey wrote: Ooops I meant source ;) Firstly: {{ p.source.all.0 }} - < gets source name, only first element (as proper slice should work) but I still dont understand how to get all avaliable elements for each source in publisher Secondly: {{ p.source.url.all.0 }} < does not get URL from Source.url, I really need an example on accessing other fields -- 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: Accessing related fields.
Thank you Bruce and Daniel both anwsers really helped me. I really appreciate 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/-/LkInATAnM28J. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-registration + csrf token
On Fri, Sep 9, 2011 at 12:02 PM, Brett Hutley wrote: > You need to add it to the registration_form.html as well. > > Make sure you have 'django.middleware.csrf.CsrfViewMiddleware', in the > MIDDLEWARE_CLASSES tuple in the settings.py file. > > Cheers, Brett > > On 9 Sep 2011, at 16:47, nicolas HERSOG wrote: > >> Hi All ! >> >> Do any of you use this app >> https://bitbucket.org/ubernostrum/django-registration/overview with the csrf >> middleware ? >> >> Instead of re-write myself the registar, check via email, lost password, >> login and co i tried to use this app, but it don't work and i have this >> message : >> Forbidden (403) >> CSRF verification failed. Request aborted. >> >> I added to the login form {{ csrf_token }} but it's seems that it is not >> implemented, >> >> any ideas ? >> >> Thanks for all :) Instead of: {{ csrf_token }} try: {% csrf_token %} -- 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.
order by + group by
Hi! How can I express this SQL query SELECT ... FROM ( SELECT ... FROM ... ) in the ORM? Specifically, I want to express SELECT ... FROM ( SELECT ... FROM app_model ORDER BY field1 ) GROUP BY field2 Is it possible without writing SQL by hand? Thanks, Jonas -- Django + MongoDB: http://django-mongodb.org -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Multitenant in Django
在什么地方举行呢? -- 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: Login based in url for user
*You can filter the objects based on user. Which means you can include a ForeignKey to User model in your models, and save the logged in user while saving the model. In the views, while displaying, you can filter based on the logged-in user. So no other user get to see your objects * On Tue, Aug 30, 2011 at 11:57 PM, Carsten Jantzen wrote: > Hej I am new and trying to make a login for mysite. > I have written a basic login which validates against another site and > is working fine atm. > > I would like to make the auth related to the url. > So that user a with permission 1 can access www.test.dk/1/content but > he is not allowed to access www.test.dk/2/content > user 2 with permission 4 can access www.test.dk/4/content but he is > not allowed to access www.test.dk/1/content > > It there a good way to solved this? > > Is it possible extend the or use the @login_required tag to this solution. > > Hope for some input so I can find a solution. > > Regards > Carsten > > -- > 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.
Getting a class using a variable name.
Hi, I have been struggling with this for a while now and I can't seem to find a way of returning a class object from a different module without importing it. Say I have two files: test_a.py class A(models.Model): pass test_b.py class B(models.Model): def get_a_class(self): return ? to get the A class from test_a.py I do not want to import it as it will cause circular references. 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: Multitenant in Django
2011/9/9 sjtirtha > But I cannot set the SITE_ID in the settings.py right? > Because if one user set the SITE_ID = 1, then parallel another user > can set the SITE_ID = 2. > Because we only have one instance. > Right, but AFAIK if you don't use threads you shouldn't have any problem. We have been using the middleware hack with Django 1.2.6 from more than one year. The midleware run first and set settings.SITE_ID according to the current site, something like http://dpaste.com/612953/ Currently running nginx + uwsgi but we used mod_wsgi for the last couple of months. -- Alessandro Pasotti w3: www.itopen.it -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Getting a class using a variable name.
I should add that in the B class function get_a_class I only have a variable name "A" -- 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: Getting a class using a variable name.
Hi, you can do the import here to prevent circular import: class B(models.Model): def get_a_class(self): from test_a import A return A Martin On Sun, 11 Sep 2011 16:49:22 +0200, pbzRPA wrote: Hi, I have been struggling with this for a while now and I can't seem to find a way of returning a class object from a different module without importing it. Say I have two files: test_a.py class A(models.Model): pass test_b.py class B(models.Model): def get_a_class(self): return ? to get the A class from test_a.py I do not want to import it as it will cause circular references. 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: Getting a class using a variable name.
Hi Martin, Thanks for the tip. The thing is that I store my class names in the database. So class B(models.Mode): form_class = models.CharField(...) def get_form_class(self): return ..(self.form_class) <- this is where I need to some how get the class object from a different file. I know I could use globals()[self.form_class] if the class was in the same file but the classes are in various modules. -- 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: Getting a class using a variable name.
Ok, I found a way. I don't know if it's the best way but it works :) return getattr(__import__(module_name, fromlist = [class_name]), class_name) Thanks for the help. -- 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.
two views in one url
Hello all I have two views in two app and I want to get them in main url file how I Can do that ? first view in project/app_news/views.py def article_index(request): return render_to_response('news/index.html', { 'news_slide': Article.objects.filter(status=1, statusslide=1)[:6], 'section_list' : Section.objects.all(), 'last_lib' : Library.objects.all()[:3], }, context_instance=RequestContext(request) ) secend view in project/app_poll/views.py def questionlast(request): try: question = Question.objects.order_by('id').reverse()[0] except ObjectDoesNotExist, e: raise Http404 if request.method == 'POST': try: last_choice_id = request.session[question.id] last_choice = Choice.objects.get(id = last_choice_id) last_choice.total_votes -= 1 last_choice.save() except KeyError, e: pass choice_id = int(request.POST['choices']) choice = Choice.objects.get(id = choice_id) choice.total_votes += 1 choice.save() request.session[question.id] = choice.id return HttpResponseRedirect(question.get_results_url()) if request.method == 'GET': try: last_choice_id = request.session[question.id] last_choice = Choice.objects.get(id = last_choice_id) except KeyError, e: last_choice = 0 choices = Choice.objects.filter(question = question) payload = {'question':question, 'choices':choices, 'last_choice':last_choice} return render('news/index.html', payload, request) I want get both views in one template In news/index.html IWant get poll in index 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: two views in one url
Hi cha, Programming in django is just programming in python. Views are just normal python functions that are called from urls.py which contains pattern which is also a function. If you want both views in one file, do exactly that. You could cut and paste the view in the second app and paste it in the first apps view then adjust the pattern in your urls.py file. Or better still you could create a new file and cut and paste the functions in the first and second view into that new file and make the adjustment in your urls.py file. If you still don't understand the explanation you could copy and paste the your urls file here or someone might be able to provide a link to some resource on the web. You need to be comfortable with programming with python for you to get the hang of django. On 9/11/11, cha wrote: > Hello all I have two views in two app and I want to get them in main > url file how I Can do that ? > > first view in project/app_news/views.py > > def article_index(request): > return render_to_response('news/index.html', { > 'news_slide': Article.objects.filter(status=1, > statusslide=1)[:6], > 'section_list' : Section.objects.all(), > 'last_lib' : Library.objects.all()[:3], > }, > context_instance=RequestContext(request) > ) > > secend view in project/app_poll/views.py > > def questionlast(request): > try: > question = Question.objects.order_by('id').reverse()[0] > except ObjectDoesNotExist, e: > raise Http404 > if request.method == 'POST': > try: > last_choice_id = request.session[question.id] > last_choice = Choice.objects.get(id = last_choice_id) > last_choice.total_votes -= 1 > last_choice.save() > except KeyError, e: > pass > choice_id = int(request.POST['choices']) > choice = Choice.objects.get(id = choice_id) > choice.total_votes += 1 > choice.save() > request.session[question.id] = choice.id > return HttpResponseRedirect(question.get_results_url()) > if request.method == 'GET': > try: > last_choice_id = request.session[question.id] > last_choice = Choice.objects.get(id = last_choice_id) > except KeyError, e: > last_choice = 0 > choices = Choice.objects.filter(question = question) > payload = {'question':question, 'choices':choices, > 'last_choice':last_choice} > > return render('news/index.html', payload, request) > > I want get both views in one template In news/index.html IWant get > poll in index 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. > > -- Sent from my mobile device -- 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: two views in one url
You may merge the code in views.py and use 1 url for them. You could use TemplateView() instead of render to response -- 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/-/90Fd_SWYciQJ. 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.
When is it useful to run multiple admin sites?
I know you can run multiple admin sites, but the only reason I can see for doing it is to have a full admin and other customized admin sites for different types of users. This is possibly even a stretch, and really just a guess. What are some of the use cases for multiple admin sites? -- 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/-/CD_W0_AII9AJ. 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: When is it useful to run multiple admin sites?
I've done this for a multitenant project where we wanted each tenant to have their own admin site with just their own data filtered, as well as a central admin where senior staff could manage all tenants' data. It's also handy if you want different interfaces (custom forms, read-only or excluded fields, instructions, etc) instead of just different permissions for different users. On Sep 11, 3:13 pm, Joshua Russo wrote: > I know you can run multiple admin sites, but the only reason I can see for > doing it is to have a full admin and other customized admin sites for > different types of users. This is possibly even a stretch, and really just a > guess. > > What are some of the use cases for multiple admin sites? -- 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: two views in one url
thank you very much Babatunde Akinyanmi & petey Im merge the code and its work Mr Babatunde Akinyanmi acutely I need be comfortable with programming with python But I dont Know How to do that can you help me and give me the best way to be comfortable and professional programmer -- 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 at activating the admin site (Django tutorial part 2)
Hi Babatunde, 1. sorry for the delayed answer - but I was in the last three weeks far from any possibility to use the Internet (and Django as well)... 2. I have tried to reproduce the phenomenon and with the 'Pászkán Attila' as user it worked ! Why? - still it isn't clear. PA On Aug 26, 12:20 am, Babatunde Akinyanmi wrote: > Cool. I'm really interested in finding out what went wrong. If you are > also, try to recreate the problem by using you former username and see > if the problem persists. If it does, its a bug that the community > could consider fixing. That error was thrown by the Site app so I'm > still wondering how a change in user name was able to solve it > > On 8/25/11, pasztilla wrote: > > > > > Hi Babatunde, > > > Hi Babatunde, > > > SITE_ID == 1 > > > then I did what you've suggested:(see the result) > > > Microsoft Windows [verziószám: 6.1.7601] > > > Copyright (c) 2009 Microsoft Corporation. > > Minden jog fenntartva. > > > C:\Users\Pászkán Attila> > > > D:\>cd Atilla\Programoz\Django\Gyakorlaas\mysite > > > D:\Atilla\Programoz\Django\Gyakorlaas\mysite>python manage.py shell > > > Python 2.7.1 (r271:86832, Feb 7 2011, 11:30:38)[MSC v.1500 32 bit > > (Intel)] on win32 > > > Type "help", "copyright", "credits" or "license" for more information. > > (InteractiveConsole) > > from django.contrib.sites.models import Site > > Site.objects.get(id=1) > > > Traceback (most recent call last): > > > File "", line 1, in > > > File "D:\Python27\lib\site-packages\django\db\models\manager.py", > > line 132, in get > > > return self.get_query_set().get(*args, **kwargs) > > > File "D:\Python27\lib\site-packages\django\db\models\query.py", line > > 349, in get > > > % self.model._meta.object_name) > > > DoesNotExist: Site matching query does not exist. > > > + > > > Meanwhile came an idea that this error could have slyly, > > somehow undercover, something to do with my User Name (under Windows) > > which contains some unusual characters (two á-s, see above) ... > > I've set up a new user (without unusual characters) > > and repeated the whole procedure (building up an application > > according to the tutorial) and it worked fine!!! :-) > > > So, seemingly the problem has been resolved! :-) > > (It would be interesting to find out why and how > > has influenced that unusual user name the functioning > > of my admin-site...but it is maybee to much effort to investigate) > > > Anyway, thanks for your efforts and support! > > > PA > > > On aug. 25, 19:28, Babatunde Akinyanmi wrote: > >> Hi paszkan, > >> First I want you to go to your settings file and tell me what value is > >> specified for SITE_ID. You will need that value for the next step. > > >> In your terminal where you would have typed "python manage.py > >> runserver" type "python manage.py shell" > > >> Doing that would load django's inbuilt shell. > > >> Next type: > >> "from django.contrib.sites.models import Site" > >> If there's no error type this is where you would need the SITE_ID > >> setting value. Assuming SITE_ID value is 1 then type: > >> "Site.objects.get(id=1)" > > >> Do this and give feed back > > >> On 8/25/11, Pászkán Attila wrote: > > >> > Can you give more details? > > >> > 2011/8/25 Babatunde Akinyanmi > > >> >> The error you stated normally happens when there are problems with the > >> >> django_site table created when you start a project. > > >> >> On 8/25/11, Babatunde Akinyanmi wrote: > >> >> > Please say exactly what you did. It will be easier to help that way > > >> >> > On 8/25/11, raj wrote: > >> >> >> In ur urls.py, > >> >> >> Did u import admin, make it discoverable, and also uncomment the / > >> >> >> admin/ url? > >> >> >> Also, make sure that you syncdb by running python manage.py syncdb. > >> >> >> Lemme know if that helps :) > >> >> >> On Aug 25, 9:29 am, pasztilla wrote: > >> >> >>> Hi there, > >> >> >>> I'm just trying to accomodate myself with Django - and so I tried > >> >> >>> to > >> >> >>> go through the Django Tutorial from the Django official site. There > >> >> >>> went everything ok with part 1, but at the very beginning of the > >> >> >>> part > >> >> >>> 2 I've met a problem(https://docs.djangoproject.com/en/1.3/intro/ > >> >> >>> tutorial02). In spite of that I've perform all settings/changes > >> >> >>> described in the 'Activate the admin site' section going to the > >> >> >>> next > >> >> >>> section 'Start the development server' (ie. 127.0.0.1:8000/admin/) > >> >> >>> led > >> >> >>> merely to an error message: > > >> >> >>> "DoesNotExist at /admin/ > >> >> >>> Site matching query does not exist. > >> >> >>> Request Method: > >> >> >>> GET > >> >> >>> Request URL:http://127.0.0.1:8000/admin/ > >> >> >>> Django Version: > >> >> >>> 1.3 > > >> >> >>> Exception Type: > >> >> >>> DoesNotExist > > >> >> >>> Exception Value: > >> >> >>> Site matching query does not exist. > > >> >> >>> Exception Location: > > >> >> >>> D:\Python27\lib\site-packages\djan
Re: When is it useful to run multiple admin sites?
Where can I find any info about hot to run 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/-/s5twxCSBgDMJ. 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: When is it useful to run multiple admin sites?
That makes sense. Thanks -- 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/-/Hz0DW_-dSwAJ. 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: newbie question on activating the automatic admin
ok, i am planning to remove all traces of all django installations from my system, and re-install the dev version (and if that still does not work 3.1) under virtualenv. Will repost here if I still see problems. Nara On Sep 10, 7:16 pm, Babatunde Akinyanmi wrote: > Hi nara, > Please post the debug output you get when you try to view the admin > page from your browser. > > Meanwhile, while switching versions of django, you have to make sure > you remove completely every file from the old version. Failure to do > that will break django. > > On 9/10/11, nara wrote: > > > > > > > > > > > ok, I switched to the 1.3.1 released version of Django, and > > also tried Python2.6 instead of Python2.7 on the dev version > > of Django. Things are still majorly broken, see the following > > in the django shell on a fresh startproject, I could not > > import even the top level django module. Then, > > I set PYTHONPATH to /home/nara/Django1.3/django, > > and after that, in the shell, I am still unable to > > directly import the admin module, I have to do this: > > import django > import django.contrib > import django.contrib.admin > > > So, the problem is not just in the admin module, it > > is likely all over the place (entire django module hierarchy). > > > Oh well, looks like I have to cool this off for a while. > > > Thanks for everyone's help. > > Nara > > > On Sep 10, 2:17 pm, nara wrote: > >> I'll get through this yet :) > > >> I tried the commands you have under the django shell, and I got > >> 'example.com' > >> on the django.Site query, and not an error. Also, interestingly, > >> within the shell, I don't see > >> django on the sys.path at all (shown below), but I do see my project > >> mblog. This could > >> be the cause of not seeing the admin. I could switch to python 2.6 > >> instead > >> of python 2.7, but I doubt that that is going fix this issue. Dropping > >> my project > >> table and doing a new syncdb did not help either. > > >> Here is the path, prettified: > > >> ['/home/nara/dj/mblog' > >> '/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg' > >> '/usr/local/lib/python2.7/dist-packages/grin-1.2.1-py2.7.egg' > >> '/usr/local/lib/python2.7/dist-packages/pip-1.0.2-py2.7.egg' > >> '/usr/lib/python2.7' > >> '/usr/lib/python2.7/plat-linux2' > >> '/usr/lib/python2.7/lib-tk' > >> '/usr/lib/python2.7/lib-old' > >> '/usr/lib/python2.7/lib-dynload' > >> '/usr/local/lib/python2.7/dist-packages' > >> '/usr/lib/python2.7/dist-packages' > >> '/usr/lib/python2.7/dist-packages/PIL' > >> '/usr/lib/pymodules/python2.7/gtk-2.0' > >> '/usr/lib/python2.7/dist-packages/gst-0.10' > >> '/usr/lib/python2.7/dist-packages/gtk-2.0' > >> '/usr/lib/pymodules/python2.7' > >> '/usr/lib/pymodules/python2.7/ubuntuone-control-panel' > >> '/usr/lib/pymodules/python2.7/libubuntuone' > >> '/usr/lib/pymodules/python2.7/ubuntuone-storage-protocol' > >> '/usr/lib/pymodules/python2.7/ubuntuone-client'] > > >> Thanks > >> Nara > > >> On Sep 9, 9:56 pm, Babatunde Akinyanmi wrote: > > >> > Hi nara, > >> > This error is normally thrown when the sites app is being used in a > >> > django project. I think it can also occur if the sites tables in the > >> > database is not properly created during django-admin startproject. > >> > Someone else reported that he was able to solve the problem by using a > >> > user name without special characters. > > >> > This might be difficult to debug since you are using a development > >> > version however: > >> > 1. Go to the inbuilt django shell and enter these commands: > >> > from django.contrib.sites.models import Site > >> > From django.conf import settings > >> > x = settings.SITE_ID > >> > Site.objects.get(pk=x) > > >> > You should get the same "site matching query does not exist" error. > >> > Now print x and then check the django_site_table in your database. x > >> > should be the same as the primary key of what you have in the table. > >> > If it isn't, drop the table and syncdb again. > > >> > On 9/10/11, nara wrote: > > >> > > yes, admin is in INSTALLED_APPS. BTW, the basic site works fine if I > >> > > turn > >> > > off all admin. admin is not strictly necessary, it is just a nicety. > > >> > > One strange thing though: I have had to set PYTHONPATH and > >> > > explicitly set it to ~/mblog:~/mblog/apps:~/mblog/apps/myblog, > >> > > even though __init__.py files exist at all levels! Could > >> > > something as basic as Python module search be broken? > >> > > I am using latest Python 2.7 on Ubuntu 11.04 > > >> > > Thanks > >> > > Nara > > >> > > On Sep 9, 5:35 pm, Casey Greene wrote: > >> > >> Is admin in INSTALLED_APPS? > > >> > >>https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-INSTA... > > >> > >> Casey > > >> > >> On 09/09/2011 07:04 PM, nara wrote: > > >> > >> > Hi, > > >> > >> > I am a newbie, and I am trying a very basic blog site to get > >> > >> > familiar > >> > >> > with the latest development release. I followed the di
Re: Admin Site appending letter "s" to end of each model\table name
On Sat, Sep 10, 2011 at 11:06 PM, Shawn Milochik wrote: > The way you were doing it makes perfect sense if you have experience > creating database tables by hand, the way most people do for their PHP and > ASP apps. Django's ORM is doing all the same stuff underneath, but it > provides a level of abstraction that makes it (much) easier to do common > things, and it's a bit different than the "old way." AFAICT, most SQL database design texts advice on using singular nouns for table names. ORMs inherited that practice. of course, as a newbie, I also made the mistake of using plural names very often, until I found that advice; and I can say that it really sounds better after a while. -- Javier -- 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 at activating the admin site (Django tutorial part 2)
It isn't clear to me also. Initially I was surprised because the site app doesn't have any dependency on django's user system. Even if it does, django uses unicode which caters for those characters in your name. Well.at least we are sure the problem wsnt from the user name. But something definetely went wrong. Don't worry about it though On 9/11/11, pasztilla wrote: > Hi Babatunde, > > 1. sorry for the delayed answer - but I was in the last three weeks > far from any possibility to use the Internet (and Django as well)... > 2. I have tried to reproduce the phenomenon and with the 'Pászkán > Attila' as user it worked ! Why? - still it isn't clear. > > PA > > On Aug 26, 12:20 am, Babatunde Akinyanmi wrote: >> Cool. I'm really interested in finding out what went wrong. If you are >> also, try to recreate the problem by using you former username and see >> if the problem persists. If it does, its a bug that the community >> could consider fixing. That error was thrown by the Site app so I'm >> still wondering how a change in user name was able to solve it >> >> On 8/25/11, pasztilla wrote: >> >> >> >> > Hi Babatunde, >> >> > Hi Babatunde, >> >> > SITE_ID == 1 >> >> > then I did what you've suggested:(see the result) >> >> > Microsoft Windows [verziószám: 6.1.7601] >> >> > Copyright (c) 2009 Microsoft Corporation. >> > Minden jog fenntartva. >> >> > C:\Users\Pászkán Attila> >> >> > D:\>cd Atilla\Programoz\Django\Gyakorlaas\mysite >> >> > D:\Atilla\Programoz\Django\Gyakorlaas\mysite>python manage.py shell >> >> > Python 2.7.1 (r271:86832, Feb 7 2011, 11:30:38)[MSC v.1500 32 bit >> > (Intel)] on win32 >> >> > Type "help", "copyright", "credits" or "license" for more information. >> > (InteractiveConsole) >> >> from django.contrib.sites.models import Site >> >> Site.objects.get(id=1) >> >> > Traceback (most recent call last): >> >> > File "", line 1, in >> >> > File "D:\Python27\lib\site-packages\django\db\models\manager.py", >> > line 132, in get >> >> > return self.get_query_set().get(*args, **kwargs) >> >> > File "D:\Python27\lib\site-packages\django\db\models\query.py", line >> > 349, in get >> >> > % self.model._meta.object_name) >> >> > DoesNotExist: Site matching query does not exist. >> >> > + >> >> > Meanwhile came an idea that this error could have slyly, >> > somehow undercover, something to do with my User Name (under Windows) >> > which contains some unusual characters (two á-s, see above) ... >> > I've set up a new user (without unusual characters) >> > and repeated the whole procedure (building up an application >> > according to the tutorial) and it worked fine!!! :-) >> >> > So, seemingly the problem has been resolved! :-) >> > (It would be interesting to find out why and how >> > has influenced that unusual user name the functioning >> > of my admin-site...but it is maybee to much effort to investigate) >> >> > Anyway, thanks for your efforts and support! >> >> > PA >> >> > On aug. 25, 19:28, Babatunde Akinyanmi wrote: >> >> Hi paszkan, >> >> First I want you to go to your settings file and tell me what value is >> >> specified for SITE_ID. You will need that value for the next step. >> >> >> In your terminal where you would have typed "python manage.py >> >> runserver" type "python manage.py shell" >> >> >> Doing that would load django's inbuilt shell. >> >> >> Next type: >> >> "from django.contrib.sites.models import Site" >> >> If there's no error type this is where you would need the SITE_ID >> >> setting value. Assuming SITE_ID value is 1 then type: >> >> "Site.objects.get(id=1)" >> >> >> Do this and give feed back >> >> >> On 8/25/11, Pászkán Attila wrote: >> >> >> > Can you give more details? >> >> >> > 2011/8/25 Babatunde Akinyanmi >> >> >> >> The error you stated normally happens when there are problems with >> >> >> the >> >> >> django_site table created when you start a project. >> >> >> >> On 8/25/11, Babatunde Akinyanmi wrote: >> >> >> > Please say exactly what you did. It will be easier to help that >> >> >> > way >> >> >> >> > On 8/25/11, raj wrote: >> >> >> >> In ur urls.py, >> >> >> >> Did u import admin, make it discoverable, and also uncomment the >> >> >> >> / >> >> >> >> admin/ url? >> >> >> >> Also, make sure that you syncdb by running python manage.py >> >> >> >> syncdb. >> >> >> >> Lemme know if that helps :) >> >> >> >> On Aug 25, 9:29 am, pasztilla wrote: >> >> >> >>> Hi there, >> >> >> >>> I'm just trying to accomodate myself with Django - and so I >> >> >> >>> tried >> >> >> >>> to >> >> >> >>> go through the Django Tutorial from the Django official site. >> >> >> >>> There >> >> >> >>> went everything ok with part 1, but at the very beginning of >> >> >> >>> the >> >> >> >>> part >> >> >> >>> 2 I've met a >> >> >> >>> problem(https://docs.djangoproject.com/en/1.3/intro/ >> >> >> >>> tutorial02). In spite of that I've perform all settings/changes >> >> >> >>> described in the 'Activate the admin site' section go
Re: two views in one url
This is way off topic for this group but.. To be comfortable with python, the online python documentation is a very good resource. It seems like you're a programming noob so also get books like pragmatic programmer and Python The Hard Way. Of course there are many more good books on python programming but nobody learns how to swim by reading books. In other words, the singular act that will make you a better programmer is doing more programming. You can also check github and the likes so you can read other people's code and maybe improve them. On 9/11/11, cha wrote: > thank you very much > Babatunde Akinyanmi & petey > Im merge the code and its work > > Mr Babatunde Akinyanmi > acutely I need be comfortable with programming with python > But I dont Know How to do that > can you help me and give me the best way to be comfortable and > professional programmer > > -- > 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. > > -- Sent from my mobile device -- 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: newbie question on activating the automatic admin
And reply here if you don't see problems :) On 9/12/11, nara wrote: > ok, i am planning to remove all traces of all django installations > from my > system, and re-install the dev version (and if that still does not > work 3.1) > under virtualenv. > > Will repost here if I still see problems. > > Nara > > On Sep 10, 7:16 pm, Babatunde Akinyanmi wrote: >> Hi nara, >> Please post the debug output you get when you try to view the admin >> page from your browser. >> >> Meanwhile, while switching versions of django, you have to make sure >> you remove completely every file from the old version. Failure to do >> that will break django. >> >> On 9/10/11, nara wrote: >> >> >> >> >> >> >> >> >> >> > ok, I switched to the 1.3.1 released version of Django, and >> > also tried Python2.6 instead of Python2.7 on the dev version >> > of Django. Things are still majorly broken, see the following >> > in the django shell on a fresh startproject, I could not >> > import even the top level django module. Then, >> > I set PYTHONPATH to /home/nara/Django1.3/django, >> > and after that, in the shell, I am still unable to >> > directly import the admin module, I have to do this: >> >> import django >> import django.contrib >> import django.contrib.admin >> >> > So, the problem is not just in the admin module, it >> > is likely all over the place (entire django module hierarchy). >> >> > Oh well, looks like I have to cool this off for a while. >> >> > Thanks for everyone's help. >> > Nara >> >> > On Sep 10, 2:17 pm, nara wrote: >> >> I'll get through this yet :) >> >> >> I tried the commands you have under the django shell, and I got >> >> 'example.com' >> >> on the django.Site query, and not an error. Also, interestingly, >> >> within the shell, I don't see >> >> django on the sys.path at all (shown below), but I do see my project >> >> mblog. This could >> >> be the cause of not seeing the admin. I could switch to python 2.6 >> >> instead >> >> of python 2.7, but I doubt that that is going fix this issue. Dropping >> >> my project >> >> table and doing a new syncdb did not help either. >> >> >> Here is the path, prettified: >> >> >> ['/home/nara/dj/mblog' >> >> '/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg' >> >> '/usr/local/lib/python2.7/dist-packages/grin-1.2.1-py2.7.egg' >> >> '/usr/local/lib/python2.7/dist-packages/pip-1.0.2-py2.7.egg' >> >> '/usr/lib/python2.7' >> >> '/usr/lib/python2.7/plat-linux2' >> >> '/usr/lib/python2.7/lib-tk' >> >> '/usr/lib/python2.7/lib-old' >> >> '/usr/lib/python2.7/lib-dynload' >> >> '/usr/local/lib/python2.7/dist-packages' >> >> '/usr/lib/python2.7/dist-packages' >> >> '/usr/lib/python2.7/dist-packages/PIL' >> >> '/usr/lib/pymodules/python2.7/gtk-2.0' >> >> '/usr/lib/python2.7/dist-packages/gst-0.10' >> >> '/usr/lib/python2.7/dist-packages/gtk-2.0' >> >> '/usr/lib/pymodules/python2.7' >> >> '/usr/lib/pymodules/python2.7/ubuntuone-control-panel' >> >> '/usr/lib/pymodules/python2.7/libubuntuone' >> >> '/usr/lib/pymodules/python2.7/ubuntuone-storage-protocol' >> >> '/usr/lib/pymodules/python2.7/ubuntuone-client'] >> >> >> Thanks >> >> Nara >> >> >> On Sep 9, 9:56 pm, Babatunde Akinyanmi wrote: >> >> >> > Hi nara, >> >> > This error is normally thrown when the sites app is being used in a >> >> > django project. I think it can also occur if the sites tables in the >> >> > database is not properly created during django-admin startproject. >> >> > Someone else reported that he was able to solve the problem by using >> >> > a >> >> > user name without special characters. >> >> >> > This might be difficult to debug since you are using a development >> >> > version however: >> >> > 1. Go to the inbuilt django shell and enter these commands: >> >> > from django.contrib.sites.models import Site >> >> > From django.conf import settings >> >> > x = settings.SITE_ID >> >> > Site.objects.get(pk=x) >> >> >> > You should get the same "site matching query does not exist" error. >> >> > Now print x and then check the django_site_table in your database. x >> >> > should be the same as the primary key of what you have in the table. >> >> > If it isn't, drop the table and syncdb again. >> >> >> > On 9/10/11, nara wrote: >> >> >> > > yes, admin is in INSTALLED_APPS. BTW, the basic site works fine if >> >> > > I >> >> > > turn >> >> > > off all admin. admin is not strictly necessary, it is just a >> >> > > nicety. >> >> >> > > One strange thing though: I have had to set PYTHONPATH and >> >> > > explicitly set it to ~/mblog:~/mblog/apps:~/mblog/apps/myblog, >> >> > > even though __init__.py files exist at all levels! Could >> >> > > something as basic as Python module search be broken? >> >> > > I am using latest Python 2.7 on Ubuntu 11.04 >> >> >> > > Thanks >> >> > > Nara >> >> >> > > On Sep 9, 5:35 pm, Casey Greene wrote: >> >> > >> Is admin in INSTALLED_APPS? >> >> >> > >>https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-INSTA...
Re: sitemap
Thank You very much! -- 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/-/MUltEa4dGogJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-registration + csrf token
omg, I'm so ashamed... I use {% csrf_token %} and it works, Thx :) Nicolas On Sun, Sep 11, 2011 at 2:52 PM, DrBloodmoney wrote: > On Fri, Sep 9, 2011 at 12:02 PM, Brett Hutley wrote: > > You need to add it to the registration_form.html as well. > > > > Make sure you have 'django.middleware.csrf.CsrfViewMiddleware', in the > MIDDLEWARE_CLASSES tuple in the settings.py file. > > > > Cheers, Brett > > > > On 9 Sep 2011, at 16:47, nicolas HERSOG wrote: > > > >> Hi All ! > >> > >> Do any of you use this app > https://bitbucket.org/ubernostrum/django-registration/overview with the > csrf middleware ? > >> > >> Instead of re-write myself the registar, check via email, lost password, > login and co i tried to use this app, but it don't work and i have this > message : > >> Forbidden (403) > >> CSRF verification failed. Request aborted. > >> > >> I added to the login form {{ csrf_token }} but it's seems that it is not > implemented, > >> > >> any ideas ? > >> > >> Thanks for all :) > > Instead of: > {{ csrf_token }} > > try: > {% csrf_token %} > > -- > 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.