Search Results

Search found 4921 results on 197 pages for 'django transactions'.

Page 12/197 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Disabling email-style usernames in Django 1.2 with django-registration

    - by shacker
    Django 1.2 allows usernames to take the form of an email address. Changed in Django 1.2: Usernames may now contain @, +, . and - characters I know that's a much-requested feature, but what if you don't want the new behavior? It makes for messy usernames in profile URLs and seems to break django-registration (if a user registers an account with an email-style username, the link in the django-registration activation email returns 404). Does anyone have a recipe for restoring the old behavior and disabling email-style usernames?

    Read the article

  • Does Django cache url regex patterns somehow?

    - by Emre Sevinç
    I'm a Django newbie who needs help: Even though I change some urls in my urls.py I keep on getting the same error message from Django. Here is the relevant line from my settings.py: ROOT_URLCONF = 'mydjango.urls' Here is my urls.py: from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^mydjango/', include('mydjango.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)), # (r'^polls/', include('mydjango.polls.urls')), (r'^$', 'mydjango.polls.views.homepage'), (r'^polls/$', 'mydjango.polls.views.index'), (r'^polls/(?P<poll_id>\d+)/$', 'mydjango.polls.views.detail'), (r'^polls/(?P<poll_id>\d+)/results/$', 'mydjango.polls.views.results'), (r'^polls/(?P<poll_id>\d+)/vote/$', 'mydjango.polls.views.vote'), (r'^polls/randomTest1/', 'mydjango.polls.views.randomTest1'), (r'^admin/', include(admin.site.urls)), ) So I expect that whenever I visit http://mydjango.yafz.org/polls/randomTest1/ the mydjango.polls.views.randomTest1 function should run because in my polls/views.py I have the relevant function: def randomTest1(request): # mainText = request.POST['mainText'] return HttpResponse("Default random test") However I keep on getting the following error message: Page not found (404) Request Method: GET Request URL: http://mydjango.yafz.org/polls/randomTest1 Using the URLconf defined in mydjango.urls, Django tried these URL patterns, in this order: 1. ^$ 2. ^polls/$ 3. ^polls/(?P<poll_id>\d+)/$ 4. ^polls/(?P<poll_id>\d+)/results/$ 5. ^polls/(?P<poll_id>\d+)/vote/$ 6. ^admin/ 7. ^polls/randomTest/$ The current URL, polls/randomTest1, didn't match any of these. I'm surprised because again and again I check urls.py and there is no ^polls/randomTest/$ in it, but there is ^polls/randomTest1/' It seems like Django is somehow storing the previous contents of urls.py and I just don't know how to make my latest changes effective. Any ideas? Why do I keep on seeing some old version of regexes when I try to load that page even though I changed my urls.py?

    Read the article

  • force delete row on django app after migration

    - by unsorted
    After a migration with south, I ended up deleting a column. Now the current data in one of my tables is screwed up and I want to delete it, but attempts to delete just result in an error: >>> d = Degree.objects.all() >>> d.delete() Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Python26\lib\site-packages\django\db\models\query.py", line 440, in d elete for i, obj in izip(xrange(CHUNK_SIZE), del_itr): File "C:\Python26\lib\site-packages\django\db\models\query.py", line 106, in _ result_iter self._fill_cache() File "C:\Python26\lib\site-packages\django\db\models\query.py", line 760, in _ fill_cache self._result_cache.append(self._iter.next()) File "C:\Python26\lib\site-packages\django\db\models\query.py", line 269, in i terator for row in compiler.results_iter(): File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py", line 67 2, in results_iter for rows in self.execute_sql(MULTI): File "C:\Python26\lib\site-packages\django\db\models\sql\compiler.py", line 72 7, in execute_sql cursor.execute(sql, params) File "C:\Python26\lib\site-packages\django\db\backends\util.py", line 15, in e xecute return self.cursor.execute(sql, params) File "C:\Python26\lib\site-packages\django\db\backends\sqlite3\base.py", line 200, in execute return Database.Cursor.execute(self, query, params) DatabaseError: no such column: students_degree.abbrev >>> Is there a simple way to just force a delete? Do I drop the table and then rerun manage.py schemamigration to recreate the table in south?

    Read the article

  • 2-step user registration with Django

    - by David S
    I'm creating a website with Django and want a fairly common 2-step user registration. What I mean by this is that the user fills in the some basic user information + some application specific information (sort of like a coupon value). Upon submit, an email is sent to ensure email address is valid. This email should contain a link to click on to "finish" the registration. When the link is clicked, the user is marked as validated and they are directed to a new page to complete optional "user profile" type information. So, pretty basic stuff. I have done some research and found django-registration by James Bennett. I do know who James is and have seen him at PyCons and DjanoCons in the past. There is obviously very few people in the world that know Django better than James (so, I know the quality of the code/app is good). But, it almost seems like a bit of over kill. I've read through the docs and was a bit confused (maybe I'm just being a bit dense today). I believe that if I do use django-registration, I will need to have some custom forms, etc. Is there anything else out there I should evaluate? Or are there any good tutorials or videos on using django-registration? I've done a bit of googling, but haven't found anything. But, I suspect that it might be a case of a lot of very common words that don't really find what you are looking for (django user registration tutorial/example). Or is just a case where it would be just about as easy to build your own solution with Django forms, etc? Here is the tech stack I'm using: Python 2.7.2 Django 1.3.1 PostgreSQL 9.1 psycopg2 2.4.1 Twitter Bootstrap 2.0.2

    Read the article

  • error in implementing static files in django

    - by POOJA GUPTA
    my settings.py file:- STATIC_ROOT = '/home/pooja/Desktop/static/' # URL prefix for static files. STATIC_URL = '/static/' # Additional locations of static files STATICFILES_DIRS = ( '/home/pooja/Desktop/mysite/search/static', ) my urls.py file:- from django.conf.urls import patterns, include, url from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^search/$','search.views.front_page'), url(r'^admin/', include(admin.site.urls)), ) urlpatterns += staticfiles_urlpatterns() I have created an app using django which seraches the keywords in 10 xml documents and then return their frequency count displayed as graphical representation and list of filenames and their respective counts.Now the list has filenames hyperlinked, I want to display them on the django server when user clicks them , for that I have used static files provision in django. Hyperlinking has been done in this manner: <ul> {% for l in list1 %} <li><a href="{{STATIC_URL}}static/{{l.file_name}}">{{l.file_name}}</a{{l.frequency_count</li> {% endfor %} </ul> Now when I run my app on the server, everything is running fine but as soon as I click on the filename, it gives me this error : Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order: ^search/$ ^admin/ ^static\/(?P<path>.*)$ The current URL, search/static/books.xml, didn't match any of these. I don't know why this error is coming, because I have followed the steps required to achieve this. I have posted my urls.py file and it is showing error in that only. I'm new to django , so Please help

    Read the article

  • How to make a model instance read-only after saving it once?

    - by Ryszard Szopa
    One of the functionalities in a Django project I am writing is sending a newsletter. I have a model, Newsletter and a function, send_newsletter, which I have registered to listen to Newsletter's post_save signal. When the newsletter object is saved via the admin interface, send_newsletter checks if created is True, and if yes it actually sends the mail. However, it doesn't make much sense to edit a newsletter that has already been sent, for the obvious reasons. Is there a way of making the Newsletter object read-only once it has been saved? Edit: I know I can override the save method of the object to raise an error or do nothin if the object existed. However, I don't see the point of doing that. As for the former, I don't know where to catch that error and how to communicate the user the fact that the object wasn't saved. As for the latter, giving the user false feedback (the admin interface saying that the save succeded) doesn't seem like a Good Thing. What I really want is allow the user to use the Admin interface to write the newsletter and send it, and then browse the newsletters that have already been sent. I would like the admin interface to show the data for sent newsletters in an non-editable input box, without the "Save" button. Alternatively I would like the "Save" button to be inactive.

    Read the article

  • django internationalization doesn't work

    - by xRobot
    I have: * created translation strings in the template and in the application view. * run this command: django-admin.py makemessages -l it and the file it/LC_MESSAGES/django.po has been created * translated strings in the django.po file. * run this command: django-admin.py compilemessages and I receive: processing file django.po in /home/jobber/Desktop/library/books/locale/it/LC_MESSAGES * set this in settings.py: LANGUAGE_CODE = 'it' TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", ) USE_I18N = True MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ) but.... translation doesn't work !! I always see english text. Why ?

    Read the article

  • Programmatically specifying Django model attributes

    - by mojbro
    Hi! I would like to add attributes to a Django models programmatically, at run time. For instance, lets say I have a Car model class and want to add one price attribute (database column) per currency, given a list of currencies. What is the best way to do this? I had an approach that I thought would work, but it didn't exactly. This is how I tried doing it, using the car example above: from django.db import models class Car(models.Model): name = models.CharField(max_length=50) currencies = ['EUR', 'USD'] for currency in currencies: Car.add_to_class('price_%s' % currency.lower(), models.IntegerField()) This does seem to work pretty well at first sight: $ ./manage.py syncdb Creating table shop_car $ ./manage.py dbshell shop=# \d shop_car Table "public.shop_car" Column | Type | Modifiers -----------+-----------------------+------------------------------------------------------- id | integer | not null default nextval('shop_car_id_seq'::regclass) name | character varying(50) | not null price_eur | integer | not null price_usd | integer | not null Indexes: "shop_car_pkey" PRIMARY KEY, btree (id) But when I try to create a new Car, it doesn't really work anymore: >>> from shop.models import Car >>> mycar = Car(name='VW Jetta', price_eur=100, price_usd=130) >>> mycar <Car: Car object> >>> mycar.save() Traceback (most recent call last): File "<console>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/base.py", line 410, in save self.save_base(force_insert=force_insert, force_update=force_update) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/base.py", line 495, in save_base result = manager._insert(values, return_id=update_pk) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/manager.py", line 177, in _insert return insert_query(self.model, values, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/query.py", line 1087, in insert_query return query.execute_sql(return_id) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/sql/subqueries.py", line 320, in execute_sql cursor = super(InsertQuery, self).execute_sql(None) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/sql/query.py", line 2369, in execute_sql cursor.execute(sql, params) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/util.py", line 19, in execute return self.cursor.execute(sql, params) ProgrammingError: column "price_eur" specified more than once LINE 1: ...NTO "shop_car" ("name", "price_eur", "price_usd", "price_eur... ^

    Read the article

  • Django: CharField with fixed length, how?

    - by Giovanni Di Milia
    Hi everybody, I wold like to have in my model a CharField with fixed length. In other words I want that only a specified length is valid. I tried to do something like volumenumber = models.CharField('Volume Number', max_length=4, min_length=4) but it gives me an error (it seems that I can use both max_length and min_length at the same time). Is there another quick way? Thanks EDIT: Following the suggestions of some people I will be a bit more specific: My model is this: class Volume(models.Model): vid = models.AutoField(primary_key=True) jid = models.ForeignKey(Journals, db_column='jid', null=True, verbose_name = "Journal") volumenumber = models.CharField('Volume Number') date_publication = models.CharField('Date of Publication', max_length=6, blank=True) class Meta: db_table = u'volume' verbose_name = "Volume" ordering = ['jid', 'volumenumber'] unique_together = ('jid', 'volumenumber') def __unicode__(self): return (str(self.jid) + ' - ' + str(self.volumenumber)) What I want is that the volumenumber must be exactly 4 characters. I.E. if someone insert '4b' django gives an error because it expects a string of 4 characters. So I tried with volumenumber = models.CharField('Volume Number', max_length=4, min_length=4) but it gives me this error: Validating models... Unhandled exception in thread started by <function inner_run at 0x70feb0> Traceback (most recent call last): File "/Library/Python/2.5/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run self.validate(display_num_errors=True) File "/Library/Python/2.5/site-packages/django/core/management/base.py", line 249, in validate num_errors = get_validation_errors(s, app) File "/Library/Python/2.5/site-packages/django/core/management/validation.py", line 28, in get_validation_errors for (app_name, error) in get_app_errors().items(): File "/Library/Python/2.5/site-packages/django/db/models/loading.py", line 131, in get_app_errors self._populate() File "/Library/Python/2.5/site-packages/django/db/models/loading.py", line 58, in _populate self.load_app(app_name, True) File "/Library/Python/2.5/site-packages/django/db/models/loading.py", line 74, in load_app models = import_module('.models', app_name) File "/Library/Python/2.5/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/Users/Giovanni/src/djangoTestSite/../djangoTestSite/journaldb/models.py", line 120, in <module> class Volume(models.Model): File "/Users/Giovanni/src/djangoTestSite/../djangoTestSite/journaldb/models.py", line 123, in Volume volumenumber = models.CharField('Volume Number', max_length=4, min_length=4) TypeError: __init__() got an unexpected keyword argument 'min_length' That obviously doesn't appear if I use only "max_length" OR "min_length". I read the documentation on the django web site and it seems that I'm right (I cannot use both together) so I'm asking if there is another way to solve the problem. Thanks again

    Read the article

  • django-registration with paypal integration

    - by GrumpyCanuck
    I'm trying to figure out how to integrate django-registration with django-paypal. Being a Django n00b, I'm trying to figure out how to implement a flow like this: User signs up using django-registation with 'active' flag set to 0 After registering, send user to PayPal for a subscription When they come back from PayPal successfully, I want to set 'active' to 1 I've been looking at the django-registration documentation and don't quite understand how to use different backends or implement a flow the way I want. Any tips on how to accomplish this would be greatly appreciated. django-paypal won't be a problem for me as I've done PayPal integration before (in PHP for a self-published book about CakePHP).

    Read the article

  • extending django usermodel

    - by imran-glt
    Hi i am trying to create a signup form for my django app. for this i have extended the user model. This is my Forms.py from contact.models import register from django import forms from django.contrib import auth class registerForm(forms.ModelForm): class Meta: model=register fields = ('latitude', 'longitude', 'status') class Meta: model = auth.models.User # this gives me the User fields fields = ('username', 'first_name', 'last_name', 'email') and this is my model.py from django.db import models from django.contrib.auth.models import User STATUS_CHOICES = ( ('Online', 'Online.'), ('Busy', 'Busy.'), ('AppearOffline', 'AppearOffline.'),) class register(models.Model): user = models.ForeignKey('auth.User', unique = True) latitude = models.DecimalField(max_digits=8, decimal_places=6) longitude = models.DecimalField(max_digits=8, decimal_places=6) status = models.CharField(max_length=8,choices=STATUS_CHOICES, blank= True, null=True) i dont know where i am making a mistake. the users passwords are not accepted at the login and the latitude and logitude are not saved against the created user user. i am fiarly new to django and dont know what to do any body have any solution .?

    Read the article

  • django objects.all() method issue

    - by xlione
    after I saved one item using MyModelClass.save() method of django in one view/page , at another view I use MyModelClass.objects.all() to list all items in MyModelClass but the newly added one always is missing at the new page. i am using django 1.1 i am using mysql middleware setting MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.locale.LocaleMiddleware', ) my model: class Company(models.Model): name = models.CharField(max_length=500) description = models.CharField(max_length=500,null=True) addcompany view def addcompany(request): if request.POST: form = AddCompanyForm(request.POST) if form.is_valid(): companyname = form.cleaned_data['companyname'] c = Company(name=companyname,description='description') c.save() return HttpResponseRedirect('/admins/') else: form = AddCompanyForm() return render_to_response('user/addcompany.html',{'form':form},context_instance=RequestContext(request)) after this page in another view i called this form in another view class CompanyForm(forms.Form): companies=((0,' '),) for o in CcicCompany.objects.all(): x=o.id,o.name companies+=(x,) company = forms.ChoiceField(choices=companies,label='Company Name') to list all companies but the recently added one is missing. The transaction should be successful, since after i do a apache server reboot , i can see the newly added company name Thanks for any help...

    Read the article

  • django shopping cart as a beginner

    - by Jacques Knie
    Hi, i'm quite new to django and trying to add a shopping cart to a simple webshop. What I need is a simple cart that can be filled and presents its content, which is then sent to the vendor via email. So Satchmo might be too big for this task. Therefore i chose django-cart (http://code.google.com/p/django-cart/) which causes some problems now. 1. Is django-cart the right thing? Or are there any better approaches to this task? 2. As I am a beginner even django-cart makes me struggle. I used the view and the template of the django-cart-website, but writing a form that can be used to add products to the cart took me hours. I probably need help in understanding the general layout of a shopping cart and its integration into a website. 3. Two more specific questions: Is it possible to dynamically populate a formfield in a template (e.g. with {{ object.id }})? Is django-cart able to change (update) the contents of a cart? I hope it's not too many questions at once. Thanks in advance Jacques

    Read the article

  • How to add manytomany field to flatpage admin

    - by valya
    Hello! I have a site with Flatpages, and now I need to be able to add galleries (Gallery model) to the page. This is going to be ManyToManyField, so there is no need to change the flatpages table. But I still can't define ManyToManyField in proxy class. I can define ManyToManyField in Gallery model, but it isn't comfortable for the client. How can I change FlatPage Admin to add a ManyToManyField from Galleries model?

    Read the article

  • Copying contents of a model

    - by Hulk
    If there exists an old data of a model say , query=Emp.objects.filter(pk=profile.id) Is there a easier way to copy the same values into the same model again.. Now that the id will be different so.. I have this requirement. Thanks..

    Read the article

  • Cannot assign - must be a "UserProfile" instance

    - by webvulture
    I have a class UserProfile defined which takes the default user as a foreign key. Now another class A has a foreign key to UserProfile. So for saving any instance in class A, how do i give it the userprofile object. Also, does making a class UserProfile mean that class user is still used and class UserProfile is just some other table? I need to know this as I have to take care of the user profile creation, so I should know what gets stored where? -- Confused

    Read the article

  • Copying contents of a module

    - by Hulk
    If there exists an old data of a model say , query=Emp.objects.filter(pk=profile.id) Is there a easier way to copy the same values into the same model again.. Now that the id will be different so.. I have this requirement. Thanks..

    Read the article

  • MultiWidget in MultiWidget how to compress the first one?

    - by sacabuche
    I have two MultiWidget one inside the other, but the problem is that the MultiWidget contained don't return compress, how do i do to get the right value from the first widget? In this case from SplitTimeWidget class SplitTimeWidget(forms.MultiWidget): """ Widget written to split widget into hours and minutes. """ def __init__(self, attrs=None): widgets = ( forms.Select(attrs=attrs, choices=([(hour,hour) for hour in range(0,24)])), forms.Select(attrs=attrs, choices=([(minute, str(minute).zfill(2)) for minute in range(0,60)])), ) super(SplitTimeWidget, self).__init__(widgets, attrs) def decompress(self, value): if value: return [value.hour, value.minute] return [None, None] class DateTimeSelectWidget (forms.MultiWidget): """ A widget that splits date into Date and Hours, minutes, seconds with selects """ date_format = DateInput.format def __init__(self, attrs=None, date_format=None): if date_format: self.date_format = date_format #if time_format: # self.time_format = time_format hours = [(hour,str(hour)+' h') for hour in range(0,24)] minutes = [(minute,minute) for minute in range(0,60)] seconds = minutes #not used always in 0s widgets = ( DateInput(attrs=attrs, format=self.date_format), SplitTimeWidget(attrs=attrs), ) super(DateTimeSelectWidget,self).__init__(widgets, attrs) def decompress(self, value): if value: return [value.date(), value.time()] else: [None, None, None]

    Read the article

  • Using a custom form in a modelformset factory?

    - by jamida
    I'd like to be able to use a customized form in a modelformset_factory. For example: models.py class Author(models.Model): name = models.CharField() address = models.CharField() class AuthorForm(ModelForm): class Meta: model = Author views.py def test_render(request): myModelFormset = modelformset_factory(Author) items = Author.objects.all() formsetInstance = myModelFormset(queryset = items) return render_to_response('template',locals()) The above code works just fine, but note I'm NOT using AuthorForm. The question is how can I get the modelformset_factory to use the AuthorForm (which I plan to customize later) instead of making a default Author form?

    Read the article

  • extending satchmo user profile

    - by z3a
    I'm trying to extend the basic user registration form and profile included in satchmo store, but I'm in problems with that. This what I've done: Create a new app "extendedprofile" Wrote a models.py that extends the satchmo_store.contact.models class and add the custom name fields. wrote an admin.py that unregister the Contact class and register my newapp but this still showing me the default user profile form. Maybe some one can show me the correct way to do this?

    Read the article

  • Form for Profile models ?

    - by xRobot
    Is there a way to create a form from profile models ? For example... If I have this model as profile: class blogger(models.Model): user = models.ForeignKey(User, unique=True) born = models.DateTimeField('born') gender = models.CharField(max_length=1, choices=gender ) about = models.TextField(_('about'), null=True, blank=True) . I want this form: Name: Surname: Born: Gender: About: Is this possible ? If yes how ?

    Read the article

  • Where to delete model image?

    - by WesDec
    I have a Model with an image field and I want to be able to change the image using a ModelForm. When changing the image, the old image should be deleted and replaced by the new image. I have tried to do this in the clean method of the ModelForm like this: def clean(self): cleaned_data = super(ModelForm, self).clean() old_profile_image = self.instance.image if old_profile_image: old_profile_image.delete(save=False) return cleaned_data This works fine unless the file indicated by the user is not correct (for example if its not an image), which result in the image being deleted without any new images being saved. I would like to know where is the best place to delete the old image? By this I mean where can I be sure that the new image is correct before deleting the old one?

    Read the article

  • How to set multiple permissions in one class view, depending on http request

    - by andrew13331
    How can I change the permissions depending on if it is a get or a post. Is it possible to do it in one class or would I have to separate it out into two classes? If its a get I want "permission_classes = (permissions.IsAuthenticated)" and if its a post I want "permission_classes = (permissions.IsAdminUser)" class CategoryList(generics.ListCreateAPIView): queryset = QuestionCategory.objects.all() serializer_class = QuestionCategorySerializer permission_classes = (permissions.IsAuthenticated,)

    Read the article

  • Why is django giving me an attribute error when I call _set.all() for its children models?

    - by user1876508
    I have two models defined from django.db import models class Blog(models.Model): title = models.CharField(max_length=144) @property def posts(self): self.Post_set.all() class Post(models.Model): title = models.CharField(max_length=144) text = models.TextField() blog = models.ForeignKey('Blog') but the problem is, when I run shell, and enter >>> blog = Blog(title="My blog") >>> post = Post(title="My first post", text="Here is the main text for my blog post", blog=blog) >>> blog.posts I get the error Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/lucas/Programming/Python/Django/djangorestfun/blog/models.py", line 9, in posts self.Post_set.all() AttributeError: 'Blog' object has no attribute 'Post_set' >>> Now I am having the following problem >>> from blog.models import * >>> blog = Blog(title="gewrhter") >>> blog.save() >>> blog.__dict__ {'_state': <django.db.models.base.ModelState object at 0x259be10>, 'id': 1, 'title': 'gewrhter'} >>> blog._state.__dict__ {'adding': False, 'db': 'default'} >>> post = Post(title="sdhxcvb", text="hdbfdgb", blog=blog) >>> post.save() >>> post.__dict__ {'blog_id': 1, 'title': 'sdhxcvb', 'text': 'hdbfdgb', '_blog_cache': <Blog: Blog object>, '_state': <django.db.models.base.ModelState object at 0x259bed0>, 'id': 1} >>> blog.posts >>> print blog.posts None Second update So I followed your guide, but I am still getting nothing. In addition, blog.posts gives me an error. >>> from blog.models import * >>> blog = Blog(title="asdf") >>> blog.save() >>> post = Post(title="asdf", text="sdxcvb", blog=blog) >>> post.save() >>> blog.posts Traceback (most recent call last): File "<console>", line 1, in <module> AttributeError: 'Blog' object has no attribute 'posts' >>> print blog.all_posts None

    Read the article

  • Is it possible to change the model name in the django admin site?

    - by luc
    Hello, I am translating a django app and I would like to translate also the homepage of the django admin site. On this page are listed the application names and the model class names. I would like to translate the model class name but I don't find how to give a user-friendly name for a model class. Does anybody know how to do that?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >