'Add item' not working, symptom: 'POST method not allowed 405'. it is using 'create view'. 'add category' which bases on same class view works fine.
the error hasn't occur since I uploaded 2 weeks ago on Heroku, there is no use if I roll back to the point it is less complex and working.
i don't know what makes the app fail without changing code
add item works fine only in 2 categories 'hello-xinxin','songs life',i guess this means the code is good. other categories can't not be added in any new item. is this because database mess up?
The app: http://songs-todolist.herokuapp.com/todolist/
Source code: https://github.com/SongGithub/2DoList
The url you are trying to access is not mentioned in your urls.py of to_do_list_app.
That's why, it is failing.
Related
hope anyone here will be able to help me out.
I am trying to get the reverse url for a viewset but somehow it's not working.
I will quickly go through what I have done from the moment everything was working fine to the moment the reverse stopped working.
I had a viewset on an app called "card" the reverse was reverse('card:card-list') everything was perfect, then I decided to move the card viewset to a different app called 'company' I did check the new urls structure by using the django_extensions and running the following command on the terminal python manage.py show_urls which gave me the new routing company:card-list I have then changed my reverse to reverse('company:card-list'), but now the code is broken and the reverse is not working as expected.
I have done those changes cause an end point as /api/company/card instead of /api/card/ .
Any ideas on how to solve it?
tks a lot
I have a rails 5.0.0.1 app that has model for books and for authors.
In production and development, the pages display as expected showing the book.author.name
However, in my tests, book.author is valid and as expected, but book.author.name produces an error "ActionView::Template::Error: undefined method `name' for nil:NilClass"
using byebug I found that the author_id for the book is set to 459301548 but there is no author with that id.
How does minitest handle things differently such that the error only occurs in the test environment?
I have tried moving things around and trying different ways to populate #books to use in my #books.each do |book| but the only thing that seems to work is to remove the reference to book.author.name
The error is only occurring when not logged in, but I need to check my tests to make sure that I don't get it in other cases.
I don't know why this makes a difference, but when I change the variable assignment in my controller from:
#books = Book.paginate(...)
to:
#books = Book.all.paginate(...)
The error goes away.
The pages still seems to show the correct information in development and production either way.
I have a form here with a nested table - where each table can dynamically grow, i.e., the inner table (w/ Transit No and Account No) and the outer table (Accounts by ID No). Here is an example:
(Behind the buttons:
Add - $.parent.tbl.Row.instanceManager.addInstance();
Remove - $.parent.instanceManager.removeInstance(this.parent.index); (In
production I make sure there is at least one row to remove...)
In the definition for each table I do not have checked 'Repeat Table for Each Data Item'. This works great. However I did try with that checked and the outcome was the same.
Now, when I email the form and open the attachment, this is what I see:
You can see that the second table didn't make it, and apparently a row was added to the inner table in the first, without any data.
Any ideas on what's going wrong here? And what I can do about it?
Unfortunately I'm not sure what's wrong with your form but I have made a similar form that works - so I can show you how I did it and list a few things that I can think of that can cause problems.
This is what my form looks like and when I e-mail it, it comes out exactly the way it is:
(It has repeatable parent- and childsubforms like yours)
I did it entirely with JS though, no FormCalc and Dollar $igns :D
When a button is pressed I call a function from a Scriptobject.
These are the main parts of my script inside my functions:
Adding a Subform:
var oNewInstance = subform.instanceManager.addInstance(1);
Deleting a Subform:
if (subform.instanceManager.count > subform.instanceManager.occur.min)
{
subform.instanceManager.removeInstance(subform.index);
}
And these are my subforms' properties (in German, but you can figure it out :P):
Your problem might also have completely other reasons though, make sure you don't have any changes in an initialize,docReady, preSubmit and similar actions that occur between sending and opening the sent PDF.
Also before sending it as an e-mail you have to save it in Acrobat as a Reader Extended PDF:
Besides that I've noticed that sometimes problems can occur due to the target version (Selectable in LCD under File > Form Properties > Defaults).
It helped me sometimes to set it to the newest one.
I have a Customer_ratings model that allows users to leave feedback on each other. The web app is working properly, and feedback is collected, stored and displayed.
I wanted to go in and delete some feedback through the rails console, but when I enter Customer_rating.all, I get the following error:
LoadError: Unable to autoload constant Customer_rating, expected /Users/myapps/app/models/customer_rating.rb to define it
Similarly, if I enter Customer_rating[0], I get:
RuntimeError: Circular dependency detected while autoloading constant Customer_rating
I don't have this issue while accessing other tables through my console.
What could be causing the issue, and why wouldn't this error prohibit Customer_ratings from working properly through the web app?
It seems like a case of messed up naming convention.
As per Rails naming convention, file names should be in snake_case and class names in CamelCase. In your scenario, the file name should be customer_rating.rb and class name should be CustomerRating.
After making these changes, use CustomerRating.all(as the updated class name is CustomerRating) to fetch all the customer ratings. Do not use Customer_rating.all.
I'd also like to add a scenario of this problem that I found for future reference.
I'm running Rails 4.0 and I had this same problem but what happened was I had a model named Student inside student.rb that was contained in a folder called Student. I didn't realize it at first but the folder name was the problem. Changing the folder name to something other than a model name solved the problem.
If the naming convention is not off, like in this question, it may be an issue on initial first load if you're making a lot of requests at the same time. I experienced this with nested controllers Api::LocationsController.
I solved it by enabled eager_load in development env:
Rails.application.configure do
...
# Enabled this to avoid crash unable to autoload controller
# Error happens when you start and stop server on initial requests
# solution found via https://github.com/rails/rails/issues/32082#issuecomment-367715194
config.eager_load = true
I based this off of rails issues comments: https://github.com/rails/rails/issues/32082#issuecomment-367715194
You just need to modify the name of the Module
For example if the link is http://sairam.esy.es/users/customer_rating then
you controller should like be
module Users
class RatingController
# ...
def customer_rating
# ...
end
# ...
end
end
I've got an object, Question, that I've created an edit page for. This worked fine. Someone would edit the question and changes would show up on the page that just showed the question. Recently however, I started noticing the changes did NOT show up on the list of questions. This problem persists after having changed the cache-backend to the dummybackend. When running the developmentserver, I see the request with a nice 200 code. Print statements I put into the view, that I expected to show up in the output of de dev-server, do not show up. So apperently the view method isn't even called. I get the feeling the 200 code does not mean something wasn't retrieved from cache.
Three ways I noticed, make the website show the change in the object after it has been saved:
1. Signing the current user out of the website and then logging in again.
2. Appending ?something=whatever to the url.
3. Waiting for an unknown amount of time. I tried if the waitingtime could be changed by modifying session-parameters, but to no avail.
Though I think it is possible to use that last method, it doesn't feel right. And it means means quite a bit of work to solve a problem that wasn't there before. And I'd like to know just what happend.
Here is the cache-bit from settings.py. No surprises there I'd think:
CACHES = {
'default':{
'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}
And, because logging out & in helps, the session stuff:
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_AGE = 60
Oh and this problem is also in the admin..
Suggestions?